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

This commit is contained in:
nekral-guest
2007-10-07 11:44:32 +00:00
parent be1f391d2a
commit d6e9891ad7
41 changed files with 910 additions and 720 deletions

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chage.c,v 1.17 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: chage.c,v 1.18 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -130,6 +130,21 @@ static void print_date(time_t);
static void list_fields(void);
static void cleanup(int);
/*
* isnum - determine whether or not a string is a number
*/
int
isnum(const char *s)
{
while (*s) {
if (!isdigit(*s))
return 0;
s++;
}
return 1;
}
/*
* usage - print command line syntax and exit
*/
@ -390,7 +405,7 @@ main(int argc, char **argv)
Prog = Basename(argv[0]);
openlog("chage", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG("chage");
#ifdef NDBM
#ifdef SHADOWPWD
sp_dbm_mode = O_RDWR;
@ -427,7 +442,7 @@ main(int argc, char **argv)
break;
case 'd':
dflg++;
if (strchr (optarg, '/'))
if (!isnum(optarg))
lastday = strtoday (optarg);
else
lastday = strtol (optarg, 0, 10);
@ -443,7 +458,7 @@ main(int argc, char **argv)
break;
case 'E':
Eflg++;
if (strchr (optarg, '/'))
if (!isnum(optarg))
expdays = strtoday (optarg);
else
expdays = strtol (optarg, 0, 10);

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chfn.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: chfn.c,v 1.17 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -275,13 +275,12 @@ main(int argc, char **argv)
/*
* Get the program name. The program name is used as a
* prefix to most error messages. It is also used as input
* to the openlog() function for error logging.
* prefix to most error messages.
*/
Prog = Basename(argv[0]);
openlog("chfn", LOG_PID, LOG_AUTH);
OPENLOG("chfn");
/*
* The remaining arguments will be processed one by one and

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: chsh.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: chsh.c,v 1.17 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -179,13 +179,12 @@ main(int argc, char **argv)
/*
* Get the program name. The program name is used as a
* prefix to most error messages. It is also used as input
* to the openlog() function for error logging.
* prefix to most error messages.
*/
Prog = Basename(argv[0]);
openlog("chsh", LOG_PID, LOG_AUTH);
OPENLOG("chsh");
/*
* There is only one option, but use getopt() anyway to

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: dpasswd.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: dpasswd.c,v 1.12 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@ -90,7 +90,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
while ((opt = getopt (argc, argv, "a:d:")) != EOF) {
switch (opt) {

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: gpasswd.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: gpasswd.c,v 1.17 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -230,9 +230,9 @@ main(int argc, char **argv)
Prog = Basename(argv[0]);
openlog("gpasswd", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
setbuf (stdout, (char *) 0);
setbuf (stderr, (char *) 0);
OPENLOG("gpasswd");
setbuf(stdout, NULL);
setbuf(stderr, NULL);
#ifdef SHADOWGRP
is_shadowgrp = sgr_file_present();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groupadd.c,v 1.15 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: groupadd.c,v 1.16 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -488,7 +488,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groupdel.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: groupdel.c,v 1.12 2000/09/02 18:40:43 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -279,7 +279,7 @@ main(int argc, char **argv)
group_name = argv[1];
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: groupmod.c,v 1.13 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: groupmod.c,v 1.14 2000/09/02 18:40:44 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -474,7 +474,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: grpck.c,v 1.13 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: grpck.c,v 1.14 2000/09/02 18:40:44 marekm Exp $")
#include <stdio.h>
#include <fcntl.h>
@ -177,7 +177,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
/*
* Parse the command line arguments

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: login.c,v 1.17 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: login.c,v 1.18 2000/09/02 18:40:44 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@ -596,7 +596,7 @@ main(int argc, char **argv)
preauth_flag++;
#endif
openlog("login", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG("login");
setup_tty();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: logoutd.c,v 1.15 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: logoutd.c,v 1.16 2000/09/02 18:40:44 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@ -198,7 +198,7 @@ main(int argc, char **argv)
Prog = Basename(argv[0]);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
/*
* Scan the UTMP file once per minute looking for users that

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: newgrp.c,v 1.15 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: newgrp.c,v 1.16 2000/09/02 18:40:44 marekm Exp $")
#include <stdio.h>
#include <errno.h>
@ -114,7 +114,7 @@ main(int argc, char **argv)
Prog = Basename(argv[0]);
is_newgrp = (strcmp(Prog, "newgrp") == 0);
openlog(is_newgrp ? "newgrp" : "sg", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(is_newgrp ? "newgrp" : "sg");
gid = getgid();
argc--; argv++;

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: passwd.c,v 1.19 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: passwd.c,v 1.20 2000/09/02 18:40:44 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@ -1038,7 +1038,7 @@ main(int argc, char **argv)
sanitize_env();
openlog("passwd", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG("passwd");
/*
* Start with the flags which cause another command to be

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: pwck.c,v 1.14 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: pwck.c,v 1.15 2000/09/02 18:40:44 marekm Exp $")
#include <stdio.h>
#include <fcntl.h>
@ -158,7 +158,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
/*
* Parse the command line arguments

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: su.c,v 1.14 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: su.c,v 1.15 2000/09/02 18:40:44 marekm Exp $")
#include <sys/types.h>
#include <stdio.h>
@ -193,7 +193,7 @@ main(int argc, char **argv)
Prog = Basename(argv[0]);
openlog("su", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG("su");
initenv();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: sulogin.c,v 1.11 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: sulogin.c,v 1.12 2000/09/02 18:40:44 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@ -113,7 +113,7 @@ main(int argc, char **argv)
textdomain(PACKAGE);
#ifdef USE_SYSLOG
openlog ("sulogin", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG("sulogin");
#endif
initenv();
if (argc > 1) {

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: useradd.c,v 1.17 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: useradd.c,v 1.18 2000/09/02 18:40:44 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@ -750,7 +750,7 @@ new_pwent(struct passwd *pwent)
pwent->pw_comment = (char *) "";
#endif
#ifdef BSD_QUOTA
pwent->pw_quota = (char *) "";
pwent->pw_quota = 0;
#endif
pwent->pw_dir = (char *) user_home;
pwent->pw_shell = (char *) user_shell;
@ -1659,7 +1659,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
#ifdef SHADOWPWD
is_shadow_pwd = spw_file_present();
@ -1740,6 +1740,7 @@ main(int argc, char **argv)
}
close_files ();
exit(E_SUCCESS);
/*NOTREACHED*/
}

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: userdel.c,v 1.16 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: userdel.c,v 1.17 2000/09/02 18:40:44 marekm Exp $")
#include <sys/stat.h>
#include <stdio.h>
@ -690,7 +690,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
#ifdef SHADOWPWD
is_shadow_pwd = spw_file_present();

