[svn-upgrade] Integrating new upstream version, shadow (4.0.16)
This commit is contained in:
@@ -300,6 +300,8 @@ U = @U@
|
||||
USE_NLS = @USE_NLS@
|
||||
USE_NLS_FALSE = @USE_NLS_FALSE@
|
||||
USE_NLS_TRUE = @USE_NLS_TRUE@
|
||||
USE_PAM_FALSE = @USE_PAM_FALSE@
|
||||
USE_PAM_TRUE = @USE_PAM_TRUE@
|
||||
VERSION = @VERSION@
|
||||
XGETTEXT = @XGETTEXT@
|
||||
XMLCATALOG = @XMLCATALOG@
|
||||
|
||||
16
src/chfn.c
16
src/chfn.c
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: chfn.c,v 1.39 2006/02/21 22:44:35 kloczek Exp $"
|
||||
#ident "$Id: chfn.c,v 1.41 2006/05/07 17:44:39 kloczek Exp $"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
@@ -344,14 +344,14 @@ int main (int argc, char **argv)
|
||||
char *nis_master;
|
||||
|
||||
fprintf (stderr,
|
||||
_("%s: cannot change user `%s' on NIS client.\n"),
|
||||
_("%s: cannot change user '%s' on NIS client.\n"),
|
||||
Prog, user);
|
||||
|
||||
if (!yp_get_default_domain (&nis_domain) &&
|
||||
!yp_master (nis_domain, "passwd.byname", &nis_master)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: `%s' is the NIS master for this client.\n"),
|
||||
("%s: '%s' is the NIS master for this client.\n"),
|
||||
Prog, nis_master);
|
||||
}
|
||||
exit (E_NOPERM);
|
||||
@@ -472,31 +472,31 @@ int main (int argc, char **argv)
|
||||
* Check all of the fields for valid information
|
||||
*/
|
||||
if (valid_field (fullnm, ":,=")) {
|
||||
fprintf (stderr, _("%s: invalid name: \"%s\"\n"), Prog, fullnm);
|
||||
fprintf (stderr, _("%s: invalid name: '%s'\n"), Prog, fullnm);
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
if (valid_field (roomno, ":,=")) {
|
||||
fprintf (stderr, _("%s: invalid room number: \"%s\"\n"),
|
||||
fprintf (stderr, _("%s: invalid room number: '%s'\n"),
|
||||
Prog, roomno);
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
if (valid_field (workph, ":,=")) {
|
||||
fprintf (stderr, _("%s: invalid work phone: \"%s\"\n"),
|
||||
fprintf (stderr, _("%s: invalid work phone: '%s'\n"),
|
||||
Prog, workph);
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
if (valid_field (homeph, ":,=")) {
|
||||
fprintf (stderr, _("%s: invalid home phone: \"%s\"\n"),
|
||||
fprintf (stderr, _("%s: invalid home phone: '%s'\n"),
|
||||
Prog, homeph);
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
if (valid_field (slop, ":")) {
|
||||
fprintf (stderr,
|
||||
_("%s: \"%s\" contains illegal characters\n"),
|
||||
_("%s: '%s' contains illegal characters\n"),
|
||||
Prog, slop);
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: chgpasswd.c,v 1.1 2006/03/05 22:12:38 kloczek Exp $"
|
||||
#ident "$Id: chgpasswd.c,v 1.4 2006/05/19 23:47:11 kloczek Exp $"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
@@ -43,7 +43,9 @@
|
||||
#include "nscd.h"
|
||||
#include "prototypes.h"
|
||||
#include "groupio.h"
|
||||
#ifdef SHADOWGRP
|
||||
#include "sgroupio.h"
|
||||
#endif
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
@@ -51,7 +53,9 @@ static char *Prog;
|
||||
static int eflg = 0;
|
||||
static int md5flg = 0;
|
||||
|
||||
static int is_shadow_pwd;
|
||||
#ifdef SHADOWGRP
|
||||
static int is_shadow_grp;
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
static void usage (void);
|
||||
@@ -78,14 +82,14 @@ int main (int argc, char **argv)
|
||||
char *newpwd;
|
||||
char *cp;
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
const struct sgrp *sg;
|
||||
struct sgrp newsg;
|
||||
#endif
|
||||
|
||||
const struct group *gr;
|
||||
struct group newgr;
|
||||
int errors = 0;
|
||||
int line = 0;
|
||||
long now = time ((long *) 0) / (24L * 3600L);
|
||||
int ok;
|
||||
|
||||
#ifdef USE_PAM
|
||||
@@ -93,6 +97,9 @@ int main (int argc, char **argv)
|
||||
struct passwd *pampw;
|
||||
int retval;
|
||||
#endif
|
||||
#ifndef SHADOWGRP
|
||||
struct group newgr;
|
||||
#endif
|
||||
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
@@ -178,9 +185,9 @@ int main (int argc, char **argv)
|
||||
gr_unlock ();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
is_shadow_pwd = sgr_file_present ();
|
||||
if (is_shadow_pwd) {
|
||||
#ifdef SHADOWGRP
|
||||
is_shadow_grp = sgr_file_present ();
|
||||
if (is_shadow_grp) {
|
||||
if (!sgr_lock ()) {
|
||||
fprintf (stderr, _("%s: can't lock gshadow file\n"),
|
||||
Prog);
|
||||
@@ -195,6 +202,7 @@ int main (int argc, char **argv)
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read each line, separating the group name from the password. The
|
||||
@@ -254,33 +262,33 @@ int main (int argc, char **argv)
|
||||
errors++;
|
||||
continue;
|
||||
}
|
||||
if (is_shadow_pwd)
|
||||
sg = sgr_locate (name);
|
||||
else
|
||||
sg = NULL;
|
||||
#ifdef SHADOWGRP
|
||||
sg = sgr_locate (name);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The freshly encrypted new password is merged into the
|
||||
* user's password file entry and the last password change
|
||||
* date is set to the current date.
|
||||
*/
|
||||
if (sg) {
|
||||
newsg = *sg;
|
||||
newsg.sg_passwd = cp;
|
||||
} else {
|
||||
newgr = *gr;
|
||||
newgr.gr_passwd = cp;
|
||||
}
|
||||
#ifdef SHADOWGRP
|
||||
newsg = *sg;
|
||||
newsg.sg_passwd = cp;
|
||||
#else
|
||||
newgr = *gr;
|
||||
newgr.gr_passwd = cp;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The updated password file entry is then put back and will
|
||||
* be written to the password file later, after all the
|
||||
* other entries have been updated as well.
|
||||
*/
|
||||
if (sg)
|
||||
ok = sgr_update (&newsg);
|
||||
else
|
||||
ok = gr_update (&newgr);
|
||||
#ifdef SHADOWGRP
|
||||
ok = sgr_update (&newsg);
|
||||
#else
|
||||
ok = gr_update (&newgr);
|
||||
#endif
|
||||
|
||||
if (!ok) {
|
||||
fprintf (stderr,
|
||||
@@ -302,12 +310,15 @@ int main (int argc, char **argv)
|
||||
if (errors) {
|
||||
fprintf (stderr,
|
||||
_("%s: error detected, changes ignored\n"), Prog);
|
||||
if (is_shadow_pwd)
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow_grp)
|
||||
sgr_unlock ();
|
||||
#endif
|
||||
gr_unlock ();
|
||||
exit (1);
|
||||
}
|
||||
if (is_shadow_pwd) {
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow_grp) {
|
||||
if (!sgr_close ()) {
|
||||
fprintf (stderr,
|
||||
_("%s: error updating shadow file\n"), Prog);
|
||||
@@ -316,6 +327,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
sgr_unlock ();
|
||||
}
|
||||
#endif
|
||||
if (!gr_close ()) {
|
||||
fprintf (stderr, _("%s: error updating password file\n"), Prog);
|
||||
exit (1);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: chsh.c,v 1.39 2006/02/21 22:44:35 kloczek Exp $"
|
||||
#ident "$Id: chsh.c,v 1.40 2006/05/07 17:44:39 kloczek Exp $"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
@@ -256,14 +256,14 @@ int main (int argc, char **argv)
|
||||
char *nis_master;
|
||||
|
||||
fprintf (stderr,
|
||||
_("%s: cannot change user `%s' on NIS client.\n"),
|
||||
_("%s: cannot change user '%s' on NIS client.\n"),
|
||||
Prog, user);
|
||||
|
||||
if (!yp_get_default_domain (&nis_domain) &&
|
||||
!yp_master (nis_domain, "passwd.byname", &nis_master)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: `%s' is the NIS master for this client.\n"),
|
||||
("%s: '%s' is the NIS master for this client.\n"),
|
||||
Prog, nis_master);
|
||||
}
|
||||
exit (1);
|
||||
|
||||
139
src/grpck.c
139
src/grpck.c
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: grpck.c,v 1.29 2006/01/18 19:55:15 kloczek Exp $"
|
||||
#ident "$Id: grpck.c,v 1.32 2006/05/07 17:44:39 kloczek Exp $"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
@@ -137,7 +137,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
int arg;
|
||||
int errors = 0;
|
||||
int deleted = 0;
|
||||
int changed = 0;
|
||||
int i;
|
||||
struct commonio_entry *gre, *tgre;
|
||||
struct group *grp;
|
||||
@@ -290,7 +290,7 @@ int main (int argc, char **argv)
|
||||
* them to delete it.
|
||||
*/
|
||||
printf (_("invalid group file entry\n"));
|
||||
printf (_("delete line `%s'? "), gre->line);
|
||||
printf (_("delete line '%s'? "), gre->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -308,7 +308,7 @@ int main (int argc, char **argv)
|
||||
delete_gr:
|
||||
SYSLOG ((LOG_INFO, "delete group line `%s'",
|
||||
gre->line));
|
||||
deleted++;
|
||||
changed++;
|
||||
|
||||
__gr_del_entry (gre);
|
||||
continue;
|
||||
@@ -346,7 +346,7 @@ int main (int argc, char **argv)
|
||||
* another and ask them to delete it.
|
||||
*/
|
||||
printf (_("duplicate group entry\n"));
|
||||
printf (_("delete line `%s'? "), gre->line);
|
||||
printf (_("delete line '%s'? "), gre->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -361,7 +361,7 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
if (!check_group_name (grp->gr_name)) {
|
||||
errors++;
|
||||
printf (_("invalid group name `%s'\n"), grp->gr_name);
|
||||
printf (_("invalid group name '%s'\n"), grp->gr_name);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -386,18 +386,91 @@ int main (int argc, char **argv)
|
||||
errors++;
|
||||
printf (_("group %s: no user %s\n"),
|
||||
grp->gr_name, grp->gr_mem[i]);
|
||||
printf (_("delete member `%s'? "), grp->gr_mem[i]);
|
||||
printf (_("delete member '%s'? "), grp->gr_mem[i]);
|
||||
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
|
||||
SYSLOG ((LOG_INFO, "delete member `%s' group `%s'",
|
||||
SYSLOG ((LOG_INFO, "delete member '%s' group '%s'",
|
||||
grp->gr_mem[i], grp->gr_name));
|
||||
deleted++;
|
||||
changed++;
|
||||
delete_member (grp->gr_mem, grp->gr_mem[i]);
|
||||
gre->changed = 1;
|
||||
__gr_set_changed ();
|
||||
}
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
/*
|
||||
* Make sure this entry exists in the /etc/gshadow file.
|
||||
*/
|
||||
|
||||
if (is_shadow) {
|
||||
sgr = (struct sgrp *) sgr_locate (grp->gr_name);
|
||||
if (sgr == NULL) {
|
||||
printf (_
|
||||
("no matching group file entry in %s\n"),
|
||||
sgr_file);
|
||||
printf (_("add group '%s' in %s ?"),
|
||||
grp->gr_name, sgr_file);
|
||||
errors++;
|
||||
if (yes_or_no ()) {
|
||||
struct sgrp sg;
|
||||
struct group gr;
|
||||
static char *empty = NULL;
|
||||
|
||||
sg.sg_name = grp->gr_name;
|
||||
sg.sg_passwd = grp->gr_passwd;
|
||||
sg.sg_adm = ∅
|
||||
sg.sg_mem = grp->gr_mem;
|
||||
SYSLOG ((LOG_INFO,
|
||||
"add group `%s' to `%s'",
|
||||
grp->gr_name, sgr_file));
|
||||
changed++;
|
||||
|
||||
if (!sgr_update (&sg)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: can't update shadow entry for %s\n"),
|
||||
Prog, sg.sg_name);
|
||||
exit (E_CANT_UPDATE);
|
||||
}
|
||||
/* remove password from /etc/group */
|
||||
gr = *grp;
|
||||
gr.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
|
||||
if (!gr_update (&gr)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: can't update entry for group %s\n"),
|
||||
Prog, gr.gr_name);
|
||||
exit (E_CANT_UPDATE);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Verify that the all members defined in /etc/group are also
|
||||
* present in /etc/gshadow.
|
||||
*/
|
||||
char **pgrp_mem, **psgr_mem;
|
||||
|
||||
for (pgrp_mem = grp->gr_mem; *pgrp_mem;
|
||||
pgrp_mem++) {
|
||||
for (psgr_mem = sgr->sg_mem; *psgr_mem;
|
||||
psgr_mem++) {
|
||||
if (strcmp
|
||||
(*pgrp_mem, *psgr_mem) == 0)
|
||||
break;
|
||||
}
|
||||
if (*psgr_mem == NULL) {
|
||||
printf
|
||||
("'%s' is a member of the '%s' group in %s but not in %s\n",
|
||||
*pgrp_mem, sgr->sg_name,
|
||||
grp_file, sgr_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
@@ -421,7 +494,7 @@ int main (int argc, char **argv)
|
||||
* them to delete it.
|
||||
*/
|
||||
printf (_("invalid shadow group file entry\n"));
|
||||
printf (_("delete line `%s'? "), sge->line);
|
||||
printf (_("delete line '%s'? "), sge->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -439,7 +512,7 @@ int main (int argc, char **argv)
|
||||
delete_sg:
|
||||
SYSLOG ((LOG_INFO, "delete shadow line `%s'",
|
||||
sge->line));
|
||||
deleted++;
|
||||
changed++;
|
||||
|
||||
__sgr_del_entry (sge);
|
||||
continue;
|
||||
@@ -477,7 +550,7 @@ int main (int argc, char **argv)
|
||||
* another and ask them to delete it.
|
||||
*/
|
||||
printf (_("duplicate shadow group entry\n"));
|
||||
printf (_("delete line `%s'? "), sge->line);
|
||||
printf (_("delete line '%s'? "), sge->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -490,12 +563,34 @@ int main (int argc, char **argv)
|
||||
/*
|
||||
* Make sure this entry exists in the /etc/group file.
|
||||
*/
|
||||
if (!gr_locate (sgr->sg_name)) {
|
||||
printf (_("no matching group file entry\n"));
|
||||
printf (_("delete line `%s'? "), sge->line);
|
||||
grp = (struct group *) gr_locate (sgr->sg_name);
|
||||
if (grp == NULL) {
|
||||
printf (_("no matching group file entry in %s\n"),
|
||||
grp_file);
|
||||
printf (_("delete line '%s'? "), sge->line);
|
||||
errors++;
|
||||
if (yes_or_no ())
|
||||
goto delete_sg;
|
||||
} else {
|
||||
/**
|
||||
* Verify that the all members defined in /etc/gshadow are also
|
||||
* present in /etc/group.
|
||||
*/
|
||||
char **pgrp_mem, **psgr_mem;
|
||||
|
||||
for (psgr_mem = sgr->sg_mem; *psgr_mem; psgr_mem++) {
|
||||
for (pgrp_mem = grp->gr_mem; *pgrp_mem;
|
||||
pgrp_mem++) {
|
||||
if (strcmp (*pgrp_mem, *psgr_mem) == 0)
|
||||
break;
|
||||
}
|
||||
if (*pgrp_mem == NULL) {
|
||||
printf
|
||||
("'%s' is a member of the '%s' group in %s but not in %s\n",
|
||||
*psgr_mem, sgr->sg_name, sgr_file,
|
||||
grp_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -512,7 +607,7 @@ int main (int argc, char **argv)
|
||||
printf (_
|
||||
("shadow group %s: no administrative user %s\n"),
|
||||
sgr->sg_name, sgr->sg_adm[i]);
|
||||
printf (_("delete administrative member `%s'? "),
|
||||
printf (_("delete administrative member '%s'? "),
|
||||
sgr->sg_adm[i]);
|
||||
|
||||
if (!yes_or_no ())
|
||||
@@ -521,7 +616,7 @@ int main (int argc, char **argv)
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete admin `%s' from shadow group `%s'",
|
||||
sgr->sg_adm[i], sgr->sg_name));
|
||||
deleted++;
|
||||
changed++;
|
||||
delete_member (sgr->sg_adm, sgr->sg_adm[i]);
|
||||
sge->changed = 1;
|
||||
__sgr_set_changed ();
|
||||
@@ -540,7 +635,7 @@ int main (int argc, char **argv)
|
||||
errors++;
|
||||
printf (_("shadow group %s: no user %s\n"),
|
||||
sgr->sg_name, sgr->sg_mem[i]);
|
||||
printf (_("delete member `%s'? "), sgr->sg_mem[i]);
|
||||
printf (_("delete member '%s'? "), sgr->sg_mem[i]);
|
||||
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
@@ -548,7 +643,7 @@ int main (int argc, char **argv)
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete member `%s' from shadow group `%s'",
|
||||
sgr->sg_mem[i], sgr->sg_name));
|
||||
deleted++;
|
||||
changed++;
|
||||
delete_member (sgr->sg_mem, sgr->sg_mem[i]);
|
||||
sge->changed = 1;
|
||||
__sgr_set_changed ();
|
||||
@@ -559,10 +654,10 @@ int main (int argc, char **argv)
|
||||
#endif /* SHADOWGRP */
|
||||
|
||||
/*
|
||||
* All done. If there were no deletions we can just abandon any
|
||||
* All done. If there were no change we can just abandon any
|
||||
* changes to the files.
|
||||
*/
|
||||
if (deleted) {
|
||||
if (changed) {
|
||||
write_and_bye:
|
||||
if (!gr_close ()) {
|
||||
fprintf (stderr, _("%s: cannot update file %s\n"),
|
||||
@@ -593,7 +688,7 @@ int main (int argc, char **argv)
|
||||
* Tell the user what we did and exit.
|
||||
*/
|
||||
if (errors)
|
||||
printf (deleted ?
|
||||
printf (changed ?
|
||||
_("%s: the files have been updated\n") :
|
||||
_("%s: no changes\n"), Prog);
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: login.c,v 1.83 2006/03/07 15:47:32 kloczek Exp $"
|
||||
#ident "$Id: login.c,v 1.85 2006/05/07 17:44:39 kloczek Exp $"
|
||||
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
@@ -558,10 +558,10 @@ int main (int argc, char **argv)
|
||||
|
||||
if (*cp)
|
||||
snprintf (fromhost, sizeof fromhost,
|
||||
_(" on `%.100s' from `%.200s'"), tty, cp);
|
||||
_(" on '%.100s' from '%.200s'"), tty, cp);
|
||||
else
|
||||
snprintf (fromhost, sizeof fromhost,
|
||||
_(" on `%.100s'"), tty);
|
||||
_(" on '%.100s'"), tty);
|
||||
|
||||
top:
|
||||
/* only allow ALARM sec. for login */
|
||||
@@ -720,6 +720,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* We don't get here unless they were authenticated above */
|
||||
alarm (0);
|
||||
retcode = pam_acct_mgmt (pamh, 0);
|
||||
|
||||
if (retcode == PAM_NEW_AUTHTOK_REQD) {
|
||||
|
||||
11
src/passwd.c
11
src/passwd.c
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: passwd.c,v 1.57 2006/02/21 22:44:35 kloczek Exp $"
|
||||
#ident "$Id: passwd.c,v 1.58 2006/03/26 19:15:27 kloczek Exp $"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
@@ -50,15 +50,6 @@
|
||||
#include "pwauth.h"
|
||||
#include "pwio.h"
|
||||
#include "shadowio.h"
|
||||
#ifndef GPASSWD_PROGRAM
|
||||
#define GPASSWD_PROGRAM "gpasswd"
|
||||
#endif
|
||||
#ifndef CHFN_PROGRAM
|
||||
#define CHFN_PROGRAM "chfn"
|
||||
#endif
|
||||
#ifndef CHSH_PROGRAM
|
||||
#define CHSH_PROGRAM "chsh"
|
||||
#endif
|
||||
/*
|
||||
* exit status values
|
||||
*/
|
||||
|
||||
89
src/pwck.c
89
src/pwck.c
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: pwck.c,v 1.33 2006/01/18 19:55:15 kloczek Exp $"
|
||||
#ident "$Id: pwck.c,v 1.35 2006/05/07 17:44:39 kloczek Exp $"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
@@ -41,6 +41,7 @@
|
||||
#include "prototypes.h"
|
||||
#include "pwio.h"
|
||||
#include "shadowio.h"
|
||||
#include "getdef.h"
|
||||
#include "nscd.h"
|
||||
extern void __pw_del_entry (const struct commonio_entry *);
|
||||
extern struct commonio_entry *__pw_get_head (void);
|
||||
@@ -116,7 +117,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
int arg;
|
||||
int errors = 0;
|
||||
int deleted = 0;
|
||||
int changed = 0;
|
||||
struct commonio_entry *pfe, *tpfe;
|
||||
struct passwd *pwd;
|
||||
int sort_mode = 0;
|
||||
@@ -254,7 +255,7 @@ int main (int argc, char **argv)
|
||||
* them to delete it.
|
||||
*/
|
||||
printf (_("invalid password file entry\n"));
|
||||
printf (_("delete line `%s'? "), pfe->line);
|
||||
printf (_("delete line '%s'? "), pfe->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -272,7 +273,7 @@ int main (int argc, char **argv)
|
||||
delete_pw:
|
||||
SYSLOG ((LOG_INFO, "delete passwd line `%s'",
|
||||
pfe->line));
|
||||
deleted++;
|
||||
changed++;
|
||||
|
||||
__pw_del_entry (pfe);
|
||||
continue;
|
||||
@@ -309,7 +310,7 @@ int main (int argc, char **argv)
|
||||
* another and ask them to delete it.
|
||||
*/
|
||||
printf (_("duplicate password entry\n"));
|
||||
printf (_("delete line `%s'? "), pfe->line);
|
||||
printf (_("delete line '%s'? "), pfe->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -367,6 +368,60 @@ int main (int argc, char **argv)
|
||||
pwd->pw_name, pwd->pw_shell);
|
||||
errors++;
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
/*
|
||||
* Make sure this entry exists in the /etc/gshadow file.
|
||||
*/
|
||||
|
||||
if (is_shadow) {
|
||||
spw = (struct spwd *) spw_locate (pwd->pw_name);
|
||||
if (spw == NULL) {
|
||||
printf (_
|
||||
("no matching password file entry in %s\n"),
|
||||
spw_file);
|
||||
printf (_("add user '%s' in %s? "),
|
||||
pwd->pw_name, spw_file);
|
||||
errors++;
|
||||
if (yes_or_no ()) {
|
||||
struct spwd sp;
|
||||
struct passwd pw;
|
||||
|
||||
sp.sp_namp = pwd->pw_name;
|
||||
sp.sp_pwdp = pwd->pw_passwd;
|
||||
sp.sp_min =
|
||||
getdef_num ("PASS_MIN_DAYS", -1);
|
||||
sp.sp_max =
|
||||
getdef_num ("PASS_MAX_DAYS", -1);
|
||||
sp.sp_warn =
|
||||
getdef_num ("PASS_WARN_AGE", -1);
|
||||
sp.sp_inact = -1;
|
||||
sp.sp_expire = -1;
|
||||
sp.sp_flag = -1;
|
||||
sp.sp_lstchg =
|
||||
time ((time_t *) 0) / (24L * 3600L);
|
||||
changed++;
|
||||
|
||||
if (!spw_update (&sp)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: can't update shadow entry for %s\n"),
|
||||
Prog, sp.sp_namp);
|
||||
exit (E_CANTUPDATE);
|
||||
}
|
||||
/* remove password from /etc/passwd */
|
||||
pw = *pwd;
|
||||
pw.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
|
||||
if (!pw_update (&pw)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: can't update passwd entry for %s\n"),
|
||||
Prog, pw.pw_name);
|
||||
exit (E_CANTUPDATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!is_shadow)
|
||||
@@ -376,6 +431,13 @@ int main (int argc, char **argv)
|
||||
* Loop through the entire shadow password file.
|
||||
*/
|
||||
for (spe = __spw_get_head (); spe; spe = spe->next) {
|
||||
/*
|
||||
* Do not treat lines which were missing in gshadow
|
||||
* and were added earlier.
|
||||
*/
|
||||
if (spe->line == NULL)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* If this is a NIS line, skip it. You can't "know" what NIS
|
||||
* is going to do without directly asking NIS ...
|
||||
@@ -394,7 +456,7 @@ int main (int argc, char **argv)
|
||||
* them to delete it.
|
||||
*/
|
||||
printf (_("invalid shadow password file entry\n"));
|
||||
printf (_("delete line `%s'? "), spe->line);
|
||||
printf (_("delete line '%s'? "), spe->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -412,7 +474,7 @@ int main (int argc, char **argv)
|
||||
delete_spw:
|
||||
SYSLOG ((LOG_INFO, "delete shadow line `%s'",
|
||||
spe->line));
|
||||
deleted++;
|
||||
changed++;
|
||||
|
||||
__spw_del_entry (spe);
|
||||
continue;
|
||||
@@ -449,7 +511,7 @@ int main (int argc, char **argv)
|
||||
* another and ask them to delete it.
|
||||
*/
|
||||
printf (_("duplicate shadow password entry\n"));
|
||||
printf (_("delete line `%s'? "), spe->line);
|
||||
printf (_("delete line '%s'? "), spe->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -468,8 +530,9 @@ int main (int argc, char **argv)
|
||||
* Tell the user this entry has no matching
|
||||
* /etc/passwd entry and ask them to delete it.
|
||||
*/
|
||||
printf (_("no matching password file entry\n"));
|
||||
printf (_("delete line `%s'? "), spe->line);
|
||||
printf (_("no matching password file entry in %s\n"),
|
||||
pwd_file);
|
||||
printf (_("delete line '%s'? "), spe->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
@@ -493,10 +556,10 @@ int main (int argc, char **argv)
|
||||
shadow_done:
|
||||
|
||||
/*
|
||||
* All done. If there were no deletions we can just abandon any
|
||||
* All done. If there were no change we can just abandon any
|
||||
* changes to the files.
|
||||
*/
|
||||
if (deleted) {
|
||||
if (changed) {
|
||||
write_and_bye:
|
||||
if (!pw_close ()) {
|
||||
fprintf (stderr, _("%s: cannot update file %s\n"),
|
||||
@@ -527,7 +590,7 @@ int main (int argc, char **argv)
|
||||
* Tell the user what we did and exit.
|
||||
*/
|
||||
if (errors)
|
||||
printf (deleted ?
|
||||
printf (changed ?
|
||||
_("%s: the files have been updated\n") :
|
||||
_("%s: no changes\n"), Prog);
|
||||
|
||||
|
||||
10
src/su.c
10
src/su.c
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: su.c,v 1.66 2006/02/08 10:52:49 kloczek Exp $"
|
||||
#ident "$Id: su.c,v 1.70 2006/05/07 17:26:59 kloczek Exp $"
|
||||
|
||||
#include <getopt.h>
|
||||
#include <grp.h>
|
||||
@@ -241,7 +241,9 @@ static void run_shell (const char *shellstr, char *args[], int doshell,
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
exit (WEXITSTATUS (status));
|
||||
exit (WIFEXITED (status)
|
||||
? WEXITSTATUS (status)
|
||||
: WTERMSIG (status) + 128);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -761,7 +763,7 @@ int main (int argc, char **argv)
|
||||
SYSLOG ((LOG_ERR, "pam_open_session: %s",
|
||||
pam_strerror (pamh, ret)));
|
||||
fprintf (stderr, _("%s: %s\n"), Prog, pam_strerror (pamh, ret));
|
||||
pam_setcred(pamh, PAM_DELETE_CRED);
|
||||
pam_setcred (pamh, PAM_DELETE_CRED);
|
||||
pam_end (pamh, ret);
|
||||
exit (1);
|
||||
}
|
||||
@@ -785,7 +787,7 @@ int main (int argc, char **argv)
|
||||
|
||||
/* become the new user */
|
||||
if (change_uid (&pwent)) {
|
||||
pam_close_session(pamh, 0);
|
||||
pam_close_session (pamh, 0);
|
||||
pam_setcred (pamh, PAM_DELETE_CRED);
|
||||
pam_end (pamh, PAM_ABORT);
|
||||
exit (1);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: sulogin.c,v 1.25 2006/02/08 10:53:16 kloczek Exp $"
|
||||
#ident "$Id: sulogin.c,v 1.26 2006/05/12 22:32:14 kloczek Exp $"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
@@ -179,7 +179,9 @@ static RETSIGTYPE catch_signals (int sig)
|
||||
|
||||
/* get a password for root */
|
||||
cp = getpass (_
|
||||
("\nType control-d to proceed with normal startup,\n(or give root password for system maintenance):"));
|
||||
("\n"
|
||||
"Type control-d to proceed with normal startup,\n"
|
||||
"(or give root password for system maintenance):"));
|
||||
/*
|
||||
* XXX - can't enter single user mode if root password is
|
||||
* empty. I think this doesn't happen very often :-). But
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: useradd.c,v 1.92 2006/03/07 15:47:33 kloczek Exp $"
|
||||
#ident "$Id: useradd.c,v 1.96 2006/05/30 18:28:45 kloczek Exp $"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@@ -219,7 +219,7 @@ static long get_number (const char *cp)
|
||||
if (*cp != '\0' && *ep == '\0') /* valid number */
|
||||
return val;
|
||||
|
||||
fprintf (stderr, _("%s: invalid numeric argument `%s'\n"), Prog, cp);
|
||||
fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, cp);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ static uid_t get_uid (const char *cp)
|
||||
if (*cp != '\0' && *ep == '\0') /* valid number */
|
||||
return val;
|
||||
|
||||
fprintf (stderr, _("%s: invalid numeric argument `%s'\n"), Prog, cp);
|
||||
fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, cp);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
|
||||
@@ -572,7 +572,7 @@ static int get_groups (char *list)
|
||||
*/
|
||||
if (__isgrNIS ()) {
|
||||
fprintf (stderr,
|
||||
_("%s: group `%s' is a NIS group.\n"),
|
||||
_("%s: group '%s' is a NIS group.\n"),
|
||||
Prog, grp->gr_name);
|
||||
continue;
|
||||
}
|
||||
@@ -1027,7 +1027,7 @@ static void process_flags (int argc, char **argv)
|
||||
|| optarg[0] != '/') {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid base directory `%s'\n"),
|
||||
("%s: invalid base directory '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1038,7 +1038,7 @@ static void process_flags (int argc, char **argv)
|
||||
if (!VALID (optarg)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid comment `%s'\n"),
|
||||
("%s: invalid comment '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1050,7 +1050,7 @@ static void process_flags (int argc, char **argv)
|
||||
|| optarg[0] != '/') {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid home directory `%s'\n"),
|
||||
("%s: invalid home directory '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@ static void process_flags (int argc, char **argv)
|
||||
if (user_expire == -1) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid date `%s'\n"),
|
||||
("%s: invalid date '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1163,7 +1163,7 @@ static void process_flags (int argc, char **argv)
|
||||
if (!VALID (optarg)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid field `%s'\n"),
|
||||
("%s: invalid field '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ static void process_flags (int argc, char **argv)
|
||||
&& optarg[0] != '*'))) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid shell `%s'\n"),
|
||||
("%s: invalid shell '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1585,46 +1585,38 @@ static void create_home (void)
|
||||
*/
|
||||
static void create_mail (void)
|
||||
{
|
||||
char *ms;
|
||||
char *spool, *file;
|
||||
int fd;
|
||||
struct group *mail;
|
||||
gid_t mail_gid;
|
||||
struct group *gr;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
|
||||
if (strcasecmp (create_mail_spool, "yes") == 0) {
|
||||
mail = getgrnam ("mail");
|
||||
if (mail == NULL) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("No group named \"mail\" exists, creating mail spool with mode 0600.\n"));
|
||||
mode = 0600;
|
||||
mail_gid = user_gid;
|
||||
} else {
|
||||
mode = 0660;
|
||||
mail_gid = mail->gr_gid;
|
||||
}
|
||||
spool = getdef_str ("MAIL_DIR") ? : "/var/mail";
|
||||
file = alloca (strlen (spool) + strlen (user_name) + 2);
|
||||
sprintf (file, "%s/%s", spool, user_name);
|
||||
fd = open (file, O_CREAT | O_WRONLY | O_TRUNC | O_EXCL, 0);
|
||||
if (fd < 0) {
|
||||
perror (_("Creating mailbox file"));
|
||||
return;
|
||||
|
||||
ms = malloc (strlen (user_name) + 11);
|
||||
if (ms != NULL) {
|
||||
sprintf (ms, "/var/mail/%s", user_name);
|
||||
if (access (ms, R_OK) != 0) {
|
||||
fd = open (ms,
|
||||
O_CREAT | O_EXCL |
|
||||
O_WRONLY | O_TRUNC, 0);
|
||||
if (fd != -1) {
|
||||
fchown (fd, user_id, mail_gid);
|
||||
fchmod (fd, mode);
|
||||
close (fd);
|
||||
}
|
||||
} else {
|
||||
gr = getgrnam ("mail");
|
||||
if (!gr) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Can't create mail spool for user %s.\n"),
|
||||
user_name);
|
||||
fail_exit (E_MAIL_SPOOL);
|
||||
("Group 'mail' not found. Creating the user mailbox file with 0600 mode.\n"));
|
||||
gid = user_gid;
|
||||
mode = 0600;
|
||||
} else {
|
||||
gid = gr->gr_gid;
|
||||
mode = 0660;
|
||||
}
|
||||
|
||||
if (fchown (fd, user_id, gid) || fchmod (fd, mode))
|
||||
perror (_("Setting mailbox file permissions"));
|
||||
|
||||
close (fd);
|
||||
}
|
||||
free (ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,10 +29,11 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: userdel.c,v 1.61 2006/02/07 20:19:46 kloczek Exp $"
|
||||
#ident "$Id: userdel.c,v 1.64 2006/05/12 23:37:33 kloczek Exp $"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
@@ -98,7 +99,12 @@ static void remove_mailbox (void);
|
||||
*/
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("Usage: %s [-r] name\n"), Prog);
|
||||
fprintf (stderr, _("Usage: userdel [options] LOGIN\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -f, --force force removal of files, even if not owned by user\n"
|
||||
" -h, --help display this help message and exit\n"
|
||||
" -r, --remove remove home directory and mail spool\n"));
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
@@ -591,7 +597,6 @@ static void remove_mailbox (void)
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
int arg;
|
||||
int errors = 0;
|
||||
|
||||
#ifdef USE_PAM
|
||||
@@ -612,16 +617,30 @@ int main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
while ((arg = getopt (argc, argv, "fr")) != EOF) {
|
||||
switch (arg) {
|
||||
case 'f': /* force remove even if not owned by user */
|
||||
fflg++;
|
||||
break;
|
||||
case 'r': /* remove home dir and mailbox */
|
||||
rflg++;
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
{
|
||||
/*
|
||||
* Parse the command line options.
|
||||
*/
|
||||
int c;
|
||||
static struct option long_options[] = {
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
{"remove", no_argument, NULL, 'r'},
|
||||
{NULL, 0, NULL, '\0'}
|
||||
};
|
||||
while ((c =
|
||||
getopt_long (argc, argv, "fhr",
|
||||
long_options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case 'f': /* force remove even if not owned by user */
|
||||
fflg++;
|
||||
break;
|
||||
case 'r': /* remove home dir and mailbox */
|
||||
rflg++;
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ident "$Id: usermod.c,v 1.65 2006/01/18 19:55:15 kloczek Exp $"
|
||||
#ident "$Id: usermod.c,v 1.66 2006/05/07 17:44:39 kloczek Exp $"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
@@ -237,7 +237,7 @@ static int get_groups (char *list)
|
||||
*/
|
||||
if (__isgrNIS ()) {
|
||||
fprintf (stderr,
|
||||
_("%s: group `%s' is a NIS group.\n"),
|
||||
_("%s: group '%s' is a NIS group.\n"),
|
||||
Prog, grp->gr_name);
|
||||
continue;
|
||||
}
|
||||
@@ -811,7 +811,7 @@ static long get_number (const char *cp)
|
||||
if (*cp != '\0' && *ep == '\0') /* valid number */
|
||||
return val;
|
||||
|
||||
fprintf (stderr, _("%s: invalid numeric argument `%s'\n"), Prog, cp);
|
||||
fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, cp);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
|
||||
@@ -824,7 +824,7 @@ static uid_t get_id (const char *cp)
|
||||
if (*cp != '\0' && *ep == '\0') /* valid number */
|
||||
return val;
|
||||
|
||||
fprintf (stderr, _("%s: invalid numeric argument `%s'\n"), Prog, cp);
|
||||
fprintf (stderr, _("%s: invalid numeric argument '%s'\n"), Prog, cp);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
|
||||
@@ -930,7 +930,7 @@ static void process_flags (int argc, char **argv)
|
||||
case 'c':
|
||||
if (!VALID (optarg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid field `%s'\n"),
|
||||
_("%s: invalid field '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -944,7 +944,7 @@ static void process_flags (int argc, char **argv)
|
||||
case 'd':
|
||||
if (!VALID (optarg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid field `%s'\n"),
|
||||
_("%s: invalid field '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -962,7 +962,7 @@ static void process_flags (int argc, char **argv)
|
||||
#endif
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: invalid date `%s'\n"),
|
||||
("%s: invalid date '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1006,7 +1006,7 @@ static void process_flags (int argc, char **argv)
|
||||
case 'l':
|
||||
if (!check_user_name (optarg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid field `%s'\n"),
|
||||
_("%s: invalid field '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
@@ -1049,7 +1049,7 @@ static void process_flags (int argc, char **argv)
|
||||
case 's':
|
||||
if (!VALID (optarg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid field `%s'\n"),
|
||||
_("%s: invalid field '%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user