Commit Graph

171 Commits

Author SHA1 Message Date
kre 221399499c After a ':' (as in login:group or just :group) insist that there
actually be a group name (of some form, don't care what) present.
2023-03-24 16:58:24 +00:00
kre 5e706d5f81 PR misc/57287 from Nan Xiao
While it has always been assumed that everyone "just knew" that a simple
"su' meant "su root" perhaps the man page really should make that explicit.

Do that (using slightly different wording than suggested in the PR).
2023-03-24 14:34:17 +00:00
rillig 1d6b489c6e usr.bin: remove unnecessary CONSTCOND, lint no longer needs it
Since 2021-01-31, lint no longer requires a CONSTCOND comment in a
do-while-0 statement since this is a common code pattern, especially in
statement-like macros.
2021-11-27 22:16:41 +00:00
nia 566b8631da su(1): use reallocarr instead of malloc(x * y) 2021-10-30 11:25:30 +00:00
nia 9c383c5da2 su: Use consttime_memequal instead of strcmp.
This only affects the non-PAM case.
2021-10-17 10:33:57 +00:00
rillig 133e932a29 usr.bin: remove unnecessary lint comment CONSTCOND
Since 2021-01-31, lint no longer warns about 'do ... while (0)'.

No functional change.
2021-09-10 21:52:17 +00:00
wiz f592f951d4 Remove superfluous Ns. 2019-09-01 19:12:16 +00:00
sevan a4ee5060f0 su was in v1
https://www.bell-labs.com/usr/dmr/www/man13.pdf
2019-09-01 18:37:44 +00:00
htodd dab912008b Fix typo in comment. 2018-02-26 00:05:05 +00:00
mrg 2e19323388 add LIBKRB5_LDADD/LIBKRB5_DPADD and their static counterparts
to bsd.prog.mk.  use them instead of hard coding various lists
of libraries for krb5.

this fixes static builds.
2018-02-25 00:16:48 +00:00
abhinav ae7adf81e7 Correct the man page reference 2017-05-18 16:33:57 +00:00
shm 7a0fcb9b1d Do not use pamh after pam_end. It's cosmetic change since pam_strerror
ignores that parameter.
2015-08-09 09:39:21 +00:00
christos ff53269704 fix some error handling. 2015-06-16 22:54:10 +00:00
wiz 2a65137f55 Sort sections. From Henning Petersen in PR 49222. 2014-09-19 16:02:58 +00:00
dholland c49e034e83 Fix gcc48 build. No obvious reason why nobody else has hit this... 2014-03-16 01:07:46 +00:00
mlelstv 9adb142f7d Change to home directory only after setting the full user context
to avoid issues with NFS or other user-mapped mounts that don't
give root the privilege to chdir there.
2013-06-29 05:08:35 +00:00
christos f9bc1aff9f - don't re-use the va list twice, leads to coredumps.
- introduce and use a "safe" version of pam_strerror(3) that does not return
   NULL
2013-06-20 20:54:02 +00:00
pgoyette 3a4bfc9ee9 Note that 'su -l' does not update utmp and related databases. 2012-11-21 19:30:53 +00:00
christos a675bef13d make this compile again. 2012-04-12 15:35:07 +00:00
joerg 66dd2755f5 Add __printflike attribution to use vprintf and friends with an argument
as format string.
2012-03-15 02:02:20 +00:00
plunky 9f61b80465 NULL does not need a cast 2011-08-31 16:24:54 +00:00
elric 07b0c75a48 We no longer need -I/usr/include/krb5. 2011-04-24 21:42:06 +00:00
tron c71ba331c0 Don't free memory that was succesfully passed to putenv(3) which takes
ownership of the memory.
2010-10-02 10:55:36 +00:00
wiz ea548d35a5 Sort options. 2009-05-18 09:37:44 +00:00
lukem 98e5374ccb Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
2008-07-21 14:19:20 +00:00
lukem 050e20c6d5 Be consistent about making USE_PAM!=no be exclusive to USE_SKEY!=no. 2008-04-06 09:54:37 +00:00
christos 327d0b0912 call setprogname(), from Anon Ymous 2008-04-05 15:59:39 +00:00
christos b4403619e0 bump date. 2007-10-27 18:43:37 +00:00
christos 59604b5887 uncomment the group handling documentation. 2007-10-27 18:42:42 +00:00
christos 3670ce19dd - move grutil code to newgrp.
- enable user:group and :group code.
2007-10-27 15:37:45 +00:00
christos 40a10c757f From Anon Ymous:
- Fix a memory leak in newgrp().  (Noted by ginsbach@.)

- If the new and old groups are the same, addgrp() does nothing so
  exit early.  (Noted by ginsbach@.)

- In newgrp(), if the new group isn't found in the in-core, check the
  group membership list anyway as the in-core list may be full or
  /etc/groups may have been edited since login.  (Requested by
  ginsbach@.)

- Deal with a full in-core group[] array in addgid() rather than
  silently ignoring it and ending up with a group[] array that is
  inconsistent with the current group.

- More explicit error handling in addgroup().
2007-10-27 15:33:25 +00:00
christos 1b946384ef Make the license match to grutil.c 2007-10-18 15:41:50 +00:00
christos e16da7f1bc Put the proper license on this file, using the newgrp.c one. 2007-10-18 13:04:06 +00:00
christos 40d5720e00 From Anon Ymous:
- general cleanup [e-funcs, lint fixes, exit values, more error checking]
- add the ability to change the primary group group as login:group, or :group
  *disabled*, until it is discussed.
- remove krb4 code since there is no more krb4 code in the tree.
- also make the old su behave like the pam su: su to the same user, does
  not ask for a password.
- split out shared code into a separate file.
2007-10-17 21:05:39 +00:00
tls 4147a3c54a Add new Makefile knob, USE_FORT, which extends USE_SSP by turning on the
FORTIFY_SOURCE feature of libssp, thus checking the size of arguments to
various string and memory copy and set functions (as well as a few system
calls and other miscellany) where known at function entry.  RedHat has
evidently built all "core system packages" with this option for some time.

This option should be used at the top of Makefiles (or Makefile.inc where
this is used for subdirectories) but after any setting of LIB.

This is only useful for userland code, and cannot be used in libc or in
any code which includes the libc internals, because it overrides certain
libc functions with macros.  Some effort has been made to make USE_FORT=yes
work correctly for a full-system build by having the bsd.sys.mk logic
disable the feature where it should not be used (libc, libssp iteself,
the kernel) but no attempt has been made to build the entire system with
USE_FORT and doing so will doubtless expose numerous bugs and misfeatures.

Adjust the system build so that all programs and libraries that are setuid,
directly handle network data (including serial comm data), perform
authentication, or appear likely to have (or have a history of having)
data-driven bugs (e.g. file(1)) are built with USE_FORT=yes by default,
with the exception of libc, which cannot use USE_FORT and thus uses
only USE_SSP by default.  Tested on i386 with no ill results; USE_FORT=no
per-directory or in a system build will disable if desired.
2007-05-28 12:06:17 +00:00
christos 2b91c98c21 remove PAM_DEBUG 2006-07-13 18:18:09 +00:00
mlelstv bad43188a8 restore elevated priority before launching command in
user context. Fixes PR 33479.
2006-05-14 21:18:31 +00:00
christos 85e611dd01 Goodbye KerberosIV 2006-03-20 04:03:10 +00:00
christos dcf51e5c6a Use LOGIN_CAP even in the pam case. 2005-12-15 14:03:34 +00:00
christos 04095b6d82 PR/32307: Jason V. Miller: su fails to set umask correctly when using pam
and simulating a full login (-, -d, -l)
2005-12-15 14:01:31 +00:00
hubertf 9df5e26cc9 Give a general description what this command does before going into
all the details.
2005-12-15 05:26:36 +00:00
kleink 99dffcffea Set LOGNAME in the new environment (in addition to USER);
fixes PR bin/30670 from Pavel Cahyna.
2005-07-05 20:15:13 +00:00
wiz 76f0e20b24 Use groff macros instead of troff ones. 2005-06-19 17:34:03 +00:00
wiz 2e770dfdda Drop trailing whitespace. 2005-06-19 17:26:30 +00:00
christos 1246ae1e23 check for pwd != NULL 2005-04-19 03:17:35 +00:00
christos dac720be4f Update with pam descriptions.
XXX: needs more work.
1. code needs to be added in pam_group.so to handle indirect groups and
   documented.
2. the indirect group description outside before the customization section
   does not work with pam, but could be made to work once [1] is implemented.
2005-04-05 18:46:33 +00:00
he 65525e6df1 Put declaration of pwbuf[] back before any code, so this compiles with
older versions of gcc again.
2005-04-02 16:12:52 +00:00
christos bbb7e01ae0 - Use the getpw*_r methods.
- KNF.
2005-03-30 01:16:22 +00:00
christos 93bf0b6883 Deal with signals and process groups (from FreeBSD)
Fixes issues with kill -STOP $$ in the su'd shell, and setting up signals
for the child process properly.
2005-03-23 20:02:28 +00:00
he 8e8728c45c Introduce PAM_STATIC_LDADD and PAM_STATIC_DPADD. When compiling
with MKPIC=no, possibly because the target does not support shared
libraries, these include libraries required to resolve all symbols
which end up referenced from PAM-using applications.  The libraries
presently required are -lcrypt, -lrpcsvc and -lutil.

Add use of these variables which are currently set up to use PAM,
so that they compile when MKPIC=no.

Also, in the telnetd case, reorder the order of the libraries, so
that libtelnet.a comes before -ltermcap and -lutil, again to fix
link error when MKPIC=no.

Discussed with thorpej and christos.
2005-03-04 20:41:08 +00:00