View File

@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID(PKG_VER "$Id: usermod.c,v 1.18 2000/08/26 18:27:18 marekm Exp $")
RCSID(PKG_VER "$Id: usermod.c,v 1.19 2000/09/02 18:40:44 marekm Exp $")
#include <sys/types.h>
#include <sys/stat.h>
@ -114,6 +114,8 @@ static int
fflg = 0, /* days until account with expired password is locked */
eflg = 0, /* days since 1970-01-01 when account becomes expired */
#endif
Lflg = 0, /* lock the password */
Uflg = 0, /* unlock the password */
pflg = 0, /* new encrypted password */
lflg = 0; /* new user name */
@ -320,10 +322,41 @@ usage(void)
#ifdef AUTH_METHODS
fprintf(stderr, _("[-A {DEFAULT|program},... ] "));
#endif
fprintf(stderr, _("[-p passwd] name\n"));
fprintf(stderr, _("[-p passwd] [-L|-U] name\n"));
exit(E_USAGE);
}
/* update encrypted password string (for both shadow and non-shadow passwords) */
static char *
new_pw_passwd(char *pw_pass, const char *pw_name)
{
if (Lflg && pw_pass[0] != '!') {
char *buf = xmalloc(strlen(pw_pass) + 2);
SYSLOG((LOG_INFO, "lock user `%s' password\n",
pw_name));
strcpy(buf, "!");
strcat(buf, pw_pass);
pw_pass = buf;
} else if (Uflg && pw_pass[0] == '!') {
char *s;
SYSLOG((LOG_INFO, "unlock user `%s' password\n",
pw_name));
s = pw_pass;
while (*s) {
*s = *(s + 1);
s++;
}
} else if (pflg) {
SYSLOG((LOG_INFO, "change user `%s' password\n",
pw_name));
pw_pass = xstrdup(user_pass);
}
return pw_pass;
}
/*
* new_pwent - initialize the values in a password file entry
*
@ -339,14 +372,12 @@ new_pwent(struct passwd *pwent)
pwent->pw_name, user_newname));
pwent->pw_name = xstrdup (user_newname);
}
#ifdef SHADOWPWD
if (!is_shadow_pwd)
#endif
if (pflg) {
SYSLOG((LOG_INFO, "change user `%s' password\n",
pwent->pw_name));
pwent->pw_passwd = xstrdup(user_pass);
}
pwent->pw_passwd = new_pw_passwd(pwent->pw_passwd, pwent->pw_name);
if (uflg) {
SYSLOG((LOG_INFO, "change user `%s' UID from `%d' to `%d'\n",
pwent->pw_name, pwent->pw_uid, user_newid));
@ -399,11 +430,7 @@ new_spent(struct spwd *spent)
spent->sp_namp, spent->sp_expire, user_expire));
spent->sp_expire = user_expire;
}
if (pflg) {
SYSLOG((LOG_INFO, "change user `%s' password\n",
spent->sp_namp));
spent->sp_pwdp = xstrdup(user_pass);
}
spent->sp_pwdp = new_pw_passwd(spent->sp_pwdp, spent->sp_namp);
}
#endif /* SHADOWPWD */
@ -1005,9 +1032,9 @@ process_flags(int argc, char **argv)
}
#endif
#ifdef SHADOWPWD
#define FLAGS "A:u:og:G:d:s:c:mf:e:l:p:"
#define FLAGS "A:u:og:G:d:s:c:mf:e:l:p:LU"
#else
#define FLAGS "A:u:og:G:d:s:c:ml:p:"
#define FLAGS "A:u:og:G:d:s:c:ml:p:LU"
#endif
while ((arg = getopt(argc, argv, FLAGS)) != EOF) {
#undef FLAGS
@ -1099,6 +1126,12 @@ process_flags(int argc, char **argv)
user_newname = optarg;
break;
case 'L':
if (Uflg || pflg)
usage ();
Lflg++;
break;
case 'm':
if (! dflg)
usage ();
@ -1112,6 +1145,9 @@ process_flags(int argc, char **argv)
oflg++;
break;
case 'p':
if (Lflg || Uflg)
usage ();
user_pass = optarg;
pflg++;
break;
@ -1129,6 +1165,12 @@ process_flags(int argc, char **argv)
user_newid = get_number(optarg);
uflg++;
break;
case 'U':
if (Lflg && pflg)
usage ();
Uflg++;
break;
default:
usage ();
}
@ -1345,7 +1387,7 @@ usr_update(void)
pwent.pw_passwd = user_auth;
}
#endif /* AUTH_METHODS */
if (lflg || uflg || gflg || cflg || dflg || sflg || Aflg || pflg) {
if (lflg || uflg || gflg || cflg || dflg || sflg || Aflg || pflg || Lflg || Uflg) {
if (! pw_update (&pwent)) {
fprintf(stderr,
_("%s: error changing password entry\n"),
@ -1377,7 +1419,7 @@ usr_update(void)
#endif
}
#ifdef SHADOWPWD
if (spwd && (lflg || eflg || fflg || Aflg || pflg)) {
if (spwd && (lflg || eflg || fflg || Aflg || pflg || Lflg || Uflg)) {
if (! spw_update (&spent)) {
fprintf(stderr,
_("%s: error adding new shadow password entry\n"),
@ -1594,7 +1636,7 @@ main(int argc, char **argv)
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
openlog(Prog, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_AUTH);
OPENLOG(Prog);
#ifdef SHADOWPWD
is_shadow_pwd = spw_file_present();