[svn-upgrade] Integrating new upstream version, shadow (20000826)

This commit is contained in:
nekral-guest
2007-10-07 11:44:14 +00:00
parent 446e664caa
commit efd7efa9f1
196 changed files with 7676 additions and 9088 deletions

View File

@@ -47,15 +47,15 @@ suidubins = chage chfn chsh expiry gpasswd newgrp passwd
install-exec-hook:
for i in $(suidbins); do \
chmod 4755 $(bindir)/$$i; \
chmod 4755 $(DESTDIR)$(bindir)/$$i; \
done
install-data-hook:
for i in $(suidubins); do \
chmod 4755 $(ubindir)/$$i; \
chmod 4755 $(DESTDIR)$(ubindir)/$$i; \
done
rm -f $(ubindir)/sg
ln -s newgrp $(ubindir)/sg
rm -f $(DESTDIR)$(ubindir)/sg
ln -s newgrp $(DESTDIR)$(ubindir)/sg
noinst_PROGRAMS = groups id sulogin
@@ -79,7 +79,7 @@ noinst_PROGRAMS = groups id sulogin
shlibs = ../lib/libshadow.la
# With glibc2, almost all programs need libcrypt for some reason,
# even those that don't actually use crypt().
LDADD = ${shlibs} ../libmisc/libmisc.a ../lib/libshadow.a @INTLLIBS@ @LIBCRYPT@ @LIBTCFS@ @LIBSKEY@
LDADD = ${shlibs} ../libmisc/libmisc.a ../lib/libshadow.a @INTLLIBS@ @LIBCRYPT@ @LIBTCFS@ @LIBSKEY@ @LIBMD@
INCLUDES = -I${top_srcdir}/lib -I$(top_srcdir)/libmisc
chfn_LDADD = ${LDADD} @LIBPAM@

View File

@@ -76,6 +76,7 @@ INTLOBJS = @INTLOBJS@
LD = @LD@
LIBCRACK = @LIBCRACK@
LIBCRYPT = @LIBCRYPT@
LIBMD = @LIBMD@
LIBPAM = @LIBPAM@
LIBSKEY = @LIBSKEY@
LIBTCFS = @LIBTCFS@
@@ -164,7 +165,7 @@ noinst_PROGRAMS = groups id sulogin
shlibs = ../lib/libshadow.la
# With glibc2, almost all programs need libcrypt for some reason,
# even those that don't actually use crypt().
LDADD = ${shlibs} ../libmisc/libmisc.a ../lib/libshadow.a @INTLLIBS@ @LIBCRYPT@ @LIBTCFS@ @LIBSKEY@
LDADD = ${shlibs} ../libmisc/libmisc.a ../lib/libshadow.a @INTLLIBS@ @LIBCRYPT@ @LIBTCFS@ @LIBSKEY@ @LIBMD@
INCLUDES = -I${top_srcdir}/lib -I$(top_srcdir)/libmisc
chfn_LDADD = ${LDADD} @LIBPAM@
@@ -879,15 +880,15 @@ mostlyclean distclean maintainer-clean
install-exec-hook:
for i in $(suidbins); do \
chmod 4755 $(bindir)/$$i; \
chmod 4755 $(DESTDIR)$(bindir)/$$i; \
done
install-data-hook:
for i in $(suidubins); do \
chmod 4755 $(ubindir)/$$i; \
chmod 4755 $(DESTDIR)$(ubindir)/$$i; \
done
rm -f $(ubindir)/sg
ln -s newgrp $(ubindir)/sg
rm -f $(DESTDIR)$(ubindir)/sg
ln -s newgrp $(DESTDIR)$(ubindir)/sg
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chage.c,v 1.16 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: chage.c,v 1.17 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -59,6 +59,7 @@ RCSID(PKG_VER "$Id: chage.c,v 1.16 1999/08/27 19:02:51 marekm Exp $")
#endif /* SHADOWPWD */
static char *Prog;
static int amroot;
#ifdef AGING /*{*/
@@ -122,13 +123,12 @@ extern int sp_dbm_mode;
#endif
/* local function prototypes */
static void usage P_((void));
static void date_to_str P_((char *, size_t, time_t));
static int new_fields P_((void));
static void print_date P_((time_t));
static void list_fields P_((void));
int main P_((int, char **));
static void cleanup P_((int));
static void usage(void);
static void date_to_str(char *, size_t, time_t);
static int new_fields(void);
static void print_date(time_t);
static void list_fields(void);
static void cleanup(int);
/*
* usage - print command line syntax and exit
@@ -371,7 +371,7 @@ main(int argc, char **argv)
#else
char new_age[5];
#endif
uid_t ruid = getuid ();
uid_t ruid;
const struct passwd *pw;
struct passwd pwent;
char name[BUFSIZ];
@@ -381,6 +381,9 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
ruid = getuid();
amroot = (ruid == 0);
/*
* Get the program name so that error messages can use it.
*/
@@ -476,7 +479,7 @@ main(int argc, char **argv)
* information.
*/
if (ruid != 0 && ! lflg) {
if (!amroot && !lflg) {
fprintf (stderr, _("%s: permission denied\n"), Prog);
closelog();
exit (1);
@@ -487,14 +490,14 @@ main(int argc, char **argv)
* password file entries into memory. Then we get a pointer
* to the password file entry for the requested user.
*/
if (!pw_lock()) {
/* We don't lock the password file if we are not root */
if (amroot && !pw_lock()) {
fprintf(stderr, _("%s: can't lock password file\n"), Prog);
SYSLOG((LOG_ERR, LOCK_FAIL, PASSWD_FILE));
closelog();
exit(1);
}
if (!pw_open((ruid != 0 || lflg) ? O_RDONLY:O_RDWR)) {
if (!pw_open((!amroot || lflg) ? O_RDONLY:O_RDWR)) {
fprintf(stderr, _("%s: can't open password file\n"), Prog);
cleanup(1);
SYSLOG((LOG_ERR, OPEN_FAIL, PASSWD_FILE));
@@ -519,15 +522,15 @@ main(int argc, char **argv)
* a new entry will be created for this user if one does
* not exist already.
*/
if (!spw_lock()) {
/* We don't lock the shadow file if we are not root */
if (amroot && !spw_lock()) {
fprintf(stderr, _("%s: can't lock shadow password file\n"), Prog);
cleanup(1);
SYSLOG((LOG_ERR, LOCK_FAIL, SHADOW_FILE));
closelog();
exit(1);
}
if (!spw_open((ruid != 0 || lflg) ? O_RDONLY:O_RDWR)) {
if (!spw_open((!amroot || lflg) ? O_RDONLY : O_RDWR)) {
fprintf(stderr, _("%s: can't open shadow password file\n"), Prog);
cleanup(2);
SYSLOG((LOG_ERR, OPEN_FAIL, SHADOW_FILE));
@@ -588,7 +591,7 @@ main(int argc, char **argv)
*/
if (lflg) {
if (ruid != 0 && ruid != pwent.pw_uid) {
if (!amroot && (ruid != pwent.pw_uid)) {
fprintf(stderr, _("%s: permission denied\n"), Prog);
closelog();
exit(1);
@@ -785,14 +788,16 @@ static void
cleanup(int state)
{
switch (state) {
case 2:
case 2:
#ifdef SHADOWPWD
spw_unlock ();
if (amroot)
spw_unlock();
#endif
case 1:
pw_unlock ();
case 0:
break;
case 1:
if (amroot)
pw_unlock();
case 0:
break;
}
}

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chfn.c,v 1.15 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: chfn.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -90,11 +90,10 @@ extern int pw_dbm_mode;
#define CHGGECOS "changed user `%s' information.\n"
/* local function prototypes */
static void usage P_((void));
static int may_change_field P_((int));
static void new_fields P_((void));
static char *copy_field P_((char *, char *, char *));
int main P_((int, char **));
static void usage(void);
static int may_change_field(int);
static void new_fields(void);
static char *copy_field(char *, char *, char *);
/*
* usage - print command line syntax and exit

View File

@@ -43,7 +43,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chpasswd.c,v 1.9 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: chpasswd.c,v 1.10 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include "prototypes.h"
@@ -61,12 +61,10 @@ static int eflg = 0;
static int is_shadow_pwd;
#endif
extern char *crypt_make_salt P_((void));
extern char *l64a();
/* local function prototypes */
static void usage P_((void));
int main P_((int, char **));
static void usage(void);
/*
* usage - display usage message and exit

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chsh.c,v 1.15 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: chsh.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -91,10 +91,9 @@ extern int pw_dbm_mode;
#define CHGSHELL "changed user `%s' shell to `%s'\n"
/* local function prototypes */
static void usage P_((void));
static void new_fields P_((void));
static int restricted_shell P_((const char *));
int main P_((int, char **));
static void usage(void);
static void new_fields(void);
static int restricted_shell(const char *);
/*
* usage - print command line syntax and exit

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: dpasswd.c,v 1.10 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: dpasswd.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -58,12 +58,10 @@ static char *Prog;
extern int optind;
extern char *optarg;
extern char *crypt_make_salt P_((void));
extern char *getpass();
/* local function prototypes */
static void usage P_((void));
int main P_((int, char **));
static void usage(void);
static void
usage(void)

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: expiry.c,v 1.8 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: expiry.c,v 1.9 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <signal.h>
@@ -45,7 +45,6 @@ RCSID(PKG_VER "$Id: expiry.c,v 1.8 1999/06/07 16:40:45 marekm Exp $")
#endif
#endif
int main P_((int, char **));
#if !defined(SHADOWPWD) && !defined(AGING) /*{*/
@@ -62,8 +61,8 @@ main(int argc, char **argv)
#else /*} AGING || SHADOWPWD {*/
/* local function prototypes */
static RETSIGTYPE catch P_((int));
static void usage P_((void));
static RETSIGTYPE catch(int);
static void usage(void);
/*
* catch - signal catcher

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: faillog.c,v 1.9 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: faillog.c,v 1.10 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -61,16 +61,15 @@ extern char *optarg;
#define NOW (time((time_t *) 0))
/* local function prototypes */
static void usage P_((void));
int main P_((int, char **));
static void print P_((void));
static void print_one P_((const struct faillog *, uid_t));
static void reset P_((void));
static int reset_one P_((uid_t));
static void setmax P_((int));
static void setmax_one P_((uid_t, int));
static void set_locktime P_((long));
static void set_locktime_one P_((uid_t, long));
static void usage(void);
static void print(void);
static void print_one(const struct faillog *, uid_t);
static void reset(void);
static int reset_one(uid_t);
static void setmax(int);
static void setmax_one(uid_t, int);
static void set_locktime(long);
static void set_locktime_one(uid_t, long);
static void

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: gpasswd.c,v 1.15 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: gpasswd.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -65,7 +65,6 @@ static int
#define RETRIES 3
#endif
extern char *crypt_make_salt P_((void));
extern int optind;
extern char *optarg;
#ifdef NDBM
@@ -76,10 +75,9 @@ extern int gr_dbm_mode;
#endif
/* local function prototypes */
static void usage P_((void));
static RETSIGTYPE die P_((int));
static int check_list P_((const char *));
int main P_((int, char **));
static void usage(void);
static RETSIGTYPE die(int);
static int check_list(const char *);
/*
* usage - display usage message
@@ -564,11 +562,12 @@ main(int argc, char **argv)
cp = pw_encrypt(pass, crypt_make_salt());
memzero(pass, sizeof pass);
#ifdef SHADOWGRP
sgent.sg_passwd = cp;
#else
grent.gr_passwd = cp;
#ifdef SHADOWGRP
if (is_shadowgrp)
sgent.sg_passwd = cp;
else
#endif
grent.gr_passwd = cp;
SYSLOG((LOG_INFO, "change the password for group %s by %s\n", group, myname));
/*

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groupadd.c,v 1.14 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: groupadd.c,v 1.15 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -82,19 +82,18 @@ extern int optind;
extern char *optarg;
/* local function prototypes */
static void usage P_((void));
static void new_grent P_((struct group *));
static void usage(void);
static void new_grent(struct group *);
#ifdef SHADOWGRP
static void new_sgent P_((struct sgrp *));
static void new_sgent(struct sgrp *);
#endif
static void grp_update P_((void));
static void find_new_gid P_((void));
static void check_new_name P_((void));
static void process_flags P_((int, char **));
static void close_files P_((void));
static void open_files P_((void));
static void fail_exit P_((int));
int main P_((int, char **));
static void grp_update(void);
static void find_new_gid(void);
static void check_new_name(void);
static void process_flags(int, char **);
static void close_files(void);
static void open_files(void);
static void fail_exit(int);
/*
* usage - display usage message and exit

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groupdel.c,v 1.10 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: groupdel.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -70,12 +70,11 @@ static int is_shadow_grp;
#define E_GRP_UPDATE 10 /* can't update group file */
/* local function prototypes */
static void usage P_((void));
static void grp_update P_((void));
static void close_files P_((void));
static void open_files P_((void));
static void group_busy P_((gid_t));
int main P_((int, char **));
static void usage(void);
static void grp_update(void);
static void close_files(void);
static void open_files(void);
static void group_busy(gid_t);
/*
* usage - display usage message and exit

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groupmod.c,v 1.12 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: groupmod.c,v 1.13 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -83,18 +83,17 @@ extern int optind;
extern char *optarg;
/* local function prototypes */
static void usage P_((void));
static void new_grent P_((struct group *));
static void usage(void);
static void new_grent(struct group *);
#ifdef SHADOWGRP
static void new_sgent P_((struct sgrp *));
static void new_sgent(struct sgrp *);
#endif
static void grp_update P_((void));
static void check_new_gid P_((void));
static void check_new_name P_((void));
static void process_flags P_((int, char **));
static void close_files P_((void));
static void open_files P_((void));
int main P_((int, char **));
static void grp_update(void);
static void check_new_gid(void);
static void check_new_name(void);
static void process_flags(int, char **);
static void close_files(void);
static void open_files(void);
/*
* usage - display usage message and exit

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groups.c,v 1.5 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: groups.c,v 1.6 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include <pwd.h>
@@ -39,8 +39,7 @@ RCSID(PKG_VER "$Id: groups.c,v 1.5 1999/06/07 16:40:45 marekm Exp $")
#include "defines.h"
/* local function prototypes */
static void print_groups P_((const char *));
int main P_((int, char **));
static void print_groups(const char *);
/*
* print_groups - print the groups which the named user is a member of

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: grpck.c,v 1.12 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: grpck.c,v 1.13 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include <fcntl.h>
@@ -44,13 +44,13 @@ RCSID(PKG_VER "$Id: grpck.c,v 1.12 1999/06/07 16:40:45 marekm Exp $")
#include "commonio.h"
#include "groupio.h"
extern void __gr_del_entry P_((const struct commonio_entry *));
extern struct commonio_entry *__gr_get_head P_((void));
extern void __gr_del_entry(const struct commonio_entry *);
extern struct commonio_entry *__gr_get_head(void);
#ifdef SHADOWGRP
#include "sgroupio.h"
extern void __sgr_del_entry P_((const struct commonio_entry *));
extern struct commonio_entry *__sgr_get_head P_((void));
extern void __sgr_del_entry(const struct commonio_entry *);
extern struct commonio_entry *__sgr_get_head(void);
#endif
/*
@@ -83,10 +83,9 @@ static const char *sgr_file = SGROUP_FILE;
static int read_only = 0;
/* local function prototypes */
static void usage P_((void));
static int yes_or_no P_((void));
static void delete_member P_((char **, const char *));
int main P_((int, char **));
static void usage(void);
static int yes_or_no(void);
static void delete_member(char **, const char *);
/*
* usage - print syntax message and exit
@@ -289,7 +288,7 @@ main(int argc, char **argv)
* be parsed properly.
*/
if (!gre->entry) {
if (!gre->eptr) {
/*
* Tell the user this entire line is bogus and
@@ -327,7 +326,7 @@ delete_gr:
* Group structure is good, start using it.
*/
grp = gre->entry;
grp = gre->eptr;
/*
* Make sure this entry has a unique name.
@@ -335,7 +334,7 @@ delete_gr:
for (tgre = __gr_get_head(); tgre; tgre = tgre->next) {
const struct group *ent = tgre->entry;
const struct group *ent = tgre->eptr;
/*
* Don't check this entry
@@ -444,7 +443,7 @@ delete_gr:
* be parsed properly.
*/
if (!sge->entry) {
if (!sge->eptr) {
/*
* Tell the user this entire line is bogus and
@@ -482,7 +481,7 @@ delete_sg:
* Shadow group structure is good, start using it.
*/
sgr = sge->entry;
sgr = sge->eptr;
/*
* Make sure this entry has a unique name.
@@ -490,7 +489,7 @@ delete_sg:
for (tsge = __sgr_get_head(); tsge; tsge = tsge->next) {
const struct sgrp *ent = tsge->entry;
const struct sgrp *ent = tsge->eptr;
/*
* Don't check this entry

View File

@@ -27,14 +27,13 @@
#include "sgroupio.h"
#include "rcsid.h"
RCSID(PKG_VER "$Id: grpconv.c,v 1.10 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: grpconv.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
static int group_locked = 0;
static int gshadow_locked = 0;
/* local function prototypes */
static void fail_exit P_((int));
int main P_((int, char **));
static void fail_exit(int);
static void
fail_exit(int status)

View File

@@ -11,7 +11,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: grpunconv.c,v 1.9 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: grpunconv.c,v 1.10 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include <stdlib.h>
@@ -32,8 +32,7 @@ static int group_locked = 0;
static int gshadow_locked = 0;
/* local function prototypes */
static void fail_exit P_((int));
int main P_((int, char **));
static void fail_exit(int);
static void
fail_exit(int status)

View File

@@ -38,7 +38,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: id.c,v 1.5 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: id.c,v 1.6 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -47,8 +47,7 @@ RCSID(PKG_VER "$Id: id.c,v 1.5 1999/06/07 16:40:45 marekm Exp $")
#include "defines.h"
/* local function prototypes */
static void usage P_((void));
int main P_((int, char **));
static void usage(void);
static void
usage(void)

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: lastlog.c,v 1.5 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: lastlog.c,v 1.6 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -69,9 +69,8 @@ extern char *optarg;
#define NOW (time ((time_t *) 0))
/* local function prototypes */
int main P_((int, char **));
static void print P_((void));
static void print_one P_((const struct passwd *));
static void print(void);
static void print_one(const struct passwd *);
int
main(int argc, char **argv)

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: login.c,v 1.16 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: login.c,v 1.17 2000/08/26 18:27:18 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@@ -78,7 +78,7 @@ RCSID(PKG_VER "$Id: login.c,v 1.16 1999/08/27 19:02:51 marekm Exp $")
#include <netdb.h>
#endif
#ifdef USE_PAM_not_yet
#ifdef USE_PAM
#include "pam_defs.h"
static const struct pam_conv conv = {
@@ -96,7 +96,7 @@ static pam_handle_t *pamh = NULL;
#define PAM_END { retcode = pam_close_session(pamh,0); \
pam_end(pamh,retcode); }
#endif /* USE_PAM_not_yet */
#endif /* USE_PAM */
/*
* Needed for MkLinux DR1/2/2.1 - J.
@@ -140,16 +140,14 @@ static int timeout;
extern char **newenvp;
extern size_t newenvc;
extern char *tz P_((const char *));
extern void subsystem P_((const struct passwd *));
extern void dolastlog P_((struct lastlog *, const struct passwd *, const char *, const char *));
extern void dolastlog(struct lastlog *, const struct passwd *, const char *, const char *);
extern int optind;
extern char *optarg;
extern char **environ;
extern int login_access P_((const char *user, const char *from));
extern void login_fbtab P_((const char *tty, uid_t uid, gid_t gid));
extern int login_access(const char *, const char *);
extern void login_fbtab(const char *, uid_t, gid_t);
#ifndef ALARM
#define ALARM 60
@@ -175,14 +173,15 @@ static struct faillog faillog;
#define MANY_FAILS "REPEATED login failures%s\n"
/* local function prototypes */
static void usage P_((void));
static void setup_tty P_((void));
static void bad_time_notify P_((void));
static void check_flags P_((int, char * const *));
static void check_nologin P_((void));
static void init_env P_((void));
static RETSIGTYPE alarm_handler P_((int));
int main P_((int, char **));
static void usage(void);
static void setup_tty(void);
static void bad_time_notify(void);
static void check_flags(int, char * const *);
#ifndef USE_PAM
static void check_nologin(void);
#endif
static void init_env(void);
static RETSIGTYPE alarm_handler(int);
/*
* usage - print login command usage and exit
@@ -305,7 +304,7 @@ check_flags(int argc, char * const *argv)
}
}
#ifndef USE_PAM
static void
check_nologin(void)
{
@@ -352,7 +351,7 @@ check_nologin(void)
printf(_("\n[Disconnect bypassed -- root login allowed.]\n"));
}
}
#endif /* !USE_PAM */
static void
init_env(void)
@@ -436,10 +435,11 @@ main(int argc, char **argv)
char **envp = environ;
static char temp_pw[2];
static char temp_shell[] = "/bin/sh";
#ifdef USE_PAM_not_yet
#ifdef USE_PAM
int retcode;
pid_t child;
#endif /* USE_PAM_not_yet */
char *pam_user;
#endif /* USE_PAM */
#ifdef SHADOWPWD
struct spwd *spwd=NULL;
#endif
@@ -704,7 +704,7 @@ top:
delay = getdef_num("FAIL_DELAY", 1);
retries = getdef_num("LOGIN_RETRIES", RETRIES);
#ifdef USE_PAM_not_yet
#ifdef USE_PAM
retcode = pam_start("login", username, &conv, &pamh);
if(retcode != PAM_SUCCESS) {
fprintf(stderr,"login: PAM Failure, aborting: %s\n",
@@ -714,15 +714,38 @@ top:
exit(99);
}
/* hostname & tty are either set to NULL or their correct values,
depending on how much we know */
depending on how much we know. We also set PAM's fail delay
to ours. */
retcode = pam_set_item(pamh, PAM_RHOST, hostname);
PAM_FAIL_CHECK;
retcode = pam_set_item(pamh, PAM_TTY, tty);
PAM_FAIL_CHECK;
#ifdef HAVE_PAM_FAIL_DELAY
retcode = pam_fail_delay(pamh, 1000000*delay);
PAM_FAIL_CHECK;
#endif
/* if fflg == 1, then the user has already been authenticated */
if (!fflg || (getuid() != 0)) {
int failcount = 0;
int failcount;
char hostn[256];
char login_prompt[256]; /* That's one hell of a prompt :) */
/* Make the login prompt look like we want it */
if (!gethostname(hostn, sizeof(hostn)))
snprintf(login_prompt, sizeof(login_prompt),
"%s login: ", hostn);
else
snprintf(login_prompt, sizeof(login_prompt),
"login: ");
retcode = pam_set_item(pamh, PAM_USER_PROMPT, login_prompt);
PAM_FAIL_CHECK;
/* if we didn't get a user on the command line,
set it to NULL */
pam_get_item(pamh, PAM_USER, (const void **) &pam_user);
if (pam_user[0] == '\0')
pam_set_item(pamh, PAM_USER, NULL);
/* there may be better ways to deal with some of these
conditions, but at least this way I don't think we'll
@@ -737,30 +760,33 @@ top:
(retcode == PAM_USER_UNKNOWN) ||
(retcode == PAM_CRED_INSUFFICIENT) ||
(retcode == PAM_AUTHINFO_UNAVAIL))) {
pam_get_item(pamh, PAM_USER, (const void **) &username);
pam_get_item(pamh, PAM_USER, (const void **) &pam_user);
syslog(LOG_NOTICE,"FAILED LOGIN %d FROM %s FOR %s, %s",
failcount, hostname, username,
failcount, hostname, pam_user,
PAM_STRERROR(pamh, retcode));
fprintf(stderr,"Login incorrect\n\n");
pam_set_item(pamh,PAM_USER,NULL);
#ifdef HAVE_PAM_FAIL_DELAY
pam_fail_delay(pamh, 1000000*delay);
#endif
fprintf(stderr, "Login incorrect\n\n");
pam_set_item(pamh, PAM_USER, NULL);
retcode = pam_authenticate(pamh, 0);
}
if (retcode != PAM_SUCCESS) {
pam_get_item(pamh, PAM_USER, (const void **) &username);
pam_get_item(pamh, PAM_USER, (const void **) &pam_user);
if (retcode == PAM_MAXTRIES)
syslog(LOG_NOTICE,
"TOO MANY LOGIN TRIES (%d) FROM %s FOR %s, %s",
failcount, hostname, username,
failcount, hostname, pam_user,
PAM_STRERROR(pamh, retcode));
else
syslog(LOG_NOTICE,
"FAILED LOGIN SESSION FROM %s FOR %s, %s",
hostname, username,
hostname, pam_user,
PAM_STRERROR(pamh, retcode));
fprintf(stderr,"\nLogin incorrect\n");
fprintf(stderr, "\nLogin incorrect\n");
pam_end(pamh, retcode);
exit(0);
}
@@ -777,11 +803,12 @@ top:
/* Grab the user information out of the password file for future usage
First get the username that we are actually using, though.
*/
retcode = pam_get_item(pamh, PAM_USER, (const void **) &username);
retcode = pam_get_item(pamh, PAM_USER, (const void **) &pam_user);
setpwent();
pwd = getpwnam(username);
if (pwd)
initgroups(username, pwd->pw_gid);
pwd = getpwnam(pam_user);
if (!pwd || setup_groups(pwd))
exit(1);
retcode = pam_setcred(pamh, PAM_ESTABLISH_CRED);
PAM_FAIL_CHECK;
@@ -790,7 +817,7 @@ top:
PAM_FAIL_CHECK;
#else /* ! USE_PAM_not_yet */
#else /* ! USE_PAM */
while (1) { /* repeatedly get login/password pairs */
failed = 0; /* haven't failed authentication yet */
#ifdef RADIUS
@@ -813,8 +840,15 @@ top:
#endif
continue;
}
if (! (pwd = getpwnam(username))) {
#endif /* ! USE_PAM */
#ifdef USE_PAM
if (!(pwd = getpwnam(pam_user))) {
pwent.pw_name = pam_user;
#else
if (!(pwd = getpwnam(username))) {
pwent.pw_name = username;
#endif
strcpy(temp_pw, "!");
pwent.pw_passwd = temp_pw;
pwent.pw_shell = temp_shell;
@@ -824,7 +858,8 @@ top:
} else {
pwent = *pwd;
}
#ifdef SHADOWPWD
#ifndef USE_PAM
#ifdef SHADOWPWD
spwd = NULL;
if (pwd && strcmp(pwd->pw_passwd, SHADOW_PASSWD_STRING) == 0) {
spwd = getspnam(username);
@@ -833,7 +868,7 @@ top:
else
SYSLOG((LOG_WARN, NO_SHADOW, username, fromhost));
}
#endif /* SHADOWPWD */
#endif /* SHADOWPWD */
/*
* If the encrypted password begins with a "!", the account
@@ -996,9 +1031,9 @@ auth_ok:
exit(1);
}
} /* while (1) */
#endif /* ! USE_PAM_not_yet */
#endif /* ! USE_PAM */
(void) alarm (0); /* turn off alarm clock */
#if 1
#ifndef USE_PAM /* PAM does this */
/*
* porttime checks moved here, after the user has been
* authenticated. now prints a message, as suggested
@@ -1011,14 +1046,18 @@ auth_ok:
bad_time_notify();
exit(1);
}
#endif
check_nologin();
#endif
if (getenv("IFS")) /* don't export user IFS ... */
addenv("IFS= \t\n", NULL); /* ... instead, set a safe IFS */
#ifdef USE_PAM
setutmp(pam_user, tty, hostname); /* make entry in utmp & wtmp files */
#else
setutmp(username, tty, hostname); /* make entry in utmp & wtmp files */
#endif
if (pwent.pw_shell[0] == '*') { /* subsystem root */
subsystem (&pwent); /* figure out what to execute */
subroot++; /* say i was here again */
@@ -1032,14 +1071,17 @@ auth_ok:
#endif
goto top; /* go do all this all over again */
}
#ifndef USE_PAM /* pam_lastlog handles this */
if (getdef_bool("LASTLOG_ENAB")) /* give last login and log this one */
dolastlog(&lastlog, &pwent, utent.ut_line, hostname);
#endif
#ifdef SVR4_SI86_EUA
sysi86(SI86LIMUSER, EUA_ADD_USER); /* how do we test for fail? */
#endif
#ifdef AGING
#ifndef USE_PAM /* PAM handles this as well */
#ifdef AGING
/*
* Have to do this while we still have root privileges, otherwise
* we don't have access to /etc/shadow. expire() closes password
@@ -1066,7 +1108,7 @@ auth_ok:
}
#endif /* ATT_AGE */
#endif /* SHADOWPWD */
#endif /* AGING */
#endif /* AGING */
#ifdef RADIUS
if (is_rad_login) {
@@ -1082,6 +1124,7 @@ auth_ok:
}
#endif
setup_limits(&pwent); /* nice, ulimit etc. */
#endif /* ! USE_PAM */
chown_tty(tty, &pwent);
#ifdef LOGIN_FBTAB
@@ -1117,7 +1160,12 @@ auth_ok:
login_fbtab(tty, pwent.pw_uid, pwent.pw_gid);
#endif
/* We call set_groups() above because this clobbers pam_groups.so */
#ifndef USE_PAM
if (setup_uid_gid(&pwent, is_console))
#else
if (change_uid(&pwent))
#endif
exit(1);
#ifdef KERBEROS
@@ -1135,7 +1183,7 @@ auth_ok:
setup_env(&pwent); /* set env vars, cd to the home dir */
#ifdef USE_PAM_not_yet
#ifdef USE_PAM
{
int i;
const char * const * env;
@@ -1154,6 +1202,8 @@ auth_ok:
if (!hushed(&pwent)) {
addenv("HUSHLOGIN=FALSE", NULL);
/* pam_unix, pam_mail and pam_lastlog should take care of this */
#ifndef USE_PAM
motd(); /* print the message of the day */
if (getdef_bool("FAILLOG_ENAB") && faillog.fail_cnt != 0) {
failprint(&faillog);
@@ -1192,6 +1242,7 @@ auth_ok:
#endif
#endif /* AGING */
mailcheck(); /* report on the status of mail */
#endif /* !USE_PAM */
} else
addenv("HUSHLOGIN=TRUE", NULL);
@@ -1203,7 +1254,7 @@ auth_ok:
signal(SIGALRM, SIG_DFL); /* default alarm signal */
signal(SIGHUP, SIG_DFL); /* added this. --marekm */
#ifdef USE_PAM_not_yet
#ifdef USE_PAM
/* We must fork before setuid() because we need to call
* pam_close_session() as root.
*/
@@ -1211,20 +1262,26 @@ auth_ok:
the parent process of login (init, telnetd, ...) is responsible
for calling pam_close_session(). This avoids an extra process
for each login. Maybe we should do this on Linux too? -MM */
signal(SIGINT, SIG_IGN);
child = fork();
if (child < 0) {
/* error in fork() */
fprintf(stderr,"login: failure forking: %s", strerror(errno));
PAM_END;
exit(0);
} else if (child) {
/* parent - wait for child to finish, then cleanup session */
wait(NULL);
PAM_END;
exit(0);
/* We let the admin configure whether they need to keep login
around to close sessions */
if (getdef_bool("CLOSE_SESSIONS")) {
signal(SIGINT, SIG_IGN);
child = fork();
if (child < 0) {
/* error in fork() */
fprintf(stderr, "login: failure forking: %s",
strerror(errno));
PAM_END;
exit(0);
} else if (child) {
/* parent - wait for child to finish,
then cleanup session */
wait(NULL);
PAM_END;
exit(0);
}
/* child */
}
/* child */
#endif
signal(SIGINT, SIG_DFL); /* default interrupt signal */

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: logoutd.c,v 1.14 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: logoutd.c,v 1.15 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -60,8 +60,7 @@ static char *Prog;
#endif
/* local function prototypes */
static int check_login P_((const struct utmp *));
int main P_((int, char **));
static int check_login(const struct utmp *);
/*

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: mkpasswd.c,v 1.6 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: mkpasswd.c,v 1.7 2000/08/26 18:27:18 marekm Exp $")
#include <sys/stat.h>
#include "prototypes.h"
@@ -103,8 +103,7 @@ extern int sg_dbm_update();
#endif
/* local function prototypes */
int main P_((int, char **));
static void usage P_((void));
static void usage(void);
/*
* mkpasswd - create DBM files for /etc/passwd-like input file

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: newgrp.c,v 1.14 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: newgrp.c,v 1.15 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include <errno.h>
@@ -53,8 +53,7 @@ static char *Prog;
static int is_newgrp;
/* local function prototypes */
static void usage P_((void));
int main P_((int, char **));
static void usage(void);
/*
* usage - print command usage message
@@ -79,6 +78,7 @@ main(int argc, char **argv)
int initflag = 0;
int needspasswd = 0;
int i;
int their_grp = 0;
int cflag = 0;
gid_t gid;
char *cp;
@@ -95,7 +95,10 @@ main(int argc, char **argv)
struct sgrp *sgrp;
#endif
#if ENABLE_NLS
/* XXX - remove when gettext is safe to use in setuid programs */
sanitize_env();
#endif
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -243,6 +246,7 @@ main(int argc, char **argv)
goto failure;
}
group = grp->gr_name;
their_grp = 1;
} else if (! (grp = getgrnam (group))) {
fprintf (stderr, _("unknown group: %s\n"), group);
goto failure;
@@ -259,9 +263,13 @@ main(int argc, char **argv)
* if she isn't a member, she needs to provide the
* group password. if there is no group password, she
* will be denied access anyway.
*
* we also check if this is the users default group, eg.
* they aren't a member, but this is the group listed as
* the one they belong to in their pwd entry.
*/
if (!is_on_list(grp->gr_mem, name))
if (!is_on_list(grp->gr_mem, name) && !their_grp)
needspasswd = 1;
/*

View File

@@ -36,7 +36,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: newusers.c,v 1.10 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: newusers.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -49,8 +49,6 @@ RCSID(PKG_VER "$Id: newusers.c,v 1.10 1999/06/07 16:40:45 marekm Exp $")
static char *Prog;
extern char *crypt_make_salt P_((void));
#include "getdef.h"
#include "pwio.h"
#include "groupio.h"
@@ -62,12 +60,11 @@ static int is_shadow;
#endif
/* local function prototypes */
static void usage P_((void));
static int add_group P_((const char *, const char *, gid_t *));
static int add_user P_((const char *, const char *, uid_t *, gid_t));
static void update_passwd P_((struct passwd *, const char *));
static int add_passwd P_((struct passwd *, const char *));
int main P_((int, char **));
static void usage(void);
static int add_group(const char *, const char *, gid_t *);
static int add_user(const char *, const char *, uid_t *, gid_t);
static void update_passwd(struct passwd *, const char *);
static int add_passwd(struct passwd *, const char *);
/*
* usage - display usage message and exit

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: passwd.c,v 1.18 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: passwd.c,v 1.19 2000/08/26 18:27:18 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@@ -155,7 +155,6 @@ static int tcfs_force = 0;
* External identifiers
*/
extern char *crypt_make_salt P_((void));
#ifdef ATT_AGE
extern char *l64a();
#endif
@@ -197,39 +196,38 @@ extern int pw_dbm_mode;
#define NOCHGPASSWD "did not change password for `%s'"
/* local function prototypes */
static void usage P_((int));
static void usage(int);
#ifndef USE_PAM
#ifdef AUTH_METHODS
static char *get_password P_((const char *));
static int uses_default_method P_((const char *));
static char *get_password(const char *);
static int uses_default_method(const char *);
#endif /* AUTH_METHODS */
static int reuse P_((const char *, const struct passwd *));
static int new_password P_((const struct passwd *));
static int reuse(const char *, const struct passwd *);
static int new_password(const struct passwd *);
#ifdef SHADOWPWD
static void check_password P_((const struct passwd *, const struct spwd *));
static void check_password(const struct passwd *, const struct spwd *);
#else /* !SHADOWPWD */
static void check_password P_((const struct passwd *));
static void check_password(const struct passwd *);
#endif /* !SHADOWPWD */
static char *insert_crypt_passwd P_((const char *, const char *));
static char *insert_crypt_passwd(const char *, const char *);
#endif /* !USE_PAM */
static char *date_to_str P_((time_t));
static const char *pw_status P_((const char *));
static void print_status P_((const struct passwd *));
static void fail_exit P_((int));
static void oom P_((void));
static char *update_crypt_pw P_((char *));
static void update_noshadow P_((void));
static char *date_to_str(time_t);
static const char *pw_status(const char *);
static void print_status(const struct passwd *);
static void fail_exit(int);
static void oom(void);
static char *update_crypt_pw(char *);
static void update_noshadow(void);
#ifdef SHADOWPWD
static void update_shadow P_((void));
static void update_shadow(void);
#endif
#ifdef HAVE_TCFS
static void update_tcfs P_((void));
static void update_tcfs(void);
#endif
#ifdef HAVE_USERSEC_H
static void update_userpw P_((char *));
static void update_userpw(char *);
#endif
static long getnumber P_((const char *));
int main P_((int, char **));
static long getnumber(const char *);
/*
* usage - print command usage and exit
@@ -301,10 +299,10 @@ reuse(const char *pass, const struct passwd *pw)
#ifdef HAVE_LIBCRACK_HIST
const char *reason;
#ifdef HAVE_LIBCRACK_PW
const char *FascistHistoryPw P_((const char *,const struct passwd *));
const char *FascistHistoryPw(const char *,const struct passwd *);
reason = FascistHistory(pass, pw);
#else
const char *FascistHistory P_((const char *, int));
const char *FascistHistory(const char *, int);
reason = FascistHistory(pass, pw->pw_uid);
#endif
if (reason) {
@@ -333,7 +331,7 @@ new_password(const struct passwd *pw)
int warned;
int pass_max_len;
#ifdef HAVE_LIBCRACK_HIST
int HistUpdate P_((const char *, const char *));
int HistUpdate(const char *, const char *);
#endif
/*

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: pwck.c,v 1.13 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: pwck.c,v 1.14 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include <fcntl.h>
@@ -44,13 +44,13 @@ RCSID(PKG_VER "$Id: pwck.c,v 1.13 1999/06/07 16:40:45 marekm Exp $")
#include "commonio.h"
#include "pwio.h"
extern void __pw_del_entry P_((const struct commonio_entry *));
extern struct commonio_entry *__pw_get_head P_((void));
extern void __pw_del_entry(const struct commonio_entry *);
extern struct commonio_entry *__pw_get_head(void);
#ifdef SHADOWPWD
#include "shadowio.h"
extern void __spw_del_entry P_((const struct commonio_entry *));
extern struct commonio_entry *__spw_get_head P_((void));
extern void __spw_del_entry(const struct commonio_entry *);
extern struct commonio_entry *__spw_get_head(void);
#endif
/*
@@ -84,9 +84,8 @@ static int read_only = 0;
static int quiet = 0; /* don't report warnings, only errors */
/* local function prototypes */
static void usage P_((void));
static int yes_or_no P_((void));
int main P_((int, char **));
static void usage(void);
static int yes_or_no(void);
/*
* usage - print syntax message and exit
@@ -276,7 +275,7 @@ main(int argc, char **argv)
* be parsed properly.
*/
if (!pfe->entry) {
if (!pfe->eptr) {
/*
* Tell the user this entire line is bogus and
@@ -314,14 +313,14 @@ delete_pw:
* Password structure is good, start using it.
*/
pwd = pfe->entry;
pwd = pfe->eptr;
/*
* Make sure this entry has a unique name.
*/
for (tpfe = __pw_get_head(); tpfe; tpfe = tpfe->next) {
const struct passwd *ent = tpfe->entry;
const struct passwd *ent = tpfe->eptr;
/*
* Don't check this entry
@@ -445,7 +444,7 @@ delete_pw:
* be parsed properly.
*/
if (!spe->entry) {
if (!spe->eptr) {
/*
* Tell the user this entire line is bogus and
@@ -483,14 +482,14 @@ delete_spw:
* Shadow password structure is good, start using it.
*/
spw = spe->entry;
spw = spe->eptr;
/*
* Make sure this entry has a unique name.
*/
for (tspe = __spw_get_head(); tspe; tspe = tspe->next) {
const struct spwd *ent = tspe->entry;
const struct spwd *ent = tspe->eptr;
/*
* Don't check this entry

View File

@@ -31,7 +31,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: pwconv.c,v 1.10 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: pwconv.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
#include <stdio.h>
#include <stdlib.h>
@@ -65,8 +65,7 @@ static int
passwd_locked = 0;
/* local function prototypes */
static void fail_exit P_((int));
int main P_((int, char **));
static void fail_exit(int);
static void
fail_exit(int status)

View File

@@ -39,7 +39,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: pwunconv.c,v 1.8 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: pwunconv.c,v 1.9 2000/08/26 18:27:18 marekm Exp $")
#include "defines.h"
#include <sys/types.h>
@@ -72,8 +72,7 @@ static int shadow_locked = 0,
passwd_locked = 0;
/* local function prototypes */
static void fail_exit P_((int));
int main P_((int, char **));
static void fail_exit(int);
static void
fail_exit(int status)

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: su.c,v 1.13 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: su.c,v 1.14 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@@ -63,9 +63,9 @@ static pam_handle_t *pamh = NULL;
* Global variables
*/
/* needed by sulog.c */
char name[BUFSIZ];
char oldname[BUFSIZ];
/* not needed by sulog.c anymore */
static char name[BUFSIZ];
static char oldname[BUFSIZ];
static char *Prog;
@@ -78,19 +78,14 @@ struct passwd pwent;
extern char **newenvp;
extern size_t newenvc;
extern void sulog P_((const char *, int));
extern void subsystem P_((const struct passwd *));
extern char *tz P_((const char *));
extern int check_su_auth P_((const char *, const char *));
extern char **environ;
/* local function prototypes */
int main P_((int, char **));
#ifndef USE_PAM
static RETSIGTYPE die P_((int));
static int iswheel P_((const char *));
static RETSIGTYPE die(int);
static int iswheel(const char *);
/*
* die - set or reset termio modes.
@@ -133,7 +128,7 @@ iswheel(const char *username)
static void
su_failure(const char *tty)
{
sulog(tty, 0); /* log failed attempt */
sulog(tty, 0, oldname, name); /* log failed attempt */
#ifdef USE_SYSLOG
if (getdef_bool("SYSLOG_SU_ENAB"))
SYSLOG((pwent.pw_uid ? LOG_INFO:LOG_NOTICE,
@@ -247,27 +242,24 @@ main(int argc, char **argv)
* be ignored and a new one created later on.
*/
if (! fakelogin)
while (*envp)
addenv(*envp++, NULL);
if (fakelogin && (cp=getdef_str("ENV_TZ")))
addenv(*cp == '/' ? tz(cp) : cp, NULL);
if (fakelogin) {
if ((cp=getdef_str("ENV_TZ")))
addenv(*cp == '/' ? tz(cp) : cp, NULL);
/*
* The clock frequency will be reset to the login value if required
*/
if (fakelogin && (cp=getdef_str("ENV_HZ")) )
addenv(cp, NULL); /* set the default $HZ, if one */
if ((cp=getdef_str("ENV_HZ")))
addenv(cp, NULL); /* set the default $HZ, if one */
/*
* The terminal type will be left alone if it is present in the
* environment already.
*/
if (fakelogin && (cp = getenv ("TERM")))
addenv("TERM", cp);
if ((cp = getenv ("TERM")))
addenv("TERM", cp);
} else {
while (*envp)
addenv(*envp++, NULL);
}
/*
* The next argument must be either a user ID, or some flag to
@@ -508,8 +500,19 @@ top:
}
#endif /* !USE_PAM */
cp = getdef_str(pwent.pw_uid == 0 ? "ENV_SUPATH" : "ENV_PATH");
cp = getdef_str((pwent.pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
#if 0
addenv(cp ? cp : "PATH=/bin:/usr/bin", NULL);
#else
/* XXX very similar code duplicated in libmisc/setupenv.c */
if (!cp) {
addenv("PATH=/bin:/usr/bin", NULL);
} else if (strchr(cp, '=')) {
addenv(cp, NULL);
} else {
addenv("PATH", cp);
}
#endif
environ = newenvp; /* make new environment active */
@@ -525,7 +528,7 @@ top:
goto top;
}
sulog (tty, 1); /* save SU information */
sulog(tty, 1, oldname, name); /* save SU information */
endpwent ();
#ifdef SHADOWPWD
endspent ();
@@ -593,20 +596,6 @@ top:
* arguments.
*/
if (! doshell) {
/*
* Use new user's shell from /etc/passwd and create an
* argv with the rest of the command line included.
*/
argv[-1] = pwent.pw_shell;
(void) execv (pwent.pw_shell, &argv[-1]);
(void) fprintf (stderr, _("No shell\n"));
SYSLOG((LOG_WARN, "Cannot execute %s\n", pwent.pw_shell));
closelog();
exit (1);
}
if (fakelogin) {
char *arg0;
@@ -627,6 +616,21 @@ top:
} else
cp = Basename(pwent.pw_shell);
if (! doshell) {
/*
* Use new user's shell from /etc/passwd and create an
* argv with the rest of the command line included.
*/
argv[-1] = pwent.pw_shell;
(void) execv (pwent.pw_shell, &argv[-1]);
(void) fprintf (stderr, _("No shell\n"));
SYSLOG((LOG_WARN, "Cannot execute %s\n", pwent.pw_shell));
closelog();
exit (1);
}
shell(pwent.pw_shell, cp);
/*NOTREACHED*/
exit(1);

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: sulogin.c,v 1.10 1999/08/27 19:02:51 marekm Exp $")
RCSID(PKG_VER "$Id: sulogin.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@@ -65,15 +65,13 @@ extern char **newenvp;
extern size_t newenvc;
extern char **environ;
extern char *tz P_((const char *));
#ifndef ALARM
#define ALARM 60
#endif
/* local function prototypes */
static RETSIGTYPE catch P_((int));
int main P_((int, char **));
static RETSIGTYPE catch(int);
static RETSIGTYPE
catch(int sig)
@@ -170,7 +168,7 @@ main(int argc, char **argv)
alarm (ALARM); /* only wait so long ... */
while (1) { /* repeatedly get login/password pairs */
entry (name, &pwent); /* get entry from password file */
pw_entry(name, &pwent); /* get entry from password file */
if (pwent.pw_name == (char *) 0) {
/*

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: useradd.c,v 1.16 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: useradd.c,v 1.17 2000/08/26 18:27:18 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@@ -197,33 +197,32 @@ static int sg_dbm_added;
#endif
/* local function prototypes */
static void fail_exit P_((int));
static struct group *getgr_nam_gid P_((const char *));
static long get_number P_((const char *));
static void get_defaults P_((void));
static void show_defaults P_((void));
static int set_defaults P_((void));
static int get_groups P_((char *));
static void usage P_((void));
static void new_pwent P_((struct passwd *));
static void fail_exit(int);
static struct group *getgr_nam_gid(const char *);
static long get_number(const char *);
static void get_defaults(void);
static void show_defaults(void);
static int set_defaults(void);
static int get_groups(char *);
static void usage(void);
static void new_pwent(struct passwd *);
#ifdef SHADOWPWD
static long scale_age P_((long));
static void new_spent P_((struct spwd *));
static long scale_age(long);
static void new_spent(struct spwd *);
#endif
static void grp_update P_((void));
static void find_new_uid P_((void));
static void grp_update(void);
static void find_new_uid(void);
#ifdef AUTH_METHODS
static void convert_auth P_((char *, const char *));
static int valid_auth P_((const char *));
static void convert_auth(char *, const char *);
static int valid_auth(const char *);
#endif
static void process_flags P_((int argc, char **argv));
static void close_files P_((void));
static void open_files P_((void));
static void faillog_reset P_((uid_t));
static void lastlog_reset P_((uid_t));
static void usr_update P_((void));
static void create_home P_((void));
int main P_((int, char **));
static void process_flags(int argc, char **argv);
static void close_files(void);
static void open_files(void);
static void faillog_reset(uid_t);
static void lastlog_reset(uid_t);
static void usr_update(void);
static void create_home(void);
/*
* fail_exit - undo as much as possible

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: userdel.c,v 1.15 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: userdel.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
#include <sys/stat.h>
#include <stdio.h>
@@ -101,22 +101,21 @@ static int is_shadow_grp;
extern int optind;
/* local function prototypes */
static void usage P_((void));
static void update_groups P_((void));
static void close_files P_((void));
static void fail_exit P_((int));
static void open_files P_((void));
static void update_user P_((void));
static void user_busy P_((const char *, uid_t));
static void user_cancel P_((const char *));
static void usage(void);
static void update_groups(void);
static void close_files(void);
static void fail_exit(int);
static void open_files(void);
static void update_user(void);
static void user_busy(const char *, uid_t);
static void user_cancel(const char *);
#ifdef EXTRA_CHECK_HOME_DIR
static int path_prefix P_((const char *, const char *));
static int path_prefix(const char *, const char *);
#endif
static int is_owner P_((uid_t, const char *));
static int is_owner(uid_t, const char *);
#ifndef NO_REMOVE_MAILBOX
static void remove_mailbox P_((void));
static void remove_mailbox(void);
#endif
int main P_((int, char **));
/*
* usage - display usage message and exit
@@ -134,6 +133,10 @@ usage(void)
*
* update_groups() takes the user name that was given and searches
* the group files for membership in any group.
*
* we also check to see if they have any groups they own (the same
* name is their user name) and delete them too (only if USERGROUPS_ENAB
* is enabled).
*/
static void
@@ -188,9 +191,36 @@ update_groups(void)
SYSLOG((LOG_INFO, "delete `%s' from group `%s'\n",
user_name, ngrp->gr_name));
}
#ifdef NDBM
#ifdef NDBM
endgrent();
#endif
/*
* we've removed their name from all the groups above, so
* now if they have a group with the same name as their
* user name, with no members, we delete it.
*/
grp = getgrnam(user_name);
if (grp && getdef_bool("USERGROUPS_ENAB") && (grp->gr_mem[0] == NULL)) {
gr_remove(grp->gr_name);
/*
* Update the DBM group file with the new entry as well.
*/
#ifdef NDBM
if (!gr_dbm_remove(grp))
fprintf(stderr,
_("%s: cannot remove dbm group entry\n"),
Prog);
#endif
SYSLOG((LOG_INFO, "removed group `%s' owned by `%s'\n",
grp->gr_name, user_name));
}
#ifdef NDBM
endgrent ();
#endif /* NDBM */
#endif
#ifdef SHADOWGRP
if (!is_shadow_grp)
return;

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: usermod.c,v 1.17 1999/06/07 16:40:45 marekm Exp $")
RCSID(PKG_VER "$Id: usermod.c,v 1.18 2000/08/26 18:27:18 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@@ -151,38 +151,37 @@ extern char *optarg;
extern int optind;
/* local function prototypes */
static int get_groups P_((char *));
static void usage P_((void));
static void new_pwent P_((struct passwd *));
static int get_groups(char *);
static void usage(void);
static void new_pwent(struct passwd *);
#ifdef SHADOWPWD
static void new_spent P_((struct spwd *));
static void new_spent(struct spwd *);
#endif
static void fail_exit P_((int));
static int update_group P_((void));
static void fail_exit(int);
static int update_group(void);
#ifdef SHADOWGRP
static int update_gshadow P_((void));
static int update_gshadow(void);
#endif
static int grp_update P_((void));
static int grp_update(void);
#ifdef AUTH_METHODS
static char *get_password P_((const char *));
static void split_auths P_((char *, char **));
static void update_auths P_((const char *, const char *, char *));
static void add_auths P_((const char *, const char *, char *));
static void delete_auths P_((const char *, const char *, char *));
static void convert_auth P_((char *, const char *, const char *));
static int valid_auth P_((const char *));
static char *get_password(const char *);
static void split_auths(char *, char **);
static void update_auths(const char *, const char *, char *);
static void add_auths(const char *, const char *, char *);
static void delete_auths(const char *, const char *, char *);
static void convert_auth(char *, const char *, const char *);
static int valid_auth(const char *);
#endif
static long get_number P_((const char *));
static void process_flags P_((int, char **));
static void close_files P_((void));
static void open_files P_((void));
static void usr_update P_((void));
static void move_home P_((void));
static void update_files P_((void));
static long get_number(const char *);
static void process_flags(int, char **);
static void close_files(void);
static void open_files(void);
static void usr_update(void);
static void move_home(void);
static void update_files(void);
#ifndef NO_MOVE_MAILBOX
static void move_mailbox P_((void));
static void move_mailbox(void);
#endif
int main P_((int, char **));
/* Had to move this over from useradd.c since we have groups named
* "56k-family"... ergh.

View File

@@ -23,7 +23,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: vipw.c,v 1.1 1999/07/09 18:02:43 marekm Exp $")
RCSID(PKG_VER "$Id: vipw.c,v 1.2 2000/08/26 18:27:19 marekm Exp $")
#include "defines.h"
@@ -44,13 +44,12 @@ RCSID(PKG_VER "$Id: vipw.c,v 1.1 1999/07/09 18:02:43 marekm Exp $")
static const char *progname, *filename, *fileeditname;
static int filelocked = 0, createedit = 0;
static int (*unlock)();
static int (*unlock)(void);
/* local function prototypes */
static int create_backup_file P_((FILE *, const char *, struct stat *));
static void vipwexit P_((const char *, int, int));
static void vipwedit P_((const char *, int (*) P_((void)), int (*) P_((void))));
int main P_((int, char **));
static int create_backup_file(FILE *, const char *, struct stat *);
static void vipwexit(const char *, int, int);
static void vipwedit(const char *, int (*)(void), int (*)(void));
static int
create_backup_file(FILE *fp, const char *backup, struct stat *sb)
@@ -109,7 +108,7 @@ vipwexit(const char *msg, int syserr, int ret)
#endif
static void
vipwedit(const char *file, int (*file_lock) P_((void)), int (*file_unlock) P_((void)))
vipwedit(const char *file, int (*file_lock)(void), int (*file_unlock)(void))
{
const char *editor;
pid_t pid;
@@ -143,9 +142,23 @@ vipwedit(const char *file, int (*file_lock) P_((void)), int (*file_unlock) P_((v
if ((pid = fork()) == -1) vipwexit("fork", 1, 1);
else if (!pid) {
#if 0
execlp(editor, editor, fileedit, (char *) 0);
fprintf(stderr, "%s: %s: %s\n", progname, editor, strerror(errno));
exit(1);
#else
/* use the system() call to invoke the editor so that it accepts
command line args in the EDITOR and VISUAL environment vars */
char *buf;
buf = (char *) malloc (strlen(editor) + strlen(fileedit) + 2);
snprintf(buf, strlen(editor) + strlen(fileedit) + 2, "%s %s",
editor, fileedit);
if (system(buf) != 0) {
fprintf(stderr, "%s: %s: %s\n", progname, editor, strerror(errno));
exit(1);
} else
exit(0);
#endif
}
for (;;) {