X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsysusers%2Fsysusers.c;h=d679394dfad7e6bb790747a08dc9289f0c29cd52;hb=f7f628b5db770feb8b18990436baefaec55c460b;hp=40a669725e7fff75b6cd2675498a14a0039ee447;hpb=932ad62b84165b0acf690ea34c4b8083657ae244;p=elogind.git diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 40a669725..d679394df 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -35,6 +35,8 @@ #include "conf-files.h" #include "copy.h" #include "utf8.h" +#include "label.h" +#include "fileio-label.h" typedef enum ItemType { ADD_USER = 'u', @@ -62,6 +64,8 @@ typedef struct Item { static char *arg_root = NULL; static const char conf_file_dirs[] = + "/etc/sysusers.d\0" + "/run/sysusers.d\0" "/usr/local/lib/sysusers.d\0" "/usr/lib/sysusers.d\0" #ifdef HAVE_SPLIT_USR @@ -310,7 +314,7 @@ static int write_files(void) { _cleanup_fclose_ FILE *original = NULL; group_path = fix_root("/etc/group"); - r = fopen_temporary(group_path, &group, &group_tmp); + r = fopen_temporary_label("/etc/group", group_path, &group, &group_tmp); if (r < 0) goto finish; @@ -386,7 +390,7 @@ static int write_files(void) { _cleanup_fclose_ FILE *original = NULL; passwd_path = fix_root("/etc/passwd"); - r = fopen_temporary(passwd_path, &passwd, &passwd_tmp); + r = fopen_temporary_label("/etc/passwd", passwd_path, &passwd, &passwd_tmp); if (r < 0) goto finish; @@ -1107,7 +1111,11 @@ static bool valid_gecos(const char *d) { if (!utf8_is_valid(d)) return false; - if (strpbrk(d, ":\n")) + if (string_has_cc(d, NULL)) + return false; + + /* Colons are used as field separators, and hence not OK */ + if (strchr(d, ':')) return false; return true; @@ -1485,6 +1493,8 @@ int main(int argc, char *argv[]) { umask(0022); + label_init(NULL); + r = 0; if (optind < argc) {