Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ fi
AM_CONDITIONAL([USE_PAM], [test "X$with_libpam" = "Xyes"])

AC_ARG_WITH([fcaps],
[AS_HELP_STRING([--with-fcaps], [use file capabilities instead of suid binaries for newuidmap/newgidmap @<:@default=no@:>@])],
[AS_HELP_STRING([--with-fcaps], [use file capabilities instead of suid binaries where possible @<:@default=no@:>@])],
Comment thread
alejandro-colomar marked this conversation as resolved.
[with_fcaps=$withval], [with_fcaps=no])
AM_CONDITIONAL([FCAPS], [test "x$with_fcaps" = "xyes"])

Expand Down
1 change: 1 addition & 0 deletions lib/find_new_sub_gids.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <stdio.h>
#include <errno.h>
#include <stdint.h>
Comment thread
anthonyryan1 marked this conversation as resolved.

#include "prototypes.h"
#include "subordinateio.h"
Expand Down
1 change: 1 addition & 0 deletions lib/find_new_sub_uids.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <stdio.h>
#include <errno.h>
#include <stdint.h>

#include "prototypes.h"
#include "subordinateio.h"
Expand Down
1 change: 1 addition & 0 deletions lib/pwd_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void pwd_init (void)
signal (SIGTERM, SIG_IGN);
signal (SIGTSTP, SIG_IGN);
signal (SIGTTOU, SIG_IGN);
signal (SIGXFSZ, SIG_IGN);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the commit message:

The --with-fcaps argument now changes what our Makefile does, but
runtime behaviour doesn't depend on the configuration argument.

Should this go in a separate commit? It doesn't seem to be the same change as Expand the use of --with-fcaps to other binaries.

umask (077);
}
23 changes: 19 additions & 4 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,22 @@ noinst_PROGRAMS = sulogin

suidusbins =
suidbins =
suidubins = chage chfn chsh gpasswd newgrp
if WITH_SU
suidbins += su
endif

privubins = chage chfn chsh gpasswd newgrp
if !WITH_TCB
suidubins += passwd
privubins += passwd
endif
if ENABLE_SUBIDS
if !FCAPS
suidubins += newgidmap newuidmap
privubins += newgidmap newuidmap
endif

if FCAPS
suidubins =
else
suidubins = $(privubins)
endif

if WITH_TCB
Expand Down Expand Up @@ -143,6 +148,16 @@ if WITH_TCB
chmod $(sgidperms) $(DESTDIR)$(ubindir)/$$i; \
done
endif
if FCAPS
setcap cap_dac_read_search+ep $(DESTDIR)$(ubindir)/chage
setcap cap_setgid,cap_dac_read_search+ep $(DESTDIR)$(ubindir)/newgrp
setcap cap_chown,cap_dac_override,cap_fowner+ep $(DESTDIR)$(ubindir)/chfn
setcap cap_chown,cap_dac_override,cap_fowner+ep $(DESTDIR)$(ubindir)/chsh
setcap cap_chown,cap_dac_override,cap_fowner+ep $(DESTDIR)$(ubindir)/gpasswd
if !WITH_TCB
setcap cap_chown,cap_dac_override,cap_fowner+ep $(DESTDIR)$(ubindir)/passwd
endif
endif
if ENABLE_SUBIDS
if FCAPS
setcap cap_setuid+ep $(DESTDIR)$(ubindir)/newuidmap
Expand Down
8 changes: 1 addition & 7 deletions src/chfn.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,7 @@ static void update_gecos(const char *user, char *gecos, const struct option_flag

process_selinux = !flags->chroot;

/*
* Before going any further, raise the ulimit to prevent colliding
* into a lowered ulimit, and set the real UID to root to protect
* against unexpected signals. Any keyboard signals are set to be
* ignored.
*/
if (setuid (0) != 0) {
if (geteuid () == 0 && setuid (0) != 0) {
fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG(LOG_ERR, "can't setuid(0)");
fail_exit (E_NOPERM, process_selinux);
Expand Down
8 changes: 1 addition & 7 deletions src/chsh.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,7 @@ static void update_shell (const char *user, char *newshell, const struct option_

process_selinux = !flags->chroot;

/*
* Before going any further, raise the ulimit to prevent
* colliding into a lowered ulimit, and set the real UID
* to root to protect against unexpected signals. Any
* keyboard signals are set to be ignored.
*/
if (setuid (0) != 0) {
if (geteuid () == 0 && setuid (0) != 0) {
SYSLOG(LOG_ERR, "can't setuid(0)");
fputs (_("Cannot change ID to root.\n"), stderr);
fail_exit (1, process_selinux);
Expand Down
2 changes: 1 addition & 1 deletion src/gpasswd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ int main (int argc, char **argv)
* output, etc.
*/
output:
if (setuid (0) != 0) {
if (geteuid () == 0 && setuid (0) != 0) {
fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG(LOG_ERR, "can't setuid(0)");
closelog ();
Expand Down
2 changes: 1 addition & 1 deletion src/passwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ main(int argc, char **argv)
exit (E_SUCCESS);
}
#endif /* USE_PAM */
if (setuid (0) != 0) {
if (geteuid () == 0 && setuid (0) != 0) {
(void) fputs (_("Cannot change ID to root.\n"), stderr);
SYSLOG(LOG_ERR, "can't setuid(0)");
closelog ();
Expand Down
Loading