mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-08-25 13:50:12 +03:00
tree-wide: make use of the new WRITE_STRING_FILE_MKDIR_0755 flag
This commit is contained in:
@ -490,9 +490,8 @@ static int process_hostname(void) {
|
||||
if (isempty(arg_hostname))
|
||||
return 0;
|
||||
|
||||
mkdir_parents(etc_hostname, 0755);
|
||||
r = write_string_file(etc_hostname, arg_hostname,
|
||||
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC);
|
||||
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write %s: %m", etc_hostname);
|
||||
|
||||
@ -512,9 +511,8 @@ static int process_machine_id(void) {
|
||||
if (sd_id128_is_null(arg_machine_id))
|
||||
return 0;
|
||||
|
||||
mkdir_parents(etc_machine_id, 0755);
|
||||
r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id),
|
||||
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC);
|
||||
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write machine id: %m");
|
||||
|
||||
|
@ -521,13 +521,12 @@ static int add_root_rw(DissectedPartition *p) {
|
||||
(void) generator_enable_remount_fs_service(arg_dest);
|
||||
|
||||
path = strjoina(arg_dest, "/systemd-remount-fs.service.d/50-remount-rw.conf");
|
||||
(void) mkdir_parents(path, 0755);
|
||||
|
||||
r = write_string_file(path,
|
||||
"# Automatically generated by systemd-gpt-generator\n\n"
|
||||
"[Service]\n"
|
||||
"Environment=SYSTEMD_REMOUNT_ROOT_RW=1\n",
|
||||
WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_NOFOLLOW);
|
||||
WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_NOFOLLOW|WRITE_STRING_FILE_MKDIR_0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write drop-in file %s: %m", path);
|
||||
|
||||
|
@ -121,10 +121,9 @@ int sync_cgroup(pid_t pid, CGroupUnified unified_requested, uid_t uid_shift) {
|
||||
(void) rm_rf(fn, REMOVE_ROOT|REMOVE_ONLY_DIRECTORIES);
|
||||
|
||||
fn = strjoina(tree, cgroup, "/cgroup.procs");
|
||||
(void) mkdir_parents(fn, 0755);
|
||||
|
||||
sprintf(pid_string, PID_FMT, pid);
|
||||
r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
r = write_string_file(fn, pid_string, WRITE_STRING_FILE_DISABLE_BUFFER|WRITE_STRING_FILE_MKDIR_0755);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to move process: %m");
|
||||
goto finish;
|
||||
|
@ -154,7 +154,7 @@ static int load_state(Context *c, const struct rfkill_event *event) {
|
||||
if (IN_SET(r, -ENOENT, 0)) {
|
||||
/* No state file or it's truncated? Then save the current state */
|
||||
|
||||
r = write_string_file(state_file, one_zero(event->soft), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
|
||||
r = write_string_file(state_file, one_zero(event->soft), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write state file %s: %m", state_file);
|
||||
|
||||
@ -246,7 +246,7 @@ static int save_state_cancel(Context *c, const struct rfkill_event *event) {
|
||||
static int save_state_write_one(struct write_queue_item *item) {
|
||||
int r;
|
||||
|
||||
r = write_string_file(item->file, one_zero(item->state), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC);
|
||||
r = write_string_file(item->file, one_zero(item->state), WRITE_STRING_FILE_CREATE|WRITE_STRING_FILE_ATOMIC|WRITE_STRING_FILE_MKDIR_0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to write state file %s: %m", item->file);
|
||||
|
||||
@ -280,10 +280,6 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
umask(0022);
|
||||
|
||||
r = mkdir_p("/var/lib/systemd/rfkill", 0755);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to create rfkill directory: %m");
|
||||
|
||||
n = sd_listen_fds(false);
|
||||
if (n < 0)
|
||||
return log_error_errno(n, "Failed to determine whether we got any file descriptors passed: %m");
|
||||
|
Reference in New Issue
Block a user