[Pkg-shadow-devel] Re: [Pkg-shadow-commits] r814 -
trunk/debian/patches
Alexander Gattin
xrgtn at yandex.ru
Tue Jan 17 23:11:09 UTC 2006
Hi!
Here I attach the combined 484_su-p_preserve_PATH
plus 485_shelle-exitcodes patch.
It's made against your CVS.
One more difference is that I left shell() to be called
as it used before, only prototype is changed. I.e.
there are not 2 functions called shell() and shelle()
as with 484+485.
--
WBR,
xrgtn
-------------- next part --------------
Index: lib/prototypes.h
===================================================================
RCS file: /cvsroot/shadow/lib/prototypes.h,v
retrieving revision 1.26
diff -u -r1.26 prototypes.h
--- lib/prototypes.h 2 Jan 2006 23:32:51 -0000 1.26
+++ lib/prototypes.h 17 Jan 2006 23:07:52 -0000
@@ -149,7 +149,7 @@
extern void setup_env (struct passwd *);
/* shell.c */
-extern void shell (const char *, const char *);
+extern int shell (const char *, const char *, char *const *);
/* strtoday.c */
extern long strtoday (const char *);
Index: libmisc/age.c
===================================================================
RCS file: /cvsroot/shadow/libmisc/age.c,v
retrieving revision 1.12
diff -u -r1.12 age.c
--- libmisc/age.c 31 Aug 2005 17:24:57 -0000 1.12
+++ libmisc/age.c 17 Jan 2006 23:07:53 -0000
@@ -35,6 +35,7 @@
#include <errno.h>
#include "prototypes.h"
#include "defines.h"
+#include "exitcodes.h"
#include <pwd.h>
#include <grp.h>
@@ -125,7 +126,7 @@
execl (PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *) 0);
err = errno;
perror ("Can't execute " PASSWD_PROGRAM);
- _exit ((err == ENOENT) ? 127 : 126);
+ _exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
} else if (pid == -1) {
perror ("fork");
exit (1);
Index: libmisc/shell.c
===================================================================
RCS file: /cvsroot/shadow/libmisc/shell.c,v
retrieving revision 1.12
diff -u -r1.12 shell.c
--- libmisc/shell.c 14 Jan 2006 21:16:25 -0000 1.12
+++ libmisc/shell.c 17 Jan 2006 23:07:54 -0000
@@ -51,13 +51,15 @@
* the file. If all that fails, give up in disgust ...
*/
-void shell (const char *file, const char *arg)
+int shell (const char *file, const char *arg, char *const envp[])
{
char arg0[1024];
int err;
- if (file == (char *) 0)
- exit (1);
+ if (file == (char *) 0) {
+ errno = EINVAL;
+ return errno;
+ }
/*
* The argv[0]'th entry is usually the path name, but
@@ -75,7 +77,7 @@
* able to figure out what we are up to without too much
* grief.
*/
- execle (file, arg, (char *) 0, newenvp);
+ execle (file, arg, (char *) 0, envp);
err = errno;
/* Linux handles #! in the kernel, and bash doesn't make
@@ -94,7 +96,7 @@
if (getc (fp) == '#' && getc (fp) == '!') {
fclose (fp);
execle ("/bin/sh", "sh",
- file, (char *) 0, newenvp);
+ file, (char *) 0, envp);
err = errno;
} else {
fclose (fp);
@@ -111,5 +113,5 @@
snprintf (arg0, sizeof arg0, _("Cannot execute %s"), file);
errno = err;
perror (arg0);
- exit (1);
+ return err;
}
Index: src/login.c
===================================================================
RCS file: /cvsroot/shadow/src/login.c,v
retrieving revision 1.78
diff -u -r1.78 login.c
--- src/login.c 6 Jan 2006 19:41:46 -0000 1.78
+++ src/login.c 17 Jan 2006 23:07:59 -0000
@@ -47,6 +47,7 @@
#include "getdef.h"
#include "prototypes.h"
#include "pwauth.h"
+#include "exitcodes.h"
#ifdef USE_PAM
#include "pam_defs.h"
@@ -331,6 +332,7 @@
int flag;
int subroot = 0;
int is_console;
+ int err;
const char *cp;
char *tmp;
char fromhost[512];
@@ -1127,10 +1129,12 @@
SYSLOG ((LOG_INFO, "`%s' logged in %s", username, fromhost));
#endif
closelog ();
- if ((tmp = getdef_str ("FAKE_SHELL")) != NULL) {
- shell (tmp, pwent.pw_shell); /* fake shell */
- }
- shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */
+ if ((tmp = getdef_str ("FAKE_SHELL")) != NULL)
+ err = shell (tmp, pwent.pw_shell, newenvp); /* fake shell */
+ else
+ /* exec the shell finally */
+ err = shell (pwent.pw_shell, (char *) 0, newenvp);
+ exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
/* NOT REACHED */
return 0;
}
Index: src/newgrp.c
===================================================================
RCS file: /cvsroot/shadow/src/newgrp.c,v
retrieving revision 1.42
diff -u -r1.42 newgrp.c
--- src/newgrp.c 10 Nov 2005 16:01:27 -0000 1.42
+++ src/newgrp.c 17 Jan 2006 23:08:02 -0000
@@ -38,9 +38,11 @@
#include "defines.h"
#include "getdef.h"
#include "prototypes.h"
+#include "exitcodes.h"
/*
* Global variables
*/
+extern char **newenvp;
extern char **environ;
#ifdef HAVE_SETGROUPS
@@ -103,6 +105,7 @@
int needspasswd = 0;
int i;
int cflag = 0;
+ int err = 0;
gid_t gid;
char *cp;
const char *cpasswd, *name, *prog;
@@ -556,13 +559,8 @@
audit_logger (AUDIT_USER_START, Prog, "changing",
NULL, getuid (), 0);
#endif
- if (errno == ENOENT) {
- perror ("/bin/sh");
- exit (127);
- } else {
- perror ("/bin/sh");
- exit (126);
- }
+ perror ("/bin/sh");
+ exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
}
/*
@@ -631,7 +629,8 @@
* Exec the login shell and go away. We are trying to get back to
* the previous environment which should be the user's login shell.
*/
- shell (prog, initflag ? (char *) 0 : cp);
+ err = shelle (prog, initflag ? (char *) 0 : cp, newenvp);
+ exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
/* NOTREACHED */
failure:
Index: src/su.c
===================================================================
RCS file: /cvsroot/shadow/src/su.c,v
retrieving revision 1.63
diff -u -r1.63 su.c
--- src/su.c 10 Jan 2006 15:18:17 -0000 1.63
+++ src/su.c 17 Jan 2006 23:08:04 -0000
@@ -156,7 +156,8 @@
* have been applied. Some work was needed to get it integrated into
* su.c from shadow.
*/
-static void run_shell (const char *shellstr, char *args[], int doshell)
+static void run_shell (const char *shellstr, char *args[], int doshell,
+ char *const envp[])
{
int child;
sigset_t ourset;
@@ -168,14 +169,10 @@
pam_end (pamh, PAM_SUCCESS);
if (doshell)
- shell (shellstr, (char *) args[0]);
+ (void) shell (shellstr, (char *) args[0], envp);
else
- (void) execv (shellstr, (char **) args);
- {
- int exit_status = (errno == ENOENT ? 127 : 126);
-
- exit (exit_status);
- }
+ (void) execve (shellstr, (char **) args, envp);
+ exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
} else if (child == -1) {
(void) fprintf (stderr, "%s: Cannot fork user shell\n", Prog);
SYSLOG ((LOG_WARN, "Cannot execute %s", shellstr));
@@ -292,6 +289,7 @@
#ifdef USE_PAM
int ret;
#else /* !USE_PAM */
+ int err = 0;
RETSIGTYPE (*oldsig) ();
int is_console = 0;
@@ -850,19 +848,21 @@
*/
argv[-1] = shellstr;
#ifndef USE_PAM
- (void) execv (shellstr, &argv[-1]);
-#else
- run_shell (shellstr, &argv[-1], 0);
-#endif
+ (void) execve (shellstr, &argv[-1], environ);
+ err = errno;
(void) fprintf (stderr, _("No shell\n"));
SYSLOG ((LOG_WARN, "Cannot execute %s", shellstr));
closelog ();
- exit (1);
+ exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
+#else
+ run_shell (shellstr, &argv[-1], 0, environ); /* no return */
+#endif
}
#ifndef USE_PAM
- shell (shellstr, cp);
+ err = shell (shellstr, cp, environ);
+ exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
#else
- run_shell (shellstr, &cp, 1);
+ run_shell (shellstr, &cp, 1, environ);
#endif
/* NOT REACHED */
exit (1);
Index: src/sulogin.c
===================================================================
RCS file: /cvsroot/shadow/src/sulogin.c,v
retrieving revision 1.23
diff -u -r1.23 sulogin.c
--- src/sulogin.c 7 Sep 2005 15:00:45 -0000 1.23
+++ src/sulogin.c 17 Jan 2006 23:08:05 -0000
@@ -39,6 +39,7 @@
#include "getdef.h"
#include "prototypes.h"
#include "pwauth.h"
+#include "exitcodes.h"
/*
* Global variables
*/
@@ -76,6 +77,7 @@
char *cp;
char **envp = environ;
TERMIO termio;
+ int err = 0;
#ifdef USE_TERMIO
ioctl (0, TCGETA, &termio);
@@ -220,6 +222,8 @@
#ifdef USE_SYSLOG
closelog ();
#endif
- shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */
- /*NOTREACHED*/ return (0);
+ /* exec the shell finally. */
+ err = shell (pwent.pw_shell, (char *) 0, environ);
+ exit (err == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
+ /*NOTREACHED*/ return (0);
}
Index: src/userdel.c
===================================================================
RCS file: /cvsroot/shadow/src/userdel.c,v
retrieving revision 1.58
diff -u -r1.58 userdel.c
--- src/userdel.c 1 Dec 2005 20:10:48 -0000 1.58
+++ src/userdel.c 17 Jan 2006 23:08:07 -0000
@@ -50,6 +50,7 @@
#include "pwauth.h"
#include "pwio.h"
#include "shadowio.h"
+#include "exitcodes.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
@@ -572,13 +573,8 @@
pid = fork ();
if (pid == 0) {
execl (cmd, cmd, user, (char *) 0);
- if (errno == ENOENT) {
- perror (cmd);
- _exit (127);
- } else {
- perror (cmd);
- _exit (126);
- }
+ perror (cmd);
+ _exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
} else if (pid == -1) {
perror ("fork");
return;
More information about the Pkg-shadow-devel
mailing list