]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
locale,firstboot: add headers to vconsole.conf
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 30 Oct 2023 11:30:12 +0000 (20:30 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 31 Oct 2023 08:15:21 +0000 (17:15 +0900)
Closes #29717.
Replaces #29760.

Co-authored-by: cunshunxia <cunshunxia@tencent.com>
src/basic/env-file.c
src/basic/env-file.h
src/firstboot/firstboot.c
src/locale/localed-util.c
src/shared/env-file-label.c
src/shared/env-file-label.h

index 226d578d389899fff185142b26ff14cfd4d2b905..c2cbff4d843c6250eb90ff690c6f81141f190a9a 100644 (file)
@@ -637,3 +637,11 @@ int write_env_file(int dir_fd, const char *fname, char **headers, char **l) {
         (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);
+}
index a9714cfd53a79ef00f2f1d5b4c0a0a2a07fcc4a3..37db30765b7f4386246d8db7ade6aa6dc0d8311a 100644 (file)
@@ -20,3 +20,5 @@ int load_env_file_pairs_fd(int fd, const char *fname, char ***ret);
 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);
index 6a5b5715c1a90da79551f66b90aefae6c5865b4c..6cf7415a1887d9eba9bb8696f5d98ac5ab570f03 100644 (file)
@@ -534,7 +534,7 @@ static int process_keymap(int rfd) {
 
         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");
 
index eca765c3f23b750eec8d13b526dfff95caf24f7b..199f05b9177f042eee685afafb872bfd9e2d2034 100644 (file)
@@ -532,7 +532,7 @@ int vconsole_write_data(Context *c) {
                 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;
 
index 0ab2bb9b7433e7191d98e3d65ed8d110552cc02a..5917b6377f320cc0757b6a04303e641cfc80a6d2 100644 (file)
@@ -19,3 +19,17 @@ int write_env_file_label(int dir_fd, const char *fname, char **headers, char **l
 
         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;
+}
index 1f1d727b6991dee6f5a6e97e0ad360cee17a5af2..5ba45e400578c006a034395603fae9e4a7f29186 100644 (file)
@@ -6,3 +6,5 @@
  * for all */
 
 int write_env_file_label(int dir_fd, const char *fname, char **headers, char **l);
+
+int write_vconsole_conf_label(char **l);