if !WITH_TCB
suidubins += passwd
endif
-if ACCT_TOOLS_SETUID
-suidusbins += chgpasswd chpasswd groupadd groupdel groupmod newusers useradd userdel usermod
-endif
if ENABLE_SUBIDS
if !FCAPS
suidubins += newgidmap newuidmap
$(top_builddir)/lib/libshadow.la \
$(LIBTCB)
-if ACCT_TOOLS_SETUID
-LIBPAM_SUID = $(LIBPAM)
-else
-LIBPAM_SUID =
-endif
-
if USE_PAM
LIBCRYPT_NOPAM =
else
newuidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) $(LIBECONF) -ldl
newgidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) $(LIBECONF) -ldl
chfn_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
-chgpasswd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
+chgpasswd_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
chsh_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
chpasswd_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF) -ldl
expiry_LDADD = $(LDADD) $(LIBECONF)
gpasswd_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
-groupadd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) -ldl
-groupdel_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) -ldl
+groupadd_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) -ldl
+groupdel_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) -ldl
groupmems_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
-groupmod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) -ldl
+groupmod_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF) -ldl
grpck_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
grpconv_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
grpunconv_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
suauth.c
su_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF) $(LIBSELINUX)
sulogin_LDADD = $(LDADD) $(LIBCRYPT) $(LIBECONF)
-useradd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBECONF) -ldl
-userdel_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBECONF) -ldl
-usermod_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBECONF) -ldl
+useradd_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBECONF) -ldl
+userdel_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBECONF) -ldl
+usermod_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBSEMANAGE) $(LIBACL) $(LIBECONF) -ldl
vipw_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
install-am: all-am
#include <stdio.h>
#include <stdlib.h>
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include "atoi/a2i.h"
#include "defines.h"
#include "nscd.h"
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
-static void check_perms (void);
static void open_files (bool process_selinux);
static void close_files(const struct option_flags *flags);
}
}
-/*
- * check_perms - check if the caller is allowed to add a group
- *
- * With PAM support, the setuid bit can be set on chgpasswd to allow
- * non-root users to groups.
- * Without PAM support, only users who can write in the group databases
- * can add groups.
- *
- * It will not return if the user is not allowed.
- */
-static void check_perms (void)
-{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
- struct passwd *pampw;
-
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (NULL == pampw) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- exit (1);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- exit (1);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-}
-
/*
* open_files - lock and open the group databases
*/
OPENLOG (Prog);
- check_perms ();
-
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present ();
#endif
NORETURN static void usage (int status);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
-static void check_perms (void);
static void open_files(const struct option_flags *flags);
static void close_files(const struct option_flags *flags);
}
}
-/*
- * check_perms - check if the caller is allowed to add a group
- *
- * With PAM support, the setuid bit can be set on chpasswd to allow
- * non-root users to groups.
- * Without PAM support, only users who can write in the group databases
- * can add groups.
- *
- * It will not return if the user is not allowed.
- */
-static void check_perms (void)
-{
-#ifdef USE_PAM
-#ifdef ACCT_TOOLS_SETUID
- /* If chpasswd uses PAM and is SUID, check the permissions,
- * otherwise, the permissions are enforced by the access to the
- * passwd and shadow files.
- */
- pam_handle_t *pamh = NULL;
- int retval;
- struct passwd *pampw;
-
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (NULL == pampw) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- exit (1);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- exit (1);
- }
- (void) pam_end (pamh, retval);
-#endif /* ACCT_TOOLS_SETUID */
-#endif /* USE_PAM */
-}
-
/*
* open_files - lock and open the password databases
*/
OPENLOG (Prog);
- check_perms ();
-
#ifdef USE_PAM
if (!use_pam)
#endif /* USE_PAM */
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#include <pwd.h>
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include "atoi/getnum.h"
#include "chkname.h"
static void open_files(const struct option_flags *flags);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
-static void check_perms (void);
/*
* usage - display usage message and exit
}
}
-/*
- * check_perms - check if the caller is allowed to add a group
- *
- * With PAM support, the setuid bit can be set on groupadd to allow
- * non-root users to groups.
- * Without PAM support, only users who can write in the group databases
- * can add groups.
- *
- * It will not return if the user is not allowed.
- */
-static void check_perms (void)
-{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
- struct passwd *pampw;
-
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (NULL == pampw) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- fail_exit (1);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- fail_exit (1);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-}
-
/*
* main - groupadd command
*/
*/
process_flags (argc, argv, &flags);
- check_perms ();
-
if (run_parts ("/etc/shadow-maint/groupadd-pre.d", group_name,
Prog)) {
exit(1);
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include <stdio.h>
#include <sys/types.h>
#include <getopt.h>
int main (int argc, char **argv)
{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
struct option_flags flags = {.chroot = false, .prefix = false};
log_set_progname(Prog);
process_flags (argc, argv, &flags);
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- {
- struct passwd *pampw;
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (pampw == NULL) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- fail_exit (1);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- fail_exit (1);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present ();
#include <string.h>
#include <strings.h>
#include <sys/types.h>
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#include <pwd.h>
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include "alloc/malloc.h"
#include "atoi/getnum.h"
*/
int main (int argc, char **argv)
{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
struct option_flags flags = {.chroot = false, .prefix = false};
log_set_progname(Prog);
process_flags (argc, argv, &flags);
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- {
- struct passwd *pampw;
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (NULL == pampw) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- exit (E_PAM_USERNAME);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- exit (E_PAM_ERROR);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present ();
#endif
#include "atoi/a2i.h"
#include "atoi/getnum.h"
#include "attr.h"
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include "chkname.h"
#include "defines.h"
#include "getdef.h"
static int add_passwd (struct passwd *, const char *);
static void process_flags (int argc, char **argv, struct option_flags *flags);
static void check_flags (void);
-static void check_perms(const struct option_flags *flags);
static void open_files (bool process_selinux);
static void close_files(const struct option_flags *flags);
#endif /* !USE_PAM */
}
-/*
- * check_perms - check if the caller is allowed to add a group
- *
- * With PAM support, the setuid bit can be set on groupadd to allow
- * non-root users to groups.
- * Without PAM support, only users who can write in the group databases
- * can add groups.
- *
- * It will not return if the user is not allowed.
- */
-static void
-check_perms(MAYBE_UNUSED const struct option_flags *flags)
-{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
- struct passwd *pampw;
- bool process_selinux;
-
- process_selinux = !flags->chroot;
-
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (NULL == pampw) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- fail_exit (EXIT_FAILURE, process_selinux);
- }
-
- retval = pam_start ("newusers", pampw->pw_name, &conv, &pamh);
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- fail_exit (EXIT_FAILURE, process_selinux);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-}
-
/*
* open_files - lock and open the password, group and shadow databases
*/
process_flags (argc, argv, &flags);
process_selinux = !flags.chroot;
- check_perms (&flags);
-
is_shadow = spw_file_present ();
#ifdef SHADOWGRP
#include <libgen.h>
#include <pwd.h>
#include <signal.h>
-#ifdef ACCT_TOOLS_SETUID
-# ifdef USE_PAM
-# include "pam_defs.h"
-# endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include <paths.h>
#include <stddef.h>
#include <stdio.h>
*/
int main (int argc, char **argv)
{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-
#ifdef ENABLE_SUBIDS
uid_t uid_min;
uid_t uid_max;
exit(1);
}
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- {
- struct passwd *pampw;
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (pampw == NULL && getuid ()) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- fail_exit (1, process_selinux);
- }
-
- retval = pam_start (Prog, pampw?pampw->pw_name:"root", &conv, &pamh);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- fail_exit (1, process_selinux);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-
/*
* See if we are messing with the defaults file, or creating
* a new user.
#include <sys/types.h>
#include <unistd.h>
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include "defines.h"
#include "getdef.h"
#include "groupio.h"
{
bool errors = false; /* Error in the removal of the home directory */
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
usage (E_USAGE);
}
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- {
- struct passwd *pampw;
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (pampw == NULL) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- exit (E_PW_UPDATE);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- exit (E_PW_UPDATE);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-
is_shadow_pwd = spw_file_present ();
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present ();
#include <lastlog.h>
#endif /* ENABLE_LASTLOG */
#include <pwd.h>
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
-#include "pam_defs.h"
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
*/
int main (int argc, char **argv)
{
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- pam_handle_t *pamh = NULL;
- int retval;
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
struct option_flags flags = {.chroot = false, .prefix = false};
bool process_selinux;
exit (E_USER_BUSY);
}
-#ifdef ACCT_TOOLS_SETUID
-#ifdef USE_PAM
- {
- struct passwd *pampw;
- pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (pampw == NULL) {
- fprintf (stderr,
- _("%s: Cannot determine your user name.\n"),
- Prog);
- exit (1);
- }
-
- retval = pam_start (Prog, pampw->pw_name, &conv, &pamh);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_authenticate (pamh, 0);
- }
-
- if (PAM_SUCCESS == retval) {
- retval = pam_acct_mgmt (pamh, 0);
- }
-
- if (PAM_SUCCESS != retval) {
- fprintf (stderr, _("%s: PAM: %s\n"),
- Prog, pam_strerror (pamh, retval));
- SYSLOG((LOG_ERR, "%s", pam_strerror (pamh, retval)));
- if (NULL != pamh) {
- (void) pam_end (pamh, retval);
- }
- exit (1);
- }
- (void) pam_end (pamh, retval);
-#endif /* USE_PAM */
-#endif /* ACCT_TOOLS_SETUID */
-
#ifdef WITH_TCB
if (shadowtcb_set_user (user_name) == SHADOWTCB_FAILURE) {
exit (E_PW_UPDATE);