Closes #29717.
Replaces #29760.
Co-authored-by: cunshunxia <cunshunxia@tencent.com>
(void) unlinkat(dir_fd, p, 0);
return r;
}
+
+int write_vconsole_conf(int dir_fd, const char *fname, char **l) {
+ char **headers = STRV_MAKE(
+ "# Written by systemd-localed(8) or systemd-firstboot(1), read by systemd-localed",
+ "# and systemd-vconsole-setup(8). Use localectl(1) to update this file.");
+
+ return write_env_file(dir_fd, fname, headers, l);
+}
int merge_env_file(char ***env, FILE *f, const char *fname);
int write_env_file(int dir_fd, const char *fname, char **headers, char **l);
+
+int write_vconsole_conf(int dir_fd, const char *fname, char **l);
keymap = STRV_MAKE(strjoina("KEYMAP=", arg_keymap));
- r = write_env_file(pfd, f, NULL, keymap);
+ r = write_vconsole_conf(pfd, f, keymap);
if (r < 0)
return log_error_errno(r, "Failed to write /etc/vconsole.conf: %m");
return 0;
}
- r = write_env_file_label(AT_FDCWD, "/etc/vconsole.conf", NULL, l);
+ r = write_vconsole_conf_label(l);
if (r < 0)
return r;
return r;
}
+
+int write_vconsole_conf_label(char **l) {
+ int r;
+
+ r = mac_selinux_create_file_prepare("/etc/vconsole.conf", S_IFREG);
+ if (r < 0)
+ return r;
+
+ r = write_vconsole_conf(AT_FDCWD, "/etc/vconsole.conf", l);
+
+ mac_selinux_create_file_clear();
+
+ return r;
+}
* for all */
int write_env_file_label(int dir_fd, const char *fname, char **headers, char **l);
+
+int write_vconsole_conf_label(char **l);