}
/* We knowingly ignore the results of this call */
- mkdir_p(a->where, 0555);
+ mkdir_p_label(a->where, 0555);
if (pipe2(p, O_NONBLOCK|O_CLOEXEC) < 0) {
r = -errno;
return;
}
- mkdir_p(a->where, a->directory_mode);
+ mkdir_p_label(a->where, a->directory_mode);
/* Before we do anything, let's see if somebody is playing games with us? */
if (lstat(a->where, &st) < 0) {
goto fail;
}
- mkdir_parents(p+10, 0755);
+ mkdir_parents_label(p+10, 0755);
unlink(p+10);
m->private_bus = dbus_server_listen(p, &error);
free(p);
return -ENOMEM;
}
- r = mkdir_p(p, 0755);
+ r = mkdir_p_label(p, 0755);
if (r < 0) {
log_error("Failed to create generator directory: %s", strerror(-r));
free(p);
/* The access mode here doesn't really matter too much, since
* the mounted file system will take precedence anyway. */
- mkdir_p(p->where, 0755);
+ mkdir_p_label(p->where, 0755);
log_debug("Mounting %s to %s of type %s with options %s.",
p->what,
dev_setup();
/* Create a few directories we always want around */
- label_mkdir("/run/systemd", 0755);
- label_mkdir("/run/systemd/system", 0755);
+ mkdir_label("/run/systemd", 0755);
+ mkdir_label("/run/systemd/system", 0755);
return 0;
}
m->control_command_id = MOUNT_EXEC_MOUNT;
m->control_command = m->exec_command + MOUNT_EXEC_MOUNT;
- mkdir_p(m->where, m->directory_mode);
+ mkdir_p_label(m->where, m->directory_mode);
/* Create the source directory for bind-mounts if needed */
p = get_mount_parameters_fragment(m);
if (p && mount_is_bind(p))
- mkdir_p(p->what, m->directory_mode);
+ mkdir_p_label(p->what, m->directory_mode);
if (m->from_fragment)
r = exec_command_set(
if (s->type == PATH_EXISTS || s->type == PATH_EXISTS_GLOB)
return;
- if ((r = mkdir_p(s->path, mode)) < 0)
+ if ((r = mkdir_p_label(s->path, mode)) < 0)
log_warning("mkdir(%s) failed: %s", s->path, strerror(-r));
}
}
NULSTR_FOREACH(dir, dirs)
- if (mkdir_p(dir, 0755) < 0 && errno != EEXIST) {
+ if (mkdir_p_label(dir, 0755) < 0 && errno != EEXIST) {
log_error("Failed to mkdir %s: %m", dir);
return -errno;
}
assert(path);
assert(_fd);
- mkdir_parents(path, directory_mode);
+ mkdir_parents_label(path, directory_mode);
r = label_context_set(path, S_IFIFO);
if (r < 0)
goto fail;
}
- mkdir_parents(to, 0755);
+ mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
log_error("Failed to create symlink '%s' to '%s': %m", from, to);
r = -errno;
goto fail;
}
- mkdir_parents(to, 0755);
+ mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
log_error("Failed to create symlink '%s' to '%s': %m", from, to);
r = -errno;
goto fail;
}
- mkdir_parents(to, 0755);
+ mkdir_parents_label(to, 0755);
if (symlink(from, to) < 0) {
log_error("Failed to create symlink '%s' to '%s': %m", from, to);
r = -errno;
goto finish;
}
- mkdir_parents(lnk, 0755);
+ mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
log_error("Failed to create symlink: %m");
r = -errno;
goto finish;
}
- mkdir_parents(lnk, 0755);
+ mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
log_error("Failed to create symlink: %m");
r = -errno;
goto finish;
}
- mkdir_parents(lnk, 0755);
+ mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
log_error("Failed to create symlink: %m");
r = -errno;
goto finish;
}
- mkdir_parents(lnk, 0755);
+ mkdir_parents_label(lnk, 0755);
if (symlink(unit, lnk) < 0) {
log_error("Failed to creat symlink: %m");
r = -errno;
goto finish;
}
- mkdir_parents(lnk, 0755);
+ mkdir_parents_label(lnk, 0755);
if (symlink(automount_unit, lnk) < 0) {
log_error("Failed to create symlink: %m");
r = -errno;
goto finish;
}
- mkdir_parents(to, 0755);
+ mkdir_parents_label(to, 0755);
r = symlink(from, to);
if (r < 0) {
log_info("Detected coredump of the journal daemon itself, diverting coredump to /var/lib/systemd/coredump/.");
- mkdir_p("/var/lib/systemd/coredump", 0755);
+ mkdir_p_label("/var/lib/systemd/coredump", 0755);
f = fopen("/var/lib/systemd/coredump/core.systemd-journald", "we");
if (!f) {
/* OK, we really need the runtime journal, so create
* it if necessary. */
- (void) mkdir_parents(fn, 0755);
+ (void) mkdir_parents_label(fn, 0755);
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, NULL, &s->runtime_journal);
free(fn);
if (add) {
int fd;
- mkdir_parents(filename, 0755);
+ mkdir_parents_label(filename, 0755);
fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
if (fd >= 0)
close(fd);
/* write a database file */
util_strscpyl(filename_tmp, sizeof(filename_tmp), filename, ".tmp", NULL);
- mkdir_parents(filename_tmp, 0755);
+ mkdir_parents_label(filename_tmp, 0755);
f = fopen(filename_tmp, "we");
if (f == NULL) {
udev_err(udev, "unable to create temporary db file '%s': %m\n", filename_tmp);
return 0;
}
- mkdir_parents("/etc/X11/xorg.conf.d", 0755);
+ mkdir_parents_label("/etc/X11/xorg.conf.d", 0755);
r = fopen_temporary("/etc/X11/xorg.conf.d/00-keyboard.conf", &f, &temp_path);
if (r < 0)
goto finish;
}
- mkdir_p("/etc/udev/rules.d", 0755);
+ mkdir_p_label("/etc/udev/rules.d", 0755);
r = write_one_line_file_atomic(file, rule);
if (r < 0)
goto finish;
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
- mkdir_p("/var/lib/systemd", 0755);
+ mkdir_p_label("/var/lib/systemd", 0755);
- r = safe_mkdir("/var/lib/systemd/linger", 0755, 0, 0);
+ r = mkdir_safe_label("/var/lib/systemd/linger", 0755, 0, 0);
if (r < 0)
return bus_send_error_reply(connection, message, &error, r);
assert(i);
- r = safe_mkdir("/run/systemd/inhibit", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0);
if (r < 0)
goto finish;
/* Create FIFO */
if (!i->fifo_path) {
- r = safe_mkdir("/run/systemd/inhibit", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/inhibit", 0755, 0, 0);
if (r < 0)
return r;
if (!s->started)
return 0;
- r = safe_mkdir("/run/systemd/seats", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/seats", 0755, 0, 0);
if (r < 0)
goto finish;
if (!s->started)
return 0;
- r = safe_mkdir("/run/systemd/sessions", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/sessions", 0755, 0, 0);
if (r < 0)
goto finish;
/* Create FIFO */
if (!s->fifo_path) {
- r = safe_mkdir("/run/systemd/sessions", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/sessions", 0755, 0, 0);
if (r < 0)
return r;
if (!u->started)
return 0;
- r = safe_mkdir("/run/systemd/users", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/users", 0755, 0, 0);
if (r < 0)
goto finish;
assert(u);
- r = safe_mkdir("/run/user", 0755, 0, 0);
+ r = mkdir_safe_label("/run/user", 0755, 0, 0);
if (r < 0) {
log_error("Failed to create /run/user: %s", strerror(-r));
return r;
} else
p = u->runtime_path;
- r = safe_mkdir(p, 0700, u->uid, u->gid);
+ r = mkdir_safe_label(p, 0700, u->uid, u->gid);
if (r < 0) {
log_error("Failed to create runtime directory %s: %s", p, strerror(-r));
free(p);
goto fail;
}
- r = safe_mkdir("/run/systemd/multi-session-x", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/multi-session-x", 0755, 0, 0);
if (r < 0) {
log_error("Failed to create directory: %s", strerror(-r));
goto fail;
continue;
}
- mkdir_p(where, 0755);
+ mkdir_p_label(where, 0755);
if (mount(mount_table[k].what,
where,
goto child_fail;
}
- if (mkdir_parents(home, 0775) < 0) {
- log_error("mkdir_parents() failed: %m");
+ if (mkdir_parents_label(home, 0775) < 0) {
+ log_error("mkdir_parents_label() failed: %m");
goto child_fail;
}
- if (safe_mkdir(home, 0775, uid, gid) < 0) {
- log_error("safe_mkdir() failed: %m");
+ if (mkdir_safe_label(home, 0775, uid, gid) < 0) {
+ log_error("mkdir_safe_label() failed: %m");
goto child_fail;
}
goto finish;
}
- if (mkdir_parents(RANDOM_SEED, 0755) < 0) {
+ if (mkdir_parents_label(RANDOM_SEED, 0755) < 0) {
log_error("Failed to create directories parents of %s: %m", RANDOM_SEED);
goto finish;
}
goto finish;
}
- mkdir_parents(to, 0755);
+ mkdir_parents_label(to, 0755);
r = symlink(from, to);
if (r < 0) {
sigset_add_many(&mask, SIGINT, SIGTERM, -1);
assert_se(sigprocmask(SIG_BLOCK, &mask, &oldmask) == 0);
- mkdir_p("/run/systemd/ask-password", 0755);
+ mkdir_p_label("/run/systemd/ask-password", 0755);
u = umask(0022);
fd = mkostemp(temp, O_CLOEXEC|O_CREAT|O_WRONLY);
if (r < 0)
return r;
- r = mkdir_parents(fs, 0755);
+ r = mkdir_parents_label(fs, 0755);
if (r >= 0) {
if (mkdir(fs, 0755) >= 0)
assert(old_path);
assert(new_path);
- mkdir_parents(new_path, 0755);
+ mkdir_parents_label(new_path, 0755);
if (symlink(old_path, new_path) >= 0) {
add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, new_path, old_path);
#include "util.h"
#include "log.h"
-int safe_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid) {
+int mkdir_label(const char *path, mode_t mode) {
+ return label_mkdir(path, mode);
+}
+
+int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid) {
struct stat st;
if (label_mkdir(path, mode) >= 0)
return 0;
}
-int mkdir_parents(const char *path, mode_t mode) {
+int mkdir_parents_label(const char *path, mode_t mode) {
struct stat st;
const char *p, *e;
}
}
-int mkdir_p(const char *path, mode_t mode) {
+int mkdir_p_label(const char *path, mode_t mode) {
int r;
/* Like mkdir -p */
- if ((r = mkdir_parents(path, mode)) < 0)
+ if ((r = mkdir_parents_label(path, mode)) < 0)
return r;
if (label_mkdir(path, mode) < 0 && errno != EEXIST)
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-int safe_mkdir(const char *path, mode_t mode, uid_t uid, gid_t gid);
-int mkdir_parents(const char *path, mode_t mode);
-int mkdir_p(const char *path, mode_t mode);
+int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid);
+int mkdir_label(const char *path, mode_t mode);
+int mkdir_parents_label(const char *path, mode_t mode);
+int mkdir_p_label(const char *path, mode_t mode);
#endif
* then filter out this link, if it is actually is
* one. */
- mkdir_parents(data_home, 0777);
+ mkdir_parents_label(data_home, 0777);
(void) symlink("../../../.config/systemd/user", data_home);
}
mode_t old_mask;
/* Create parents */
- mkdir_parents(a->sockaddr.un.sun_path, directory_mode);
+ mkdir_parents_label(a->sockaddr.un.sun_path, directory_mode);
/* Enforce the right access mode for the socket*/
old_mask = umask(~ socket_mode);
assert(c);
- r = safe_mkdir("/run/systemd/shutdown", 0755, 0, 0);
+ r = mkdir_safe_label("/run/systemd/shutdown", 0755, 0, 0);
if (r < 0) {
log_error("Failed to create shutdown subdirectory: %s", strerror(-r));
return r;
mode |= S_IFCHR;
if (strcmp(action, "remove") != 0) {
- mkdir_parents(udev_device_get_devnode(dev), 0755);
+ mkdir_parents_label(udev_device_get_devnode(dev), 0755);
mknod(udev_device_get_devnode(dev), mode, udev_device_get_devnum(dev));
} else {
unlink(udev_device_get_devnode(dev));
case CREATE_DIRECTORY:
u = umask(0);
- mkdir_parents(i->path, 0755);
+ mkdir_parents_label(i->path, 0755);
r = mkdir(i->path, i->mode);
umask(u);
if (asprintf(&p, "/run/systemd/ask-password-block/%u:%u", major(devnr), minor(devnr)) < 0)
return -ENOMEM;
- mkdir_parents(p, 0700);
+ mkdir_parents_label(p, 0700);
mkfifo(p, 0600);
fd = open(p, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
tty_block_fd = wall_tty_block();
- mkdir_p("/run/systemd/ask-password", 0755);
+ mkdir_p_label("/run/systemd/ask-password", 0755);
if ((notify = inotify_init1(IN_CLOEXEC)) < 0) {
r = -errno;
/* This link indicates the missing firmware file and the associated device */
log_debug("did not find firmware file '%s'\n", firmware);
do {
- err = mkdir_parents(misspath, 0755);
+ err = mkdir_parents_label(misspath, 0755);
if (err != 0 && err != -ENOENT)
break;
err = symlink(udev_device_get_devpath(dev), misspath);
} else {
log_debug("creating symlink '%s' to '%s'\n", slink, target);
do {
- err = mkdir_parents(slink, 0755);
+ err = mkdir_parents_label(slink, 0755);
if (err != 0 && err != -ENOENT)
break;
label_context_set(slink, S_IFLNK);
util_strscpyl(slink_tmp, sizeof(slink_tmp), slink, TMP_FILE_EXT, NULL);
unlink(slink_tmp);
do {
- err = mkdir_parents(slink_tmp, 0755);
+ err = mkdir_parents_label(slink_tmp, 0755);
if (err != 0 && err != -ENOENT)
break;
label_context_set(slink_tmp, S_IFLNK);
do {
int fd;
- err = mkdir_parents(filename, 0755);
+ err = mkdir_parents_label(filename, 0755);
if (err != 0 && err != -ENOENT)
break;
fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
}
snprintf(filename, sizeof(filename), "/run/udev/watch/%d", wd);
- mkdir_parents(filename, 0755);
+ mkdir_parents_label(filename, 0755);
unlink(filename);
symlink(udev_device_get_id_filename(dev), filename);
continue;
util_strscpyl(filename, sizeof(filename), "/dev/", devname, NULL);
- mkdir_parents(filename, 0755);
+ mkdir_parents_label(filename, 0755);
label_context_set(filename, mode);
log_debug("mknod '%s' %c%u:%u\n", filename, type, maj, min);
if (mknod(filename, mode, makedev(maj, min)) < 0 && errno == EEXIST)
return 0;
/* make sure we do not get here again */
- mkdir_parents("/run/udev/data", 0755);
+ mkdir_parents_label("/run/udev/data", 0755);
mkdir(filename, 0755);
/* old database */