At first, a blank in pw_shell is sufficient to assume that the user
login shell is actually a shell script.
If execution fails, the test consists of testing argv[0] for "/bin/sh"
which is set in case of shell script.
But "/bin/sh" can also be the actual login shell set for the user.
If execution fails, the error message erroneously talks about a shell
script.
Keep a boolean variable around to perform the test exactly once to
have a precise error message.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
.conv = { openpam_ttyconv, NULL } /* OpenPAM conversation function */
#endif
};
+ bool script;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
}
/* if the shell field has a space: treat it like a shell script */
- if (strchr(pwd->pw_shell, ' ')) {
+ script = strchr(pwd->pw_shell, ' ') != NULL;
+
+ if (script) {
char *buff;
xasprintf(&buff, "exec %s", pwd->pw_shell);
execvp(child_argv[0], child_argv + 1);
- if (!strcmp(child_argv[0], "/bin/sh"))
+ if (script)
warn(_("couldn't exec shell script"));
else
warn(_("no shell"));