]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Make the check for non-executable shell only a warning. 210/head
authorTomas Mraz <tmraz@fedoraproject.org>
Thu, 16 Jan 2020 11:55:30 +0000 (12:55 +0100)
committerTomas Mraz <tmraz@fedoraproject.org>
Thu, 16 Jan 2020 11:59:29 +0000 (12:59 +0100)
Although it is a good idea to check for an inadvertent typo
in the shell name it is possible that the shell might not be present
on the system yet when the user is added.

src/useradd.c

index c29ae949b006cd736772125a6b5d5748f68b4fc6..a679392d01339bcea75bf640fbeaba52f9bc293b 100644 (file)
@@ -1328,15 +1328,22 @@ static void process_flags (int argc, char **argv)
                                if (   ( !VALID (optarg) )
                                    || (   ('\0' != optarg[0])
                                        && ('/'  != optarg[0])
-                                       && ('*'  != optarg[0]) )
-                                   || (stat(optarg, &st) != 0)
-                                   || (S_ISDIR(st.st_mode))
-                                   || (access(optarg, X_OK) != 0)) {
+                                       && ('*'  != optarg[0]) )) {
                                        fprintf (stderr,
                                                 _("%s: invalid shell '%s'\n"),
                                                 Prog, optarg);
                                        exit (E_BAD_ARG);
                                }
+                               if (    '\0' != optarg[0]
+                                    && '*'  != optarg[0]
+                                    && strcmp(optarg, "/sbin/nologin") != 0
+                                    && (   stat(optarg, &st) != 0
+                                        || S_ISDIR(st.st_mode)
+                                        || access(optarg, X_OK) != 0)) {
+                                       fprintf (stderr,
+                                                _("%s: Warning: missing or non-executable shell '%s'\n"),
+                                                Prog, optarg);
+                               }
                                user_shell = optarg;
                                def_shell = optarg;
                                sflg = true;