]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
pwck.c: only check home dirs if set and not a system user 177/head
authored <ed@s5h.net>
Sun, 25 Aug 2019 19:11:24 +0000 (20:11 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sun, 6 Oct 2019 03:04:37 +0000 (22:04 -0500)
Closes #126

Changelog: pwck, better to look at array than to use strnlen.

src/pwck.c

index f022e473d77054a8424d44026404f48e0eb83323..581cfddf6e0f2773a69608e056fdd7481c680a37 100644 (file)
@@ -382,6 +382,8 @@ static void check_pw_file (int *errors, bool *changed)
        struct commonio_entry *pfe, *tpfe;
        struct passwd *pwd;
        struct spwd *spw;
+       uid_t min_sys_id = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL);
+       uid_t max_sys_id = (uid_t) getdef_ulong ("SYS_UID_MAX", 999UL);
 
        /*
         * Loop through the entire password file.
@@ -510,15 +512,20 @@ static void check_pw_file (int *errors, bool *changed)
                }
 
                /*
-                * Make sure the home directory exists
+                * If uid is system and has a home directory, then check
                 */
-               if (!quiet && (access (pwd->pw_dir, F_OK) != 0)) {
+               if (!(pwd->pw_uid >= min_sys_id && pwd->pw_uid <= max_sys_id && pwd->pw_dir && pwd->pw_dir[0])) {
                        /*
-                        * Home directory doesn't exist, give a warning
+                        * Make sure the home directory exists
                         */
-                       printf (_("user '%s': directory '%s' does not exist\n"),
-                               pwd->pw_name, pwd->pw_dir);
-                       *errors += 1;
+                       if (!quiet && (access (pwd->pw_dir, F_OK) != 0)) {
+                               /*
+                                * Home directory doesn't exist, give a warning
+                                */
+                               printf (_("user '%s': directory '%s' does not exist\n"),
+                                               pwd->pw_name, pwd->pw_dir);
+                               *errors += 1;
+                       }
                }
 
                /*