2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2008-04-27 06:10:09 +05:30
|
|
|
* Copyright (c) 1989 - 1994, Julianne Frances Haugh
|
|
|
|
* Copyright (c) 1996 - 2000, Marek Michałkiewicz
|
|
|
|
* Copyright (c) 2000 - 2006, Tomasz Kłoczko
|
|
|
|
* Copyright (c) 2007 - 2008, Nicolas François
|
2007-10-07 17:14:02 +05:30
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2008-04-27 06:10:09 +05:30
|
|
|
* 3. The name of the copyright holders or contributors may not be used to
|
|
|
|
* endorse or promote products derived from this software without
|
|
|
|
* specific prior written permission.
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2008-04-27 06:10:09 +05:30
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
|
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2008-04-27 06:10:09 +05:30
|
|
|
|
|
|
|
/* Some parts substantially derived from an ancestor of:
|
|
|
|
su for GNU. Run a shell with substitute user and group IDs.
|
|
|
|
|
2007-10-27 19:20:40 +05:30
|
|
|
Copyright (C) 1992-2003 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2008-04-27 06:10:09 +05:30
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA. */
|
2007-10-27 19:20:40 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-11-11 05:16:11 +05:30
|
|
|
#ident "$Id$"
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
#include <getopt.h>
|
2007-10-07 17:16:34 +05:30
|
|
|
#include <grp.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <signal.h>
|
2007-10-07 17:14:02 +05:30
|
|
|
#include <stdio.h>
|
2007-10-07 17:16:34 +05:30
|
|
|
#include <sys/types.h>
|
2007-10-07 17:14:02 +05:30
|
|
|
#include "prototypes.h"
|
|
|
|
#include "defines.h"
|
2007-10-07 17:17:11 +05:30
|
|
|
#include "exitcodes.h"
|
2007-10-07 17:14:02 +05:30
|
|
|
#include "pwauth.h"
|
|
|
|
#include "getdef.h"
|
2007-10-07 17:16:34 +05:30
|
|
|
#ifdef USE_PAM
|
|
|
|
#include "pam_defs.h"
|
|
|
|
#endif
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* Assorted #defines to control su's behavior
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Global variables
|
|
|
|
*/
|
* src/newgrp.c, src/userdel.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/pwconv.c, src/chpasswd.c, src/logoutd.c,
src/chfn.c, src/groupmems.c, src/usermod.c, src/pwunconv.c,
src/expiry.c, src/groupdel.c, src/chgpasswd.c, src/useradd.c,
src/su.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/grpconv.c,
src/groups.c, src/grpunconv.c, src/chsh.c: Prog is now global (not
static to the file) so that it can be used by the helper functions
of libmisc.
* lib/prototypes.h: Added extern char *Prog.
* libmisc/find_new_gid.c, libmisc/find_new_uid.c: Indicate the
program name with the warning.
2008-09-06 18:21:53 +05:30
|
|
|
char *Prog;
|
|
|
|
|
2007-10-07 17:14:14 +05:30
|
|
|
/* not needed by sulog.c anymore */
|
|
|
|
static char name[BUFSIZ];
|
|
|
|
static char oldname[BUFSIZ];
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/* If nonzero, change some environment vars to indicate the user su'd to. */
|
2008-06-11 03:37:51 +05:30
|
|
|
static bool change_environment;
|
2007-10-07 17:16:34 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
#ifdef USE_PAM
|
2007-10-07 17:16:34 +05:30
|
|
|
static pam_handle_t *pamh = NULL;
|
2008-06-11 03:37:51 +05:30
|
|
|
static bool caught = false;
|
2007-10-07 17:16:34 +05:30
|
|
|
#endif
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:15:14 +05:30
|
|
|
extern struct passwd pwent;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* External identifiers
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern char **newenvp;
|
|
|
|
extern char **environ;
|
2007-10-07 17:16:34 +05:30
|
|
|
extern size_t newenvc;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
#ifndef USE_PAM
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
static RETSIGTYPE die (int);
|
|
|
|
static int iswheel (const char *);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* die - set or reset termio modes.
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* die() is called before processing begins. signal() is then called
|
|
|
|
* with die() as the signal handler. If signal later calls die() with a
|
|
|
|
* signal number, the terminal modes are then reset.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
static RETSIGTYPE die (int killed)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
static TERMIO sgtty;
|
|
|
|
|
|
|
|
if (killed)
|
2007-10-07 17:14:59 +05:30
|
|
|
STTY (0, &sgtty);
|
2007-10-07 17:14:02 +05:30
|
|
|
else
|
2007-10-07 17:14:59 +05:30
|
|
|
GTTY (0, &sgtty);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
if (killed) {
|
2007-10-07 17:14:59 +05:30
|
|
|
closelog ();
|
|
|
|
exit (killed);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
static int iswheel (const char *username)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
struct group *grp;
|
|
|
|
|
* lib/prototypes.h, configure.in, libmisc/Makefile.am,
libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetpwuid.c,
libmisc/xgetgrnam.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c:
Added functions xgetpwnam(), xgetpwuid(), xgetgrnam(),
xgetgrgid(), and xgetspnam(). They allocate memory for the
returned structure and are more robust to successive calls. They
are implemented with the libc's getxxyyy_r() functions if
available.
* libmisc/limits.c, libmisc/entry.c, libmisc/chowntty.c,
libmisc/addgrps.c, libmisc/myname.c, libmisc/rlogin.c,
libmisc/pwdcheck.c, src/newgrp.c, src/login_nopam.c,
src/userdel.c, src/lastlog.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/chfn.c, src/groupmems.c,
src/usermod.c, src/expiry.c, src/groupdel.c, src/chgpasswd.c,
src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/suauth.c,
src/faillog.c, src/groups.c, src/chsh.c, src/id.c: Review all the
usage of one of the getpwnam(), getpwuid(), getgrnam(),
getgrgid(), and getspnam() functions. It was noticed on
http://bugs.debian.org/341230 that chfn and chsh use a passwd
structure after calling a pam function, which result in using
information from the passwd structure requested by pam, not the
original one. It is much easier to use the new xget... functions
to avoid these issues. I've checked which call to the original
get... functions could be left (reducing the scope of the
structure if possible), and I've left comments to ease future
reviews (e.g. /* local, no need for xgetpwnam */).
Note: the getpwent/getgrent calls should probably be checked also.
* src/groupdel.c, src/expiry.c: Fix typos in comments.
* src/groupmod.c: Re-indent.
* libmisc/Makefile.am, lib/groupmem.c, lib/groupio.c, lib/pwmem.c,
lib/pwio.c, lib/shadowmem.c, lib/shadowio.c: Move the __<xx>_dup
functions (used by the xget... functions) from the <xx>io.c files
to the new <xx>mem.c files. This avoid linking some utils against
the SELinux library.
2007-11-19 04:45:26 +05:30
|
|
|
grp = getgrnam ("wheel"); /* !USE_PAM, no need for xgetgrnam */
|
2008-08-31 23:00:30 +05:30
|
|
|
if ( (NULL ==grp)
|
|
|
|
|| (NULL == grp->gr_mem)) {
|
2007-10-07 17:14:02 +05:30
|
|
|
return 0;
|
2008-08-31 23:00:30 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
return is_on_list (grp->gr_mem, username);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/* borrowed from GNU sh-utils' "su.c" */
|
2008-06-11 03:37:51 +05:30
|
|
|
static bool restricted_shell (const char *shellstr)
|
2007-10-07 17:17:11 +05:30
|
|
|
{
|
|
|
|
char *line;
|
|
|
|
|
|
|
|
setusershell ();
|
|
|
|
while ((line = getusershell ()) != NULL) {
|
2008-06-11 03:37:51 +05:30
|
|
|
if (('#' != *line) && (strcmp (line, shellstr) == 0)) {
|
2007-10-07 17:17:11 +05:30
|
|
|
endusershell ();
|
2008-06-11 03:37:51 +05:30
|
|
|
return false;
|
2007-10-07 17:17:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
endusershell ();
|
2008-06-11 03:37:51 +05:30
|
|
|
return true;
|
2007-10-07 17:17:11 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
static void su_failure (const char *tty)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2007-10-07 17:14:59 +05:30
|
|
|
sulog (tty, 0, oldname, name); /* log failed attempt */
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef USE_SYSLOG
|
2008-08-31 23:00:30 +05:30
|
|
|
if (getdef_bool ("SYSLOG_SU_ENAB")) {
|
2008-06-11 03:37:51 +05:30
|
|
|
SYSLOG (((0 != pwent.pw_uid) ? LOG_INFO : LOG_NOTICE,
|
|
|
|
"- %s %s:%s", tty,
|
|
|
|
('\0' != oldname[0]) ? oldname : "???",
|
|
|
|
('\0' != name[0]) ? name : "???"));
|
2008-08-31 23:00:30 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
closelog ();
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
2007-10-07 17:15:40 +05:30
|
|
|
|
2007-10-07 17:16:34 +05:30
|
|
|
#ifdef USE_PAM
|
2007-10-07 17:15:40 +05:30
|
|
|
/* Signal handler for parent process later */
|
2008-01-06 18:50:25 +05:30
|
|
|
static void catch_signals (unused int sig)
|
2007-10-07 17:15:40 +05:30
|
|
|
{
|
2008-06-11 03:37:51 +05:30
|
|
|
caught = true;
|
2007-10-07 17:15:40 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/* This I ripped out of su.c from sh-utils after the Mandrake pam patch
|
|
|
|
* have been applied. Some work was needed to get it integrated into
|
|
|
|
* su.c from shadow.
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
static void run_shell (const char *shellstr, char *args[], bool doshell,
|
2007-10-07 17:17:22 +05:30
|
|
|
char *const envp[])
|
2007-10-07 17:15:40 +05:30
|
|
|
{
|
2008-06-14 02:32:07 +05:30
|
|
|
pid_t child;
|
2007-10-07 17:15:40 +05:30
|
|
|
sigset_t ourset;
|
|
|
|
int status;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
child = fork ();
|
|
|
|
if (child == 0) { /* child shell */
|
2007-11-17 22:49:44 +05:30
|
|
|
/*
|
|
|
|
* PAM_DATA_SILENT is not supported by some modules, and
|
|
|
|
* there is no strong need to clean up the process space's
|
|
|
|
* memory since we will either call exec or exit.
|
|
|
|
pam_end (pamh, PAM_SUCCESS | PAM_DATA_SILENT);
|
|
|
|
*/
|
2007-10-07 17:15:40 +05:30
|
|
|
|
2008-06-14 02:32:07 +05:30
|
|
|
if (doshell) {
|
2007-10-07 17:17:22 +05:30
|
|
|
(void) shell (shellstr, (char *) args[0], envp);
|
2008-06-14 02:32:07 +05:30
|
|
|
} else {
|
2007-10-07 17:17:22 +05:30
|
|
|
(void) execve (shellstr, (char **) args, envp);
|
2008-06-14 02:32:07 +05:30
|
|
|
}
|
2007-10-07 17:17:22 +05:30
|
|
|
exit (errno == ENOENT ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
2008-06-14 02:32:07 +05:30
|
|
|
} else if ((pid_t)-1 == child) {
|
2007-10-07 17:16:07 +05:30
|
|
|
(void) fprintf (stderr, "%s: Cannot fork user shell\n", Prog);
|
2007-10-07 17:17:11 +05:30
|
|
|
SYSLOG ((LOG_WARN, "Cannot execute %s", shellstr));
|
2007-10-07 17:15:40 +05:30
|
|
|
closelog ();
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
/* parent only */
|
|
|
|
sigfillset (&ourset);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (sigprocmask (SIG_BLOCK, &ourset, NULL) != 0) {
|
2007-10-07 17:15:40 +05:30
|
|
|
(void) fprintf (stderr, "%s: signal malfunction\n", Prog);
|
2008-06-11 03:37:51 +05:30
|
|
|
caught = true;
|
2007-10-07 17:15:40 +05:30
|
|
|
}
|
|
|
|
if (!caught) {
|
|
|
|
struct sigaction action;
|
|
|
|
|
2007-10-07 17:17:22 +05:30
|
|
|
action.sa_handler = catch_signals;
|
2007-10-07 17:15:40 +05:30
|
|
|
sigemptyset (&action.sa_mask);
|
|
|
|
action.sa_flags = 0;
|
|
|
|
sigemptyset (&ourset);
|
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
if ( (sigaddset (&ourset, SIGTERM) != 0)
|
|
|
|
|| (sigaddset (&ourset, SIGALRM) != 0)
|
|
|
|
|| (sigaction (SIGTERM, &action, NULL) != 0)
|
|
|
|
|| (sigprocmask (SIG_UNBLOCK, &ourset, NULL) != 0)
|
2007-10-07 17:15:40 +05:30
|
|
|
) {
|
|
|
|
fprintf (stderr,
|
|
|
|
"%s: signal masking malfunction\n", Prog);
|
2008-06-11 03:37:51 +05:30
|
|
|
caught = true;
|
2007-10-07 17:15:40 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!caught) {
|
|
|
|
do {
|
2008-06-14 02:32:07 +05:30
|
|
|
pid_t pid;
|
2007-10-07 17:15:40 +05:30
|
|
|
|
|
|
|
pid = waitpid (-1, &status, WUNTRACED);
|
|
|
|
|
2008-06-14 02:32:07 +05:30
|
|
|
if (((pid_t)-1 != pid) && (0 != WIFSTOPPED (status))) {
|
2008-05-18 19:11:56 +05:30
|
|
|
/* The child (shell) was suspended.
|
|
|
|
* Suspend su. */
|
|
|
|
kill (getpid (), WSTOPSIG(status));
|
|
|
|
/* wake child when resumed */
|
2007-10-07 17:15:40 +05:30
|
|
|
kill (pid, SIGCONT);
|
|
|
|
}
|
2008-06-11 03:37:51 +05:30
|
|
|
} while (0 != WIFSTOPPED (status));
|
2007-10-07 17:15:40 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if (caught) {
|
|
|
|
fprintf (stderr, "\nSession terminated, killing shell...");
|
|
|
|
kill (child, SIGTERM);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pam_close_session (pamh, 0);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:15:40 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_close_session: %s",
|
|
|
|
pam_strerror (pamh, ret)));
|
2007-10-07 17:17:01 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret));
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, ret);
|
2007-10-07 17:15:40 +05:30
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = pam_end (pamh, PAM_SUCCESS);
|
|
|
|
|
|
|
|
if (caught) {
|
|
|
|
sleep (2);
|
|
|
|
kill (child, SIGKILL);
|
|
|
|
fprintf (stderr, " ...killed.\n");
|
|
|
|
exit (-1);
|
|
|
|
}
|
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
exit ((0 != WIFEXITED (status)) ? WEXITSTATUS (status)
|
|
|
|
: WTERMSIG (status) + 128);
|
2007-10-07 17:15:40 +05:30
|
|
|
}
|
|
|
|
#endif
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/*
|
|
|
|
* usage - print command line syntax and exit
|
|
|
|
*/
|
|
|
|
static void usage (void)
|
|
|
|
{
|
2008-01-25 02:12:12 +05:30
|
|
|
fputs (_("Usage: su [options] [LOGIN]\n"
|
2008-01-25 02:24:42 +05:30
|
|
|
"\n"
|
|
|
|
"Options:\n"
|
|
|
|
" -c, --command COMMAND pass COMMAND to the invoked shell\n"
|
|
|
|
" -h, --help display this help message and exit\n"
|
|
|
|
" -, -l, --login make the shell a login shell\n"
|
|
|
|
" -m, -p,\n"
|
|
|
|
" --preserve-environment do not reset environment variables, and\n"
|
|
|
|
" keep the same shell\n"
|
|
|
|
" -s, --shell SHELL use SHELL instead of the default in passwd\n"
|
|
|
|
"\n"), stderr);
|
2007-10-07 17:17:11 +05:30
|
|
|
exit (E_USAGE);
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* su - switch user id
|
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* su changes the user's ids to the values for the specified user. if
|
|
|
|
* no new user name is specified, "root" is used by default.
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* Any additional arguments are passed to the user's shell. In
|
|
|
|
* particular, the argument "-c" will cause the next argument to be
|
|
|
|
* interpreted as a command by the common shell programs.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
int main (int argc, char **argv)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2007-10-07 17:14:59 +05:30
|
|
|
char *cp;
|
2008-06-11 03:37:51 +05:30
|
|
|
const char *tty = NULL; /* Name of tty SU is run from */
|
|
|
|
bool doshell = false;
|
|
|
|
bool fakelogin = false;
|
|
|
|
bool amroot = false;
|
2007-10-07 17:14:02 +05:30
|
|
|
uid_t my_uid;
|
2008-06-11 03:37:51 +05:30
|
|
|
struct passwd *pw = NULL;
|
2007-10-07 17:14:59 +05:30
|
|
|
char **envp = environ;
|
2008-06-11 03:37:51 +05:30
|
|
|
char *shellstr = NULL;
|
|
|
|
char *command = NULL;
|
2007-10-07 17:14:59 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef USE_PAM
|
2007-10-07 17:17:57 +05:30
|
|
|
char **envcp;
|
2007-10-07 17:14:02 +05:30
|
|
|
int ret;
|
2007-10-07 17:14:59 +05:30
|
|
|
#else /* !USE_PAM */
|
2007-10-07 17:17:22 +05:30
|
|
|
int err = 0;
|
|
|
|
|
2008-01-06 18:50:25 +05:30
|
|
|
RETSIGTYPE (*oldsig) (int);
|
2007-10-07 17:14:02 +05:30
|
|
|
int is_console = 0;
|
2007-10-07 17:14:59 +05:30
|
|
|
|
|
|
|
struct spwd *spwd = 0;
|
2007-10-07 17:16:25 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef SU_ACCESS
|
|
|
|
char *oldpass;
|
|
|
|
#endif
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
sanitize_env ();
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-10 03:58:16 +05:30
|
|
|
(void) setlocale (LC_ALL, "");
|
|
|
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
|
|
|
(void) textdomain (PACKAGE);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
change_environment = true;
|
2007-10-07 17:17:11 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* Get the program name. The program name is used as a prefix to
|
|
|
|
* most error messages.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
Prog = Basename (argv[0]);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
OPENLOG ("su");
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/*
|
|
|
|
* Process the command line arguments.
|
|
|
|
*/
|
|
|
|
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Parse the command line options.
|
|
|
|
*/
|
|
|
|
int option_index = 0;
|
|
|
|
int c;
|
|
|
|
static struct option long_options[] = {
|
2007-10-07 17:17:22 +05:30
|
|
|
{"command", required_argument, NULL, 'c'},
|
2007-10-07 17:17:11 +05:30
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"login", no_argument, NULL, 'l'},
|
|
|
|
{"preserve-environment", no_argument, NULL, 'p'},
|
|
|
|
{"shell", required_argument, NULL, 's'},
|
|
|
|
{NULL, 0, NULL, '\0'}
|
|
|
|
};
|
|
|
|
|
|
|
|
while ((c =
|
2007-12-26 20:40:48 +05:30
|
|
|
getopt_long (argc, argv, "c:hlmps:", long_options,
|
2007-10-07 17:17:11 +05:30
|
|
|
&option_index)) != -1) {
|
|
|
|
switch (c) {
|
2007-10-07 17:17:22 +05:30
|
|
|
case 'c':
|
|
|
|
command = optarg;
|
|
|
|
break;
|
2007-10-07 17:17:11 +05:30
|
|
|
case 'h':
|
|
|
|
usage ();
|
|
|
|
break;
|
|
|
|
case 'l':
|
2008-06-11 03:37:51 +05:30
|
|
|
fakelogin = true;
|
2007-10-07 17:17:11 +05:30
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
case 'p':
|
|
|
|
/* This will only have an effect if the target
|
|
|
|
* user do not have a restricted shell, or if
|
|
|
|
* su is called by root.
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
change_environment = false;
|
2007-10-07 17:17:11 +05:30
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
shellstr = optarg;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage (); /* NOT REACHED */
|
|
|
|
}
|
|
|
|
}
|
2007-12-26 20:40:48 +05:30
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
if ((optind < argc) && (strcmp (argv[optind], "-") == 0)) {
|
|
|
|
fakelogin = true;
|
2007-10-07 17:17:11 +05:30
|
|
|
optind++;
|
2008-06-11 03:37:51 +05:30
|
|
|
if ( (optind < argc)
|
|
|
|
&& (strcmp (argv[optind], "--") == 0)) {
|
2007-10-07 17:17:11 +05:30
|
|
|
optind++;
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
initenv ();
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
my_uid = getuid ();
|
2007-10-07 17:14:02 +05:30
|
|
|
amroot = (my_uid == 0);
|
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* Get the tty name. Entries will be logged indicating that the user
|
|
|
|
* tried to change to the named new user from the current terminal.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
cp = ttyname (0);
|
|
|
|
if ((isatty (0) != 0) && (NULL != cp)) {
|
|
|
|
if (strncmp (cp, "/dev/", 5) == 0) {
|
2007-10-07 17:14:02 +05:30
|
|
|
tty = cp + 5;
|
2008-06-11 03:37:51 +05:30
|
|
|
} else {
|
2007-10-07 17:14:02 +05:30
|
|
|
tty = cp;
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifndef USE_PAM
|
2007-10-07 17:14:59 +05:30
|
|
|
is_console = console (tty);
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Be more paranoid, like su from SimplePAMApps. --marekm
|
|
|
|
*/
|
|
|
|
if (!amroot) {
|
2007-10-07 17:14:59 +05:30
|
|
|
fprintf (stderr,
|
2007-10-07 17:16:07 +05:30
|
|
|
_("%s: must be run from a terminal\n"), Prog);
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
tty = "???";
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* The next argument must be either a user ID, or some flag to a
|
|
|
|
* subshell. Pretty sticky since you can't have an argument which
|
|
|
|
* doesn't start with a "-" unless you specify the new user name.
|
|
|
|
* Any remaining arguments will be passed to the user's login shell.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
if ((optind < argc) && ('-' != argv[optind][0])) {
|
2007-10-07 17:17:11 +05:30
|
|
|
STRFCPY (name, argv[optind++]); /* use this login id */
|
2008-06-11 03:37:51 +05:30
|
|
|
if ((optind < argc) && (strcmp (argv[optind], "--") == 0)) {
|
2007-10-07 17:17:11 +05:30
|
|
|
optind++;
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-06-11 03:37:51 +05:30
|
|
|
if ('\0' == name[0]) { /* use default user ID */
|
2007-10-07 17:14:02 +05:30
|
|
|
(void) strcpy (name, "root");
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
doshell = (argc == optind); /* any arguments remaining? */
|
|
|
|
if (NULL != command) {
|
|
|
|
doshell = false;
|
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* Get the user's real name. The current UID is used to determine
|
|
|
|
* who has executed su. That user ID must exist.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
pw = get_my_pwent ();
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL == pw) {
|
2008-08-30 23:57:07 +05:30
|
|
|
fprintf (stderr, _("%s: Cannot determine your user name.\n"),
|
|
|
|
Prog);
|
|
|
|
SYSLOG ((LOG_WARN, "Cannot determine the user name of the caller (UID %lu)",
|
|
|
|
(unsigned long) my_uid));
|
2007-10-07 17:14:59 +05:30
|
|
|
su_failure (tty);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
STRFCPY (oldname, pw->pw_name);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
#ifndef USE_PAM
|
|
|
|
#ifdef SU_ACCESS
|
|
|
|
/*
|
|
|
|
* Sort out the password of user calling su, in case needed later
|
|
|
|
* -- chris
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
spwd = getspnam (oldname); /* !USE_PAM, no need for xgetspnam */
|
|
|
|
if (NULL != spwd) {
|
2007-10-07 17:14:02 +05:30
|
|
|
pw->pw_passwd = spwd->sp_pwdp;
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
oldpass = xstrdup (pw->pw_passwd);
|
|
|
|
#endif /* SU_ACCESS */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
#else /* USE_PAM */
|
|
|
|
ret = pam_start ("su", name, &conv, &pamh);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:14:59 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_start: error %d", ret);
|
|
|
|
fprintf (stderr, _("%s: pam_start: error %d\n"),
|
|
|
|
Prog, ret));
|
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
ret = pam_set_item (pamh, PAM_TTY, (const void *) tty);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS == ret) {
|
2007-10-07 17:16:07 +05:30
|
|
|
ret = pam_set_item (pamh, PAM_RUSER, (const void *) oldname);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:14:59 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_set_item: %s",
|
|
|
|
pam_strerror (pamh, ret)));
|
2007-10-07 17:17:01 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret));
|
2007-10-07 17:14:59 +05:30
|
|
|
pam_end (pamh, ret);
|
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
top:
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* This is the common point for validating a user whose name is
|
|
|
|
* known. It will be reached either by normal processing, or if the
|
|
|
|
* user is to be logged into a subsystem root.
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2007-10-07 17:14:59 +05:30
|
|
|
* The password file entries for the user is gotten and the account
|
|
|
|
* validated.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
pw = xgetpwnam (name);
|
|
|
|
if (NULL == pw) {
|
2007-10-07 17:14:02 +05:30
|
|
|
(void) fprintf (stderr, _("Unknown id: %s\n"), name);
|
2007-10-07 17:14:59 +05:30
|
|
|
closelog ();
|
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
#ifndef USE_PAM
|
|
|
|
spwd = NULL;
|
2008-06-11 03:37:51 +05:30
|
|
|
if (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
|
|
|
|
spwd = getspnam (name); /* !USE_PAM, no need for xgetspnam */
|
|
|
|
if (NULL != spwd) {
|
|
|
|
pw->pw_passwd = spwd->sp_pwdp;
|
|
|
|
}
|
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
pwent = *pw;
|
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/* If su is not called by root, and the target user has a restricted
|
|
|
|
* shell, the environment must be changed.
|
|
|
|
*/
|
|
|
|
change_environment |= (restricted_shell (pwent.pw_shell) && !amroot);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If a new login is being set up, the old environment will be
|
|
|
|
* ignored and a new one created later on.
|
|
|
|
* (note: in the case of a subsystem, the shell will be restricted,
|
|
|
|
* and this won't be executed on the first pass)
|
|
|
|
*/
|
|
|
|
if (fakelogin && change_environment) {
|
|
|
|
/*
|
|
|
|
* The terminal type will be left alone if it is present in
|
|
|
|
* the environment already.
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
cp = getenv ("TERM");
|
|
|
|
if (NULL != cp) {
|
2007-10-07 17:17:11 +05:30
|
|
|
addenv ("TERM", cp);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
#ifndef USE_PAM
|
2008-06-11 03:37:51 +05:30
|
|
|
cp = getdef_str ("ENV_TZ");
|
|
|
|
if (NULL != cp) {
|
|
|
|
addenv (('/' == *cp) ? tz (cp) : cp, NULL);
|
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* The clock frequency will be reset to the login value if required
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
cp = getdef_str ("ENV_HZ");
|
|
|
|
if (NULL != cp) {
|
2007-10-07 17:17:11 +05:30
|
|
|
addenv (cp, NULL); /* set the default $HZ, if one */
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* Also leave DISPLAY and XAUTHORITY if present, else
|
|
|
|
* pam_xauth will not work.
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
cp = getenv ("DISPLAY");
|
|
|
|
if (NULL != cp) {
|
2007-10-07 17:17:11 +05:30
|
|
|
addenv ("DISPLAY", cp);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
|
|
|
cp = getenv ("XAUTHORITY");
|
|
|
|
if (NULL != cp) {
|
2007-10-07 17:17:11 +05:30
|
|
|
addenv ("XAUTHORITY", cp);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
#endif /* !USE_PAM */
|
|
|
|
} else {
|
2008-06-11 03:37:51 +05:30
|
|
|
while (NULL != *envp) {
|
|
|
|
addenv (*envp, NULL);
|
|
|
|
envp++;
|
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifndef USE_PAM
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* BSD systems only allow "wheel" to SU to root. USG systems don't,
|
|
|
|
* so we make this a configurable option.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
/* The original Shadow 3.3.2 did this differently. Do it like BSD:
|
|
|
|
*
|
2007-10-07 17:16:25 +05:30
|
|
|
* - check for UID 0 instead of name "root" - there are systems with
|
2007-10-07 17:14:59 +05:30
|
|
|
* several root accounts under different names,
|
|
|
|
*
|
|
|
|
* - check the contents of /etc/group instead of the current group
|
|
|
|
* set (you must be listed as a member, GID 0 is not sufficient).
|
|
|
|
*
|
|
|
|
* In addition to this traditional feature, we now have complete su
|
|
|
|
* access control (allow, deny, no password, own password). Thanks
|
|
|
|
* to Chris Evans <lady0110@sable.ox.ac.uk>.
|
|
|
|
*/
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
if (!amroot) {
|
2008-06-11 03:37:51 +05:30
|
|
|
if ( (0 == pwent.pw_uid)
|
|
|
|
&& getdef_bool ("SU_WHEEL_ONLY")
|
2007-10-07 17:14:59 +05:30
|
|
|
&& !iswheel (oldname)) {
|
|
|
|
fprintf (stderr,
|
2007-10-07 17:16:07 +05:30
|
|
|
_("You are not authorized to su %s\n"), name);
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
#ifdef SU_ACCESS
|
2007-10-07 17:14:59 +05:30
|
|
|
switch (check_su_auth (oldname, name)) {
|
|
|
|
case 0: /* normal su, require target user's password */
|
2007-10-07 17:14:02 +05:30
|
|
|
break;
|
2007-10-07 17:14:59 +05:30
|
|
|
case 1: /* require no password */
|
|
|
|
pwent.pw_passwd = ""; /* XXX warning: const */
|
2007-10-07 17:14:02 +05:30
|
|
|
break;
|
2007-10-07 17:14:59 +05:30
|
|
|
case 2: /* require own password */
|
2007-10-07 17:17:11 +05:30
|
|
|
puts (_("(Enter your own password)"));
|
2007-10-07 17:14:02 +05:30
|
|
|
pwent.pw_passwd = oldpass;
|
|
|
|
break;
|
2007-10-07 17:14:59 +05:30
|
|
|
default: /* access denied (-1) or unexpected value */
|
|
|
|
fprintf (stderr,
|
2007-10-07 17:16:07 +05:30
|
|
|
_("You are not authorized to su %s\n"), name);
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* SU_ACCESS */
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/* If the user do not want to change the environment,
|
|
|
|
* use the current SHELL.
|
|
|
|
* (unless another shell is required by the command line)
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
if ((NULL == shellstr) && !change_environment) {
|
2007-10-07 17:17:11 +05:30
|
|
|
shellstr = getenv ("SHELL");
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
/* For users with non null UID, if this user has a restricted
|
|
|
|
* shell, the shell must be the one specified in /etc/passwd
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
if ( (NULL != shellstr)
|
|
|
|
&& !amroot
|
|
|
|
&& restricted_shell (pwent.pw_shell)) {
|
2007-10-07 17:17:11 +05:30
|
|
|
shellstr = NULL;
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
/* If the shell is not set at this time, use the shell specified
|
|
|
|
* in /etc/passwd.
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL == shellstr) {
|
2007-10-07 17:17:11 +05:30
|
|
|
shellstr = (char *) strdup (pwent.pw_shell);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:17:11 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* Set the default shell.
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
if ((NULL == shellstr) || ('\0' == shellstr[0])) {
|
2007-10-07 17:17:11 +05:30
|
|
|
shellstr = "/bin/sh";
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-14 02:32:07 +05:30
|
|
|
(void) signal (SIGINT, SIG_IGN);
|
|
|
|
(void) signal (SIGQUIT, SIG_IGN);
|
2007-10-07 17:14:02 +05:30
|
|
|
#ifdef USE_PAM
|
2007-10-07 17:14:59 +05:30
|
|
|
ret = pam_authenticate (pamh, 0);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:14:59 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_authenticate: %s",
|
|
|
|
pam_strerror (pamh, ret)));
|
2007-10-07 17:17:01 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret));
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, ret);
|
2007-10-07 17:14:59 +05:30
|
|
|
su_failure (tty);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
ret = pam_acct_mgmt (pamh, 0);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:14:02 +05:30
|
|
|
if (amroot) {
|
2007-10-07 17:14:59 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n(Ignored)\n"), Prog,
|
|
|
|
pam_strerror (pamh, ret));
|
2008-06-11 03:37:51 +05:30
|
|
|
} else if (PAM_NEW_AUTHTOK_REQD == ret) {
|
2007-10-07 17:17:11 +05:30
|
|
|
ret = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:17:11 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_chauthtok: %s",
|
|
|
|
pam_strerror (pamh, ret)));
|
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog,
|
|
|
|
pam_strerror (pamh, ret));
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, ret);
|
2007-10-07 17:17:11 +05:30
|
|
|
su_failure (tty);
|
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
} else {
|
2007-10-07 17:14:59 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_acct_mgmt: %s",
|
|
|
|
pam_strerror (pamh, ret)));
|
2007-10-07 17:17:01 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog,
|
2007-10-07 17:14:59 +05:30
|
|
|
pam_strerror (pamh, ret));
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, ret);
|
2007-10-07 17:14:59 +05:30
|
|
|
su_failure (tty);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#else /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
/*
|
|
|
|
* Set up a signal handler in case the user types QUIT.
|
|
|
|
*/
|
|
|
|
die (0);
|
2008-06-14 02:32:26 +05:30
|
|
|
oldsig = signal (SIGQUIT, die);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* See if the system defined authentication method is being used.
|
|
|
|
* The first character of an administrator defined method is an '@'
|
|
|
|
* character.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
if (!amroot && pw_auth (pwent.pw_passwd, name, PW_SU, (char *) 0)) {
|
|
|
|
SYSLOG ((pwent.pw_uid ? LOG_NOTICE : LOG_WARN,
|
|
|
|
"Authentication failed for %s", name));
|
|
|
|
su_failure (tty);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-06-14 02:32:07 +05:30
|
|
|
(void) signal (SIGQUIT, oldsig);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* Check to see if the account is expired. root gets to ignore any
|
|
|
|
* expired accounts, but normal users can't become a user with an
|
|
|
|
* expired password.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
if (!amroot) {
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL == spwd) {
|
2007-10-07 17:14:59 +05:30
|
|
|
spwd = pwd_to_spwd (&pwent);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
if (expire (&pwent, spwd)) {
|
* lib/prototypes.h, configure.in, libmisc/Makefile.am,
libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetpwuid.c,
libmisc/xgetgrnam.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c:
Added functions xgetpwnam(), xgetpwuid(), xgetgrnam(),
xgetgrgid(), and xgetspnam(). They allocate memory for the
returned structure and are more robust to successive calls. They
are implemented with the libc's getxxyyy_r() functions if
available.
* libmisc/limits.c, libmisc/entry.c, libmisc/chowntty.c,
libmisc/addgrps.c, libmisc/myname.c, libmisc/rlogin.c,
libmisc/pwdcheck.c, src/newgrp.c, src/login_nopam.c,
src/userdel.c, src/lastlog.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/chfn.c, src/groupmems.c,
src/usermod.c, src/expiry.c, src/groupdel.c, src/chgpasswd.c,
src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/suauth.c,
src/faillog.c, src/groups.c, src/chsh.c, src/id.c: Review all the
usage of one of the getpwnam(), getpwuid(), getgrnam(),
getgrgid(), and getspnam() functions. It was noticed on
http://bugs.debian.org/341230 that chfn and chsh use a passwd
structure after calling a pam function, which result in using
information from the passwd structure requested by pam, not the
original one. It is much easier to use the new xget... functions
to avoid these issues. I've checked which call to the original
get... functions could be left (reducing the scope of the
structure if possible), and I've left comments to ease future
reviews (e.g. /* local, no need for xgetpwnam */).
Note: the getpwent/getgrent calls should probably be checked also.
* src/groupdel.c, src/expiry.c: Fix typos in comments.
* src/groupmod.c: Re-indent.
* libmisc/Makefile.am, lib/groupmem.c, lib/groupio.c, lib/pwmem.c,
lib/pwio.c, lib/shadowmem.c, lib/shadowio.c: Move the __<xx>_dup
functions (used by the xget... functions) from the <xx>io.c files
to the new <xx>mem.c files. This avoid linking some utils against
the SELinux library.
2007-11-19 04:45:26 +05:30
|
|
|
/* !USE_PAM, no need for xgetpwnam */
|
2007-10-07 17:17:11 +05:30
|
|
|
struct passwd *pwd = getpwnam (name);
|
|
|
|
|
* lib/prototypes.h, configure.in, libmisc/Makefile.am,
libmisc/xgetXXbyYY.c, libmisc/xgetpwnam.c, libmisc/xgetpwuid.c,
libmisc/xgetgrnam.c, libmisc/xgetgrgid.c, libmisc/xgetspnam.c:
Added functions xgetpwnam(), xgetpwuid(), xgetgrnam(),
xgetgrgid(), and xgetspnam(). They allocate memory for the
returned structure and are more robust to successive calls. They
are implemented with the libc's getxxyyy_r() functions if
available.
* libmisc/limits.c, libmisc/entry.c, libmisc/chowntty.c,
libmisc/addgrps.c, libmisc/myname.c, libmisc/rlogin.c,
libmisc/pwdcheck.c, src/newgrp.c, src/login_nopam.c,
src/userdel.c, src/lastlog.c, src/grpck.c, src/gpasswd.c,
src/newusers.c, src/chpasswd.c, src/chfn.c, src/groupmems.c,
src/usermod.c, src/expiry.c, src/groupdel.c, src/chgpasswd.c,
src/su.c, src/useradd.c, src/groupmod.c, src/passwd.c, src/pwck.c,
src/groupadd.c, src/chage.c, src/login.c, src/suauth.c,
src/faillog.c, src/groups.c, src/chsh.c, src/id.c: Review all the
usage of one of the getpwnam(), getpwuid(), getgrnam(),
getgrgid(), and getspnam() functions. It was noticed on
http://bugs.debian.org/341230 that chfn and chsh use a passwd
structure after calling a pam function, which result in using
information from the passwd structure requested by pam, not the
original one. It is much easier to use the new xget... functions
to avoid these issues. I've checked which call to the original
get... functions could be left (reducing the scope of the
structure if possible), and I've left comments to ease future
reviews (e.g. /* local, no need for xgetpwnam */).
Note: the getpwent/getgrent calls should probably be checked also.
* src/groupdel.c, src/expiry.c: Fix typos in comments.
* src/groupmod.c: Re-indent.
* libmisc/Makefile.am, lib/groupmem.c, lib/groupio.c, lib/pwmem.c,
lib/pwio.c, lib/shadowmem.c, lib/shadowio.c: Move the __<xx>_dup
functions (used by the xget... functions) from the <xx>io.c files
to the new <xx>mem.c files. This avoid linking some utils against
the SELinux library.
2007-11-19 04:45:26 +05:30
|
|
|
/* !USE_PAM, no need for xgetspnam */
|
2007-10-07 17:17:11 +05:30
|
|
|
spwd = getspnam (name);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL != pwd) {
|
2007-10-07 17:17:11 +05:30
|
|
|
pwent = *pwd;
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* Check to see if the account permits "su". root gets to ignore any
|
|
|
|
* restricted accounts, but normal users can't become a user if
|
|
|
|
* there is a "SU" entry in the /etc/porttime file denying access to
|
|
|
|
* the account.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
if (!amroot) {
|
|
|
|
if (!isttytime (pwent.pw_name, "SU", time ((time_t *) 0))) {
|
2008-06-11 03:37:51 +05:30
|
|
|
SYSLOG (((0 != pwent.pw_uid) ? LOG_WARN : LOG_CRIT,
|
2007-10-07 17:14:59 +05:30
|
|
|
"SU by %s to restricted account %s",
|
|
|
|
oldname, name));
|
|
|
|
su_failure (tty);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-14 02:32:07 +05:30
|
|
|
(void) signal (SIGINT, SIG_DFL);
|
|
|
|
(void) signal (SIGQUIT, SIG_DFL);
|
2007-10-07 17:15:23 +05:30
|
|
|
|
2007-10-07 17:16:52 +05:30
|
|
|
cp = getdef_str ((pwent.pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL == cp) {
|
2007-10-07 17:14:59 +05:30
|
|
|
addenv ("PATH=/bin:/usr/bin", NULL);
|
2008-06-11 03:37:51 +05:30
|
|
|
} else if (strchr (cp, '=') != NULL) {
|
2007-10-07 17:14:59 +05:30
|
|
|
addenv (cp, NULL);
|
2007-10-07 17:14:14 +05:30
|
|
|
} else {
|
2007-10-07 17:14:59 +05:30
|
|
|
addenv ("PATH", cp);
|
2007-10-07 17:14:14 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
if (getenv ("IFS") != NULL) { /* don't export user IFS ... */
|
2007-10-07 17:14:59 +05:30
|
|
|
addenv ("IFS= \t\n", NULL); /* ... instead, set a safe IFS */
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
/*
|
|
|
|
* Even if --shell is specified, the subsystem login test is based on
|
|
|
|
* the shell specified in /etc/passwd (not the one specified with
|
|
|
|
* --shell, which will be the one executed in the chroot later).
|
|
|
|
*/
|
2008-06-11 03:37:51 +05:30
|
|
|
if ('*' == pwent.pw_shell[0]) { /* subsystem root required */
|
2007-10-07 17:14:51 +05:30
|
|
|
pwent.pw_shell++; /* skip the '*' */
|
2007-10-07 17:14:02 +05:30
|
|
|
subsystem (&pwent); /* figure out what to execute */
|
|
|
|
endpwent ();
|
|
|
|
endspent ();
|
|
|
|
goto top;
|
|
|
|
}
|
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
sulog (tty, true, oldname, name); /* save SU information */
|
2007-10-07 17:14:02 +05:30
|
|
|
endpwent ();
|
|
|
|
endspent ();
|
|
|
|
#ifdef USE_SYSLOG
|
2008-06-11 03:37:51 +05:30
|
|
|
if (getdef_bool ("SYSLOG_SU_ENAB")) {
|
2007-10-07 17:16:25 +05:30
|
|
|
SYSLOG ((LOG_INFO, "+ %s %s:%s", tty,
|
2008-06-11 03:37:51 +05:30
|
|
|
('\0' != oldname[0]) ? oldname : "???",
|
|
|
|
('\0' != name[0]) ? name : "???"));
|
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_PAM
|
|
|
|
/* set primary group id and supplementary groups */
|
2008-06-11 03:37:51 +05:30
|
|
|
if (setup_groups (&pwent) != 0) {
|
2007-10-07 17:14:59 +05:30
|
|
|
pam_end (pamh, PAM_ABORT);
|
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
/*
|
|
|
|
* pam_setcred() may do things like resource limits, console groups,
|
|
|
|
* and much more, depending on the configured modules
|
|
|
|
*/
|
|
|
|
ret = pam_setcred (pamh, PAM_ESTABLISH_CRED);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:16:07 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_setcred: %s", pam_strerror (pamh, ret)));
|
2007-10-07 17:17:01 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret));
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, ret);
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
|
|
|
|
2007-10-07 17:15:40 +05:30
|
|
|
ret = pam_open_session (pamh, 0);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (PAM_SUCCESS != ret) {
|
2007-10-07 17:15:40 +05:30
|
|
|
SYSLOG ((LOG_ERR, "pam_open_session: %s",
|
|
|
|
pam_strerror (pamh, ret)));
|
2007-10-07 17:17:01 +05:30
|
|
|
fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret));
|
2007-10-07 17:17:33 +05:30
|
|
|
pam_setcred (pamh, PAM_DELETE_CRED);
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, ret);
|
2007-10-07 17:15:40 +05:30
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
if (change_environment) {
|
|
|
|
/* we need to setup the environment *after* pam_open_session(),
|
|
|
|
* else the UID is changed before stuff like pam_xauth could
|
|
|
|
* run, and we cannot access /etc/shadow and co
|
|
|
|
*/
|
|
|
|
environ = newenvp; /* make new environment active */
|
|
|
|
|
|
|
|
/* update environment with all pam set variables */
|
|
|
|
envcp = pam_getenvlist (pamh);
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL != envcp) {
|
|
|
|
while (NULL != *envcp) {
|
2007-10-07 17:17:11 +05:30
|
|
|
addenv (*envcp, NULL);
|
|
|
|
envcp++;
|
|
|
|
}
|
2007-10-07 17:15:40 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
/* become the new user */
|
2008-06-11 03:37:51 +05:30
|
|
|
if (change_uid (&pwent) != 0) {
|
2007-10-07 17:17:33 +05:30
|
|
|
pam_close_session (pamh, 0);
|
2007-10-07 17:14:59 +05:30
|
|
|
pam_setcred (pamh, PAM_DELETE_CRED);
|
2008-06-11 03:37:51 +05:30
|
|
|
(void) pam_end (pamh, PAM_ABORT);
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#else /* !USE_PAM */
|
2007-10-07 17:17:57 +05:30
|
|
|
environ = newenvp; /* make new environment active */
|
2007-10-13 04:06:26 +05:30
|
|
|
|
|
|
|
/* no limits if su from root (unless su must fake login's behavior) */
|
2008-06-11 03:37:51 +05:30
|
|
|
if (!amroot || fakelogin) {
|
2007-10-07 17:14:59 +05:30
|
|
|
setup_limits (&pwent);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-11 03:37:51 +05:30
|
|
|
if (setup_uid_gid (&pwent, is_console) != 0) {
|
2007-10-07 17:14:59 +05:30
|
|
|
exit (1);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:59 +05:30
|
|
|
#endif /* !USE_PAM */
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:17:11 +05:30
|
|
|
if (change_environment) {
|
|
|
|
if (fakelogin) {
|
|
|
|
pwent.pw_shell = shellstr;
|
|
|
|
setup_env (&pwent);
|
|
|
|
} else {
|
|
|
|
addenv ("HOME", pwent.pw_dir);
|
|
|
|
addenv ("USER", pwent.pw_name);
|
|
|
|
addenv ("LOGNAME", pwent.pw_name);
|
|
|
|
addenv ("SHELL", shellstr);
|
|
|
|
}
|
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a workaround for Linux libc bug/feature (?) - the
|
2007-10-07 17:14:59 +05:30
|
|
|
* /dev/log file descriptor is open without the close-on-exec flag
|
|
|
|
* and used to be passed to the new shell. There is "fcntl(LogFile,
|
|
|
|
* F_SETFD, 1)" in libc/misc/syslog.c, but it is commented out (at
|
|
|
|
* least in 5.4.33). Why? --marekm
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
2007-10-07 17:14:59 +05:30
|
|
|
closelog ();
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
2007-10-07 17:14:59 +05:30
|
|
|
* See if the user has extra arguments on the command line. In that
|
|
|
|
* case they will be provided to the new user's shell as arguments.
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
|
|
|
if (fakelogin) {
|
|
|
|
char *arg0;
|
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
cp = getdef_str ("SU_NAME");
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL == cp) {
|
2007-10-07 17:17:11 +05:30
|
|
|
cp = Basename (shellstr);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
arg0 = xmalloc (strlen (cp) + 2);
|
2007-10-07 17:14:02 +05:30
|
|
|
arg0[0] = '-';
|
2007-10-07 17:14:59 +05:30
|
|
|
strcpy (arg0 + 1, cp);
|
2007-10-07 17:14:02 +05:30
|
|
|
cp = arg0;
|
2008-06-11 03:37:51 +05:30
|
|
|
} else {
|
2007-10-07 17:17:11 +05:30
|
|
|
cp = Basename (shellstr);
|
2008-06-11 03:37:51 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2007-10-07 17:14:59 +05:30
|
|
|
if (!doshell) {
|
2007-10-07 17:17:11 +05:30
|
|
|
/* Position argv to the remaining arguments */
|
|
|
|
argv += optind;
|
2008-06-11 03:37:51 +05:30
|
|
|
if (NULL != command) {
|
2007-10-07 17:17:22 +05:30
|
|
|
argv -= 2;
|
|
|
|
argv[0] = "-c";
|
|
|
|
argv[1] = command;
|
|
|
|
}
|
2007-10-07 17:14:14 +05:30
|
|
|
/*
|
2007-10-07 17:17:11 +05:30
|
|
|
* Use the shell and create an argv
|
2007-10-07 17:14:59 +05:30
|
|
|
* with the rest of the command line included.
|
2007-10-07 17:14:14 +05:30
|
|
|
*/
|
2007-10-07 17:17:11 +05:30
|
|
|
argv[-1] = shellstr;
|
2007-10-07 17:15:40 +05:30
|
|
|
#ifndef USE_PAM
|
2007-10-07 17:17:22 +05:30
|
|
|
(void) execve (shellstr, &argv[-1], environ);
|
|
|
|
err = errno;
|
2008-01-25 02:12:12 +05:30
|
|
|
(void) fputs (_("No shell\n"), stderr);
|
2007-10-07 17:17:11 +05:30
|
|
|
SYSLOG ((LOG_WARN, "Cannot execute %s", shellstr));
|
2007-10-07 17:14:59 +05:30
|
|
|
closelog ();
|
2008-06-11 03:37:51 +05:30
|
|
|
exit ((ENOENT == err) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
2007-10-07 17:17:22 +05:30
|
|
|
#else
|
2008-06-11 03:37:51 +05:30
|
|
|
run_shell (shellstr, &argv[-1], false, environ); /* no return */
|
2007-10-07 17:17:22 +05:30
|
|
|
#endif
|
2007-10-07 17:14:14 +05:30
|
|
|
}
|
2007-10-07 17:15:40 +05:30
|
|
|
#ifndef USE_PAM
|
2007-10-07 17:17:22 +05:30
|
|
|
err = shell (shellstr, cp, environ);
|
2008-06-11 03:37:51 +05:30
|
|
|
exit ((ENOENT == err) ? E_CMD_NOTFOUND : E_CMD_NOEXEC);
|
2007-10-07 17:15:40 +05:30
|
|
|
#else
|
2008-06-11 03:37:51 +05:30
|
|
|
run_shell (shellstr, &cp, true, environ);
|
2007-10-07 17:15:40 +05:30
|
|
|
#endif
|
2007-10-07 17:15:23 +05:30
|
|
|
/* NOT REACHED */
|
|
|
|
exit (1);
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-06-11 03:37:51 +05:30
|
|
|
|