summaryrefslogtreecommitdiffstats
path: root/usr.bin/su/su.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not chdir(2) until after setuid(2), otherwise "su - username" would failluoqi2006-09-291-6/+4
| | | | | | when root doesn't have the permission to enter target user's home directory. If set, PAM environment variable HOME will be used in chdir(2) instead of pwd->pw_dir, this allows pam_chroot module to continue to function.
* Integrate audit_submit(3) bits into su. This means that records forcsjp2006-09-011-6/+68
| | | | | | | | | | | | successful and failed su attempts will be recorded using the AUE_su event type (login or lo class) if auditing is present in the system. Currently, the records will have a header, subject, text (with the actual diagnostics), a return and trailer token. See audit_submit(3) for more information. Reviewed by: rwatson Obtained from: TrustedBSD Project
* Fix the other su bug reintroduced two commits ago, namelybrian2006-01-031-1/+14
| | | | | | | | | | | | | $ su % kill -STOP $$ where su is executing (t)csh. csh's job handling is a little more special than that of (a)sh, bash and even zsh and blows up a little more spectacularly. This modification restores the original mucking about with the tty pgrp, but is careful to only do it when su (or su's child) is the foreground process. While I'm here, fix a STDERR_FILENO spelling as suggested by bde.
* Handle the case (that I just broke) where the following hangs:brian2006-01-021-1/+3
| | | | | | | $ su # kill -STOP $$ Pointed out by: David Xu <davidxu@freebsd.org>
* Remove broken code that mucks about with tcsetpgrp() -- even ifbrian2006-01-021-7/+0
| | | | | | | | | | | | | | | | | | | | su isn't the foreground process. Hopefully this won't break PAM, but I couldn't find any useful information about ache's theory that it will. Specifically, this change fixes the following: # sh # echo $$ # su - root -c id & # echo $$ The PID output changes as su seems to be kill -STOP'ing itself and catching the parent shell in the process. This is especially bad if you add a ``su - user -c command &'' to an rc script! Sponsored by: Sophos/Activestate Not objected to by: des
* If su(1) is run without an effective uid of 0, generate an error torwatson2005-01-171-3/+33
| | | | | | | | | the user indicating that su is not running setuid, which may help suggest to the user that it should be setuid, or should not be running from a file system mounted nosuid. Suggsted by: Ivan Voras <ivoras at fer dot hr> MFC after: 2 weeks
* Oops. My last commit included a bug that would make "su -m" alwaysmarkm2004-06-151-2/+0
| | | | use /bin/sh. Fix this.
* Paranoia, WARNS fixes and lint.markm2004-06-131-19/+19
|
* Add FBSDID. Do not dot terminate errx(3) string.charnier2004-04-041-5/+6
|
* When root tries to su to a non-existent user, pam_authenticate() willdes2004-01-061-4/+4
| | | | | | | | | normally succeed (because root can su to anyone), but pam_acct_mgmt() will most likely fail, causing su to log a confusing "pam_acct_mgmt: error in service module" message. To avoid this, call getpwnam() before pam_acct_mgmt(). Sponsored by: registrar.no
* Be sure to restore foreground group to parent su before parent sudavidxu2003-11-041-1/+2
| | | | | exits, otherwise shell will be confused and does not set foreground group correctly for next su command. This sounds like a bug in sh.
* It seems when su executes in a shell scripts, there is a timing race,davidxu2003-11-031-0/+2
| | | | | | | | sometimes, su will receive a SIGTTOU when parent su tries to set child su's process group as foreground group, and su will be stopped unexpectly, ignoring SIGTTOU fixes the problem. Noticed by: fjoe
* Fix broken su -m behaviour :cognet2003-10-191-4/+2
| | | | | | | chshell must return 0 if the shell is not a standard shell, or else it is possible to use an account without a valid shell. Reviewed by: des
* PAM-related improvements:des2003-04-081-37/+59
| | | | | | | | - if operating "as them" (su -l), use pam_{open,close}_session() - allow PAM to override $HOME (pam_chroot needs this) - chdir early, because later on we may be chrooted and chdir will fail Also use pid_t instead of int where applicable.
* Put child process in a different process group, ensure that the broadcastdavidxu2003-03-271-6/+22
| | | | | | | | signal never affects su directly, some shells changes its pgrp at running or suspended time, so a broadcast SIGTSTP from child will mess up su's job control. Discussed with: bde
* Fix style bugs in the previous commit (which weren't in bde's patch)des2003-03-111-2/+0
|
* Reset SIGTSTP handler to default both for parent and child process.davidxu2003-03-111-3/+4
| | | | Submitted by: bde
* Fix long standing job control bug. SIGTSTP shouldn't be ignored.davidxu2003-03-111-1/+0
| | | | | | Special instructions tested: suspend stop $$
* Pass the correct, verified username to PAM instead of getlogin().des2003-02-061-1/+1
|
* Add a new '-s' option to su(1): if the flag is present, attempt torwatson2002-10-231-4/+14
| | | | | | | | | | also set the user's MAC label as part of the user credential setup by setting setusercontext(3)'s SETMAC flag. By default, change only traditional process properties. Approved by: re Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* When a user gets refused because the password is wrong, use themarkm2002-10-181-0/+4
| | | | | | | older "BAD SU" syslog message that folks prefer. There is quite a bit more tweaking that can be done with other similar messages. Asked for by: tjr
* Style: use sa_handler instead of __sigaction_u.__sa_handler.tjr2002-10-171-1/+1
|
* Remove an unused variable.phk2002-10-141-2/+0
|
* Fix typing error in prev. commitache2002-08-121-1/+1
|
* Fix style bug in prev. commitache2002-08-121-2/+1
|
* Fix su job control (recently introduced for PAM cleanup purposes) to notache2002-08-121-3/+6
| | | | | | | kill login shell on either "suspend/fg" or "stop $$/fg" for tcsh. Since this bug occurse on -stable too, it is not kernel threads bug. Submitted by: David Xu <bsddiy@yahoo.com>
* Back out workaround of fixing "suspend/fg" by price of breaking "stop $$/fg".ache2002-08-071-1/+3
| | | | | This is real kernel bug (threads) and don't attempt to mask it by workarounds to increase chances to fix it in the kernel.
* Remove tcsetpgrp() stuff across suspend/continue because it cause upper levelache2002-07-091-3/+1
| | | | | tcsh killed on resume (fg). It is because tcsh is interactive itself and do its own things with terminal group.
* This is Alexander Kabaev's patch to solve the signal problem with sudillon2002-06-261-0/+11
| | | | | | | (see 'zsh exits upon ^C' thread). This may be temporary be he's been running it for a year without incident so we should be golden with it. Approved by: des
* Backout 1.51 on DES's request.dillon2002-06-261-2/+0
| | | | Approved by: des
* Make our child the leader of its own process group to avoid receivingdes2002-05-291-0/+2
| | | | signals in its stead. This fixes the dread "zsh exits upon ^C" bug.
* Drive-by whitespace cleanup & add NAI copyrightdes2002-05-281-2/+9
|
* Belatedly OpenPAMify. I forgot this patch in last night's megacommit.des2002-03-061-2/+2
| | | | Sponsored by: DARPA, NAI Labs
* Don't set PAM_RHOST, this is a local login.des2002-01-241-5/+1
| | | | Sponsored by: DARPA, NAI Labs
* Reinstate complete (and now correctly functioning) WARNS=2.markm2001-09-121-6/+10
|
* Back out (with prejudice) the last WARNS=2 fix. I cannot understandmarkm2001-09-071-10/+6
| | | | its failure mode, and will revisit it later.
* WARNS=2 fixes.markm2001-09-041-6/+10
| | | | | | | | The remaining problem of converting highly incompatible pointer types is done by "laundering" the value through a union. This solves the problem (in my own mind) of how a "const char *" _ever_ actually gets a value in a WARNS=2 world.
* Very minor stylistic nit.markm2001-08-201-2/+1
| | | | Discussed with: ru
* Substitute ARGSTR in-place.ru2001-08-151-4/+3
| | | | Forgot trailing newline in usage().
* Fixed the usage() string.ru2001-08-151-1/+3
| | | | | | | | This also reverts change in rev. 1.36 to the documented style of writing usage(). PR: bin/29730 Submitted by: Joseph Mallett <jmallett@xMach.org>
* Set the RUSER for PAM so that (eg) kerberos can set up tickets properly.markm2001-08-111-0/+2
|
* WARNS=2 type cleanup.markm2001-08-111-5/+5
| | | | | | | WARNS=2 cannot be enable because of an unresolvable conflict in arg 2 of execv(). Document this in the Makefile. Reviewed by: bde (su.c only)
* Deconvolute the authentication mess, and hand total responsiblitymarkm2001-05-261-303/+217
| | | | | | | | | | for authentication to PAM. This meens that WHEELSU-type logic can now be effected in the pam.conf "su" configuration stack. While here, clean up the mess that the code had assumed over years of hacking by folks using different styles. ANSIfy. There is more policy in here that can be handed over to PAM. This will be revisited.
* Tell the user what group they must be in to su to root.obrien2001-05-101-1/+4
| | | | Submitted by: Seth Kingsley <sethk@osd.bsdi.com>
* Dike out the Kerberos(IV) support on the grounds that better kerberosmarkm2001-04-281-176/+0
| | | | support can be already obtained via PAM.
* Add full PAM support for account management and sessions.markm2001-03-271-61/+211
| | | | | | | The PAM_FAIL_CHECK and PAM_END macros in su.c came from the util-linux package's PAM patches to the BSD login.c Submitted by: "David J. MacKenzie" <djm@web.us.uu.net>
* o Make comment match reality, synch code with comment.rwatson2000-11-301-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | o In practice: the comment indicates that all but umask and environmental variables of the users login class are applied when su occurs, unless -m is used to specify a class. This was incorrect; in practice, the uid, gids, resources, and priority were set, and then resources and priority were selectively removed. This meant that some aspects of the user context were not set, including handling of login events (wtmp, utmp), as well as the path specified in login.conf. o I changed it so that the behavior is the same, but instead, LOGIN_SETALL is used, and appropriate flags are removed, including the LOGIN_SETLOGIN and LOGIN_SETPATH entries that were implicitly not present before. I also updated the comment to reflect reality, selecting reality as the "correct" behavior. o This has the practical benefit that as new LOGIN_SET* flags are introduced, they are supported by su unless specifically disabled. For example, of a LOGIN_SETLABEL flag is introduced to support MAC labels determined by the user's login class, then su no longer has to be modified. o It might be desirable to have su use LOGIN_SETPATH depending on its command line parameters, as it might or might not be considered part of the "environment". Obtained from: TrustedBSD Project
* Use libcrypto in place of libdes.markm2000-02-241-1/+1
|
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Axe LOGIN_CAP_AUTH.sheldonh1999-08-131-52/+1
| | | | | | PR: 10115 Reported by: Gene Skonicki <gene@cif.rochester.edu> Requested by: jdp
OpenPOWER on IntegriCloud