[svn-upgrade] Integrating new upstream version, shadow (4.0.1)
This commit is contained in:
377
src/grpck.c
377
src/grpck.c
@ -17,7 +17,7 @@
|
||||
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
@ -30,27 +30,23 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID(PKG_VER "$Id: grpck.c,v 1.16 2001/08/18 09:28:16 malekith Exp $")
|
||||
|
||||
RCSID (PKG_VER "$Id: grpck.c,v 1.20 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "chkname.h"
|
||||
#include <pwd.h>
|
||||
|
||||
#include "commonio.h"
|
||||
|
||||
#include "groupio.h"
|
||||
extern void __gr_del_entry(const struct commonio_entry *);
|
||||
extern struct commonio_entry *__gr_get_head(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(const struct commonio_entry *);
|
||||
extern struct commonio_entry *__sgr_get_head(void);
|
||||
extern void __sgr_del_entry (const struct commonio_entry *);
|
||||
extern struct commonio_entry *__sgr_get_head (void);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -64,59 +60,52 @@ extern struct commonio_entry *__sgr_get_head(void);
|
||||
#define E_CANT_LOCK 4
|
||||
#define E_CANT_UPDATE 5
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
/*
|
||||
* Local variables
|
||||
*/
|
||||
|
||||
static char *Prog;
|
||||
static const char *grp_file = GROUP_FILE;
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
static const char *sgr_file = SGROUP_FILE;
|
||||
#endif
|
||||
static int read_only = 0;
|
||||
|
||||
/* local function prototypes */
|
||||
static void usage(void);
|
||||
static int yes_or_no(void);
|
||||
static void delete_member(char **, const char *);
|
||||
static void usage (void);
|
||||
static int yes_or_no (void);
|
||||
static void delete_member (char **, const char *);
|
||||
|
||||
/*
|
||||
* usage - print syntax message and exit
|
||||
*/
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
static void usage (void)
|
||||
{
|
||||
#ifdef SHADOWGRP
|
||||
fprintf(stderr, _("Usage: %s [ -sr ] [ group [ gshadow ] ]\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-r] [-s] [group [gshadow]]\n"),
|
||||
Prog);
|
||||
#else
|
||||
fprintf(stderr, _("Usage: %s [ -sr ] [ group ]\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-r] [-s] [group]\n"), Prog);
|
||||
#endif
|
||||
exit(E_USAGE);
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
/*
|
||||
* yes_or_no - get answer to question from the user
|
||||
*/
|
||||
|
||||
static int
|
||||
yes_or_no(void)
|
||||
static int yes_or_no (void)
|
||||
{
|
||||
char buf[80];
|
||||
char buf[80];
|
||||
|
||||
/*
|
||||
* In read-only mode all questions are answered "no".
|
||||
*/
|
||||
|
||||
if (read_only) {
|
||||
puts(_("No"));
|
||||
puts (_("No"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -124,7 +113,7 @@ yes_or_no(void)
|
||||
* Get a line and see what the first character is.
|
||||
*/
|
||||
|
||||
if (fgets(buf, sizeof buf, stdin))
|
||||
if (fgets (buf, sizeof buf, stdin))
|
||||
return buf[0] == 'y' || buf[0] == 'Y';
|
||||
|
||||
return 0;
|
||||
@ -134,8 +123,7 @@ yes_or_no(void)
|
||||
* delete_member - delete an entry in a list of members
|
||||
*/
|
||||
|
||||
static void
|
||||
delete_member(char **list, const char *member)
|
||||
static void delete_member (char **list, const char *member)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -152,19 +140,19 @@ delete_member(char **list, const char *member)
|
||||
* grpck - verify group file integrity
|
||||
*/
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int arg;
|
||||
int errors = 0;
|
||||
int deleted = 0;
|
||||
int i;
|
||||
struct commonio_entry *gre, *tgre;
|
||||
struct group *grp;
|
||||
int sort_mode = 0;
|
||||
int arg;
|
||||
int errors = 0;
|
||||
int deleted = 0;
|
||||
int i;
|
||||
struct commonio_entry *gre, *tgre;
|
||||
struct group *grp;
|
||||
int sort_mode = 0;
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
struct commonio_entry *sge, *tsge;
|
||||
struct sgrp *sgr;
|
||||
struct commonio_entry *sge, *tsge;
|
||||
struct sgrp *sgr;
|
||||
int is_shadow = 0;
|
||||
#endif
|
||||
|
||||
@ -172,19 +160,19 @@ main(int argc, char **argv)
|
||||
* Get my name so that I can use it to report errors.
|
||||
*/
|
||||
|
||||
Prog = Basename(argv[0]);
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
OPENLOG(Prog);
|
||||
OPENLOG (Prog);
|
||||
|
||||
/*
|
||||
* Parse the command line arguments
|
||||
*/
|
||||
|
||||
while ((arg = getopt(argc, argv, "qrs")) != EOF) {
|
||||
while ((arg = getopt (argc, argv, "qrs")) != EOF) {
|
||||
switch (arg) {
|
||||
case 'q':
|
||||
/* quiet - ignored for now */
|
||||
@ -196,16 +184,16 @@ main(int argc, char **argv)
|
||||
sort_mode = 1;
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
usage ();
|
||||
}
|
||||
}
|
||||
|
||||
if (sort_mode && read_only) {
|
||||
fprintf(stderr, _("%s: -s and -r are incompatibile\n"),
|
||||
Prog);
|
||||
exit(E_USAGE);
|
||||
fprintf (stderr, _("%s: -s and -r are incompatibile\n"),
|
||||
Prog);
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Make certain we have the right number of arguments
|
||||
*/
|
||||
@ -215,24 +203,24 @@ main(int argc, char **argv)
|
||||
#else
|
||||
if (optind != argc && optind + 1 != argc)
|
||||
#endif
|
||||
usage();
|
||||
usage ();
|
||||
|
||||
/*
|
||||
* If there are two left over filenames, use those as the
|
||||
* group and group password filenames.
|
||||
* If there are two left over filenames, use those as the group and
|
||||
* group password filenames.
|
||||
*/
|
||||
|
||||
if (optind != argc) {
|
||||
grp_file = argv[optind];
|
||||
gr_name(grp_file);
|
||||
gr_name (grp_file);
|
||||
}
|
||||
#ifdef SHADOWGRP
|
||||
if (optind + 2 == argc) {
|
||||
sgr_file = argv[optind + 1];
|
||||
sgr_name(sgr_file);
|
||||
sgr_name (sgr_file);
|
||||
is_shadow = 1;
|
||||
} else if (optind == argc)
|
||||
is_shadow = sgr_file_present();
|
||||
is_shadow = sgr_file_present ();
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -240,51 +228,57 @@ main(int argc, char **argv)
|
||||
*/
|
||||
|
||||
if (!read_only) {
|
||||
if (!gr_lock()) {
|
||||
fprintf(stderr, _("%s: cannot lock file %s\n"), Prog, grp_file);
|
||||
if (!gr_lock ()) {
|
||||
fprintf (stderr, _("%s: cannot lock file %s\n"),
|
||||
Prog, grp_file);
|
||||
if (optind == argc)
|
||||
SYSLOG((LOG_WARN,"cannot lock %s\n",grp_file));
|
||||
closelog();
|
||||
exit(E_CANT_LOCK);
|
||||
SYSLOG ((LOG_WARN, "cannot lock %s",
|
||||
grp_file));
|
||||
closelog ();
|
||||
exit (E_CANT_LOCK);
|
||||
}
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow && !sgr_lock()) {
|
||||
fprintf(stderr, _("%s: cannot lock file %s\n"), Prog, sgr_file);
|
||||
if (is_shadow && !sgr_lock ()) {
|
||||
fprintf (stderr, _("%s: cannot lock file %s\n"),
|
||||
Prog, sgr_file);
|
||||
if (optind == argc)
|
||||
SYSLOG((LOG_WARN,"cannot lock %s\n",sgr_file));
|
||||
closelog();
|
||||
exit(E_CANT_LOCK);
|
||||
SYSLOG ((LOG_WARN, "cannot lock %s",
|
||||
sgr_file));
|
||||
closelog ();
|
||||
exit (E_CANT_LOCK);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Open the files. Use O_RDONLY if we are in read_only mode,
|
||||
* Open the files. Use O_RDONLY if we are in read_only mode,
|
||||
* O_RDWR otherwise.
|
||||
*/
|
||||
|
||||
if (!gr_open(read_only ? O_RDONLY : O_RDWR)) {
|
||||
fprintf(stderr, _("%s: cannot open file %s\n"), Prog, grp_file);
|
||||
if (!gr_open (read_only ? O_RDONLY : O_RDWR)) {
|
||||
fprintf (stderr, _("%s: cannot open file %s\n"), Prog,
|
||||
grp_file);
|
||||
if (optind == argc)
|
||||
SYSLOG((LOG_WARN, "cannot open %s\n", grp_file));
|
||||
closelog();
|
||||
exit(E_CANT_OPEN);
|
||||
SYSLOG ((LOG_WARN, "cannot open %s", grp_file));
|
||||
closelog ();
|
||||
exit (E_CANT_OPEN);
|
||||
}
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow && !sgr_open(read_only ? O_RDONLY : O_RDWR)) {
|
||||
fprintf(stderr, _("%s: cannot open file %s\n"), Prog, sgr_file);
|
||||
if (is_shadow && !sgr_open (read_only ? O_RDONLY : O_RDWR)) {
|
||||
fprintf (stderr, _("%s: cannot open file %s\n"), Prog,
|
||||
sgr_file);
|
||||
if (optind == argc)
|
||||
SYSLOG((LOG_WARN, "cannot open %s\n", sgr_file));
|
||||
closelog();
|
||||
exit(E_CANT_OPEN);
|
||||
SYSLOG ((LOG_WARN, "cannot open %s", sgr_file));
|
||||
closelog ();
|
||||
exit (E_CANT_OPEN);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sort_mode) {
|
||||
gr_sort();
|
||||
gr_sort ();
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow)
|
||||
sgr_sort();
|
||||
sgr_sort ();
|
||||
#endif
|
||||
goto write_and_bye;
|
||||
}
|
||||
@ -293,7 +287,7 @@ main(int argc, char **argv)
|
||||
* Loop through the entire group file.
|
||||
*/
|
||||
|
||||
for (gre = __gr_get_head(); gre; gre = gre->next) {
|
||||
for (gre = __gr_get_head (); gre; gre = gre->next) {
|
||||
/*
|
||||
* Skip all NIS entries.
|
||||
*/
|
||||
@ -302,42 +296,42 @@ main(int argc, char **argv)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Start with the entries that are completely corrupt.
|
||||
* They have no (struct group) entry because they couldn't
|
||||
* be parsed properly.
|
||||
* Start with the entries that are completely corrupt. They
|
||||
* have no (struct group) entry because they couldn't be
|
||||
* parsed properly.
|
||||
*/
|
||||
|
||||
if (!gre->eptr) {
|
||||
|
||||
/*
|
||||
* Tell the user this entire line is bogus and
|
||||
* ask them to delete it.
|
||||
* Tell the user this entire line is bogus and ask
|
||||
* them to delete it.
|
||||
*/
|
||||
|
||||
printf(_("invalid group file entry\n"));
|
||||
printf(_("delete line `%s'? "), gre->line);
|
||||
printf (_("invalid group file entry\n"));
|
||||
printf (_("delete line `%s'? "), gre->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
* prompt the user to delete the entry or not
|
||||
*/
|
||||
|
||||
if (!yes_or_no())
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
|
||||
/*
|
||||
* All group file deletions wind up here. This
|
||||
* code removes the current entry from the linked
|
||||
* list. When done, it skips back to the top of
|
||||
* the loop to try out the next list element.
|
||||
* All group file deletions wind up here. This code
|
||||
* removes the current entry from the linked list.
|
||||
* When done, it skips back to the top of the loop
|
||||
* to try out the next list element.
|
||||
*/
|
||||
|
||||
delete_gr:
|
||||
SYSLOG((LOG_INFO, "delete group line `%s'\n",
|
||||
gre->line));
|
||||
delete_gr:
|
||||
SYSLOG ((LOG_INFO, "delete group line `%s'",
|
||||
gre->line));
|
||||
deleted++;
|
||||
|
||||
__gr_del_entry(gre);
|
||||
__gr_del_entry (gre);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -351,7 +345,7 @@ delete_gr:
|
||||
* Make sure this entry has a unique name.
|
||||
*/
|
||||
|
||||
for (tgre = __gr_get_head(); tgre; tgre = tgre->next) {
|
||||
for (tgre = __gr_get_head (); tgre; tgre = tgre->next) {
|
||||
|
||||
const struct group *ent = tgre->eptr;
|
||||
|
||||
@ -369,7 +363,7 @@ delete_gr:
|
||||
if (!ent)
|
||||
continue;
|
||||
|
||||
if (strcmp(grp->gr_name, ent->gr_name) != 0)
|
||||
if (strcmp (grp->gr_name, ent->gr_name) != 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@ -377,44 +371,35 @@ delete_gr:
|
||||
* another and ask them to delete it.
|
||||
*/
|
||||
|
||||
puts(_("duplicate group entry\n"));
|
||||
printf(_("delete line `%s'? "), gre->line);
|
||||
puts (_("duplicate group entry\n"));
|
||||
printf (_("delete line `%s'? "), gre->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
* prompt the user to delete the entry or not
|
||||
*/
|
||||
|
||||
if (yes_or_no())
|
||||
if (yes_or_no ())
|
||||
goto delete_gr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for invalid group names. --marekm
|
||||
*/
|
||||
if (!check_group_name(grp->gr_name)) {
|
||||
if (!check_group_name (grp->gr_name)) {
|
||||
errors++;
|
||||
printf(_("invalid group name `%s'\n"), grp->gr_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for a Slackware bug. Make sure GID is not -1
|
||||
* (it has special meaning for some syscalls). --marekm
|
||||
*/
|
||||
|
||||
if (grp->gr_gid == (gid_t) -1) {
|
||||
errors++;
|
||||
printf(_("group %s: bad GID (%d)\n"),
|
||||
grp->gr_name, (int) grp->gr_gid);
|
||||
printf (_("invalid group name `%s'\n"),
|
||||
grp->gr_name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Workaround for a NYS libc 5.3.12 bug on RedHat 4.2 -
|
||||
* groups with no members are returned as groups with
|
||||
* one member "", causing grpck to fail. --marekm
|
||||
* groups with no members are returned as groups with one
|
||||
* member "", causing grpck to fail. --marekm
|
||||
*/
|
||||
|
||||
if (grp->gr_mem[0] && !grp->gr_mem[1] && *(grp->gr_mem[0]) == '\0')
|
||||
if (grp->gr_mem[0] && !grp->gr_mem[1]
|
||||
&& *(grp->gr_mem[0]) == '\0')
|
||||
grp->gr_mem[0] = (char *) 0;
|
||||
|
||||
/*
|
||||
@ -422,27 +407,27 @@ delete_gr:
|
||||
*/
|
||||
|
||||
for (i = 0; grp->gr_mem[i]; i++) {
|
||||
if (getpwnam(grp->gr_mem[i]))
|
||||
if (getpwnam (grp->gr_mem[i]))
|
||||
continue;
|
||||
/*
|
||||
* Can't find this user. Remove them
|
||||
* Can't find this user. Remove them
|
||||
* from the list.
|
||||
*/
|
||||
|
||||
errors++;
|
||||
printf(_("group %s: no user %s\n"),
|
||||
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())
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
|
||||
SYSLOG((LOG_INFO, "delete member `%s' group `%s'\n",
|
||||
grp->gr_mem[i], grp->gr_name));
|
||||
SYSLOG ((LOG_INFO, "delete member `%s' group `%s'",
|
||||
grp->gr_mem[i], grp->gr_name));
|
||||
deleted++;
|
||||
delete_member(grp->gr_mem, grp->gr_mem[i]);
|
||||
delete_member (grp->gr_mem, grp->gr_mem[i]);
|
||||
gre->changed = 1;
|
||||
__gr_set_changed();
|
||||
__gr_set_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,45 +439,45 @@ delete_gr:
|
||||
* Loop through the entire shadow group file.
|
||||
*/
|
||||
|
||||
for (sge = __sgr_get_head(); sge; sge = sge->next) {
|
||||
for (sge = __sgr_get_head (); sge; sge = sge->next) {
|
||||
|
||||
/*
|
||||
* Start with the entries that are completely corrupt.
|
||||
* They have no (struct sgrp) entry because they couldn't
|
||||
* be parsed properly.
|
||||
* Start with the entries that are completely corrupt. They
|
||||
* have no (struct sgrp) entry because they couldn't be
|
||||
* parsed properly.
|
||||
*/
|
||||
|
||||
if (!sge->eptr) {
|
||||
|
||||
/*
|
||||
* Tell the user this entire line is bogus and
|
||||
* ask them to delete it.
|
||||
* Tell the user this entire line is bogus and ask
|
||||
* them to delete it.
|
||||
*/
|
||||
|
||||
printf(_("invalid shadow group file entry\n"));
|
||||
printf(_("delete line `%s'? "), sge->line);
|
||||
printf (_("invalid shadow group file entry\n"));
|
||||
printf (_("delete line `%s'? "), sge->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
* prompt the user to delete the entry or not
|
||||
*/
|
||||
|
||||
if (!yes_or_no())
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
|
||||
/*
|
||||
* All shadow group file deletions wind up here.
|
||||
* All shadow group file deletions wind up here.
|
||||
* This code removes the current entry from the
|
||||
* linked list. When done, it skips back to the
|
||||
* top of the loop to try out the next list element.
|
||||
* linked list. When done, it skips back to the top
|
||||
* of the loop to try out the next list element.
|
||||
*/
|
||||
|
||||
delete_sg:
|
||||
SYSLOG((LOG_INFO, "delete shadow line `%s'\n",
|
||||
sge->line));
|
||||
delete_sg:
|
||||
SYSLOG ((LOG_INFO, "delete shadow line `%s'",
|
||||
sge->line));
|
||||
deleted++;
|
||||
|
||||
__sgr_del_entry(sge);
|
||||
__sgr_del_entry (sge);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -506,7 +491,7 @@ delete_sg:
|
||||
* Make sure this entry has a unique name.
|
||||
*/
|
||||
|
||||
for (tsge = __sgr_get_head(); tsge; tsge = tsge->next) {
|
||||
for (tsge = __sgr_get_head (); tsge; tsge = tsge->next) {
|
||||
|
||||
const struct sgrp *ent = tsge->eptr;
|
||||
|
||||
@ -524,7 +509,7 @@ delete_sg:
|
||||
if (!ent)
|
||||
continue;
|
||||
|
||||
if (strcmp(sgr->sg_name, ent->sg_name) != 0)
|
||||
if (strcmp (sgr->sg_name, ent->sg_name) != 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@ -532,15 +517,15 @@ delete_sg:
|
||||
* another and ask them to delete it.
|
||||
*/
|
||||
|
||||
puts(_("duplicate shadow group entry\n"));
|
||||
printf(_("delete line `%s'? "), sge->line);
|
||||
puts (_("duplicate shadow group entry\n"));
|
||||
printf (_("delete line `%s'? "), sge->line);
|
||||
errors++;
|
||||
|
||||
/*
|
||||
* prompt the user to delete the entry or not
|
||||
*/
|
||||
|
||||
if (yes_or_no())
|
||||
if (yes_or_no ())
|
||||
goto delete_sg;
|
||||
}
|
||||
|
||||
@ -548,11 +533,11 @@ delete_sg:
|
||||
* Make sure this entry exists in the /etc/group file.
|
||||
*/
|
||||
|
||||
if (!gr_locate(sgr->sg_name)) {
|
||||
puts(_("no matching group file entry\n"));
|
||||
printf(_("delete line `%s'? "), sge->line);
|
||||
if (!gr_locate (sgr->sg_name)) {
|
||||
puts (_("no matching group file entry\n"));
|
||||
printf (_("delete line `%s'? "), sge->line);
|
||||
errors++;
|
||||
if (yes_or_no())
|
||||
if (yes_or_no ())
|
||||
goto delete_sg;
|
||||
}
|
||||
|
||||
@ -561,28 +546,30 @@ delete_sg:
|
||||
*/
|
||||
|
||||
for (i = 0; sgr->sg_adm[i]; i++) {
|
||||
if (getpwnam(sgr->sg_adm[i]))
|
||||
if (getpwnam (sgr->sg_adm[i]))
|
||||
continue;
|
||||
/*
|
||||
* Can't find this user. Remove them
|
||||
* Can't find this user. Remove them
|
||||
* from the list.
|
||||
*/
|
||||
|
||||
errors++;
|
||||
printf(_("shadow group %s: no administrative user %s\n"),
|
||||
printf (_
|
||||
("shadow group %s: no administrative user %s\n"),
|
||||
sgr->sg_name, sgr->sg_adm[i]);
|
||||
printf(_("delete administrative member `%s'? "), sgr->sg_adm[i]);
|
||||
printf (_("delete administrative member `%s'? "),
|
||||
sgr->sg_adm[i]);
|
||||
|
||||
if (!yes_or_no())
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
|
||||
SYSLOG((LOG_INFO,
|
||||
"delete admin `%s' from shadow group `%s'\n",
|
||||
sgr->sg_adm[i], sgr->sg_name));
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete admin `%s' from shadow group `%s'",
|
||||
sgr->sg_adm[i], sgr->sg_name));
|
||||
deleted++;
|
||||
delete_member(sgr->sg_adm, sgr->sg_adm[i]);
|
||||
delete_member (sgr->sg_adm, sgr->sg_adm[i]);
|
||||
sge->changed = 1;
|
||||
__sgr_set_changed();
|
||||
__sgr_set_changed ();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -590,52 +577,51 @@ delete_sg:
|
||||
*/
|
||||
|
||||
for (i = 0; sgr->sg_mem[i]; i++) {
|
||||
if (getpwnam(sgr->sg_mem[i]))
|
||||
if (getpwnam (sgr->sg_mem[i]))
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Can't find this user. Remove them
|
||||
* from the list.
|
||||
* Can't find this user. Remove them from the list.
|
||||
*/
|
||||
|
||||
errors++;
|
||||
printf(_("shadow group %s: no user %s\n"),
|
||||
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())
|
||||
if (!yes_or_no ())
|
||||
continue;
|
||||
|
||||
SYSLOG((LOG_INFO,
|
||||
"delete member `%s' from shadow group `%s'\n",
|
||||
sgr->sg_mem[i], sgr->sg_name));
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete member `%s' from shadow group `%s'",
|
||||
sgr->sg_mem[i], sgr->sg_name));
|
||||
deleted++;
|
||||
delete_member(sgr->sg_mem, sgr->sg_mem[i]);
|
||||
delete_member (sgr->sg_mem, sgr->sg_mem[i]);
|
||||
sge->changed = 1;
|
||||
__sgr_set_changed();
|
||||
__sgr_set_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
shadow_done:
|
||||
#endif /* SHADOWGRP */
|
||||
shadow_done:
|
||||
#endif /* SHADOWGRP */
|
||||
|
||||
/*
|
||||
* All done. If there were no deletions we can just abandon any
|
||||
* All done. If there were no deletions we can just abandon any
|
||||
* changes to the files.
|
||||
*/
|
||||
|
||||
if (deleted) {
|
||||
write_and_bye:
|
||||
if (!gr_close()) {
|
||||
fprintf(stderr, _("%s: cannot update file %s\n"),
|
||||
Prog, grp_file);
|
||||
exit(E_CANT_UPDATE);
|
||||
write_and_bye:
|
||||
if (!gr_close ()) {
|
||||
fprintf (stderr, _("%s: cannot update file %s\n"),
|
||||
Prog, grp_file);
|
||||
exit (E_CANT_UPDATE);
|
||||
}
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow && !sgr_close()) {
|
||||
fprintf(stderr, _("%s: cannot update file %s\n"),
|
||||
Prog, sgr_file);
|
||||
exit(E_CANT_UPDATE);
|
||||
if (is_shadow && !sgr_close ()) {
|
||||
fprintf (stderr, _("%s: cannot update file %s\n"),
|
||||
Prog, sgr_file);
|
||||
exit (E_CANT_UPDATE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -646,9 +632,9 @@ write_and_bye:
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow)
|
||||
sgr_unlock();
|
||||
sgr_unlock ();
|
||||
#endif
|
||||
(void) gr_unlock();
|
||||
(void) gr_unlock ();
|
||||
|
||||
/*
|
||||
* Tell the user what we did and exit.
|
||||
@ -656,14 +642,15 @@ write_and_bye:
|
||||
|
||||
if (errors)
|
||||
#ifdef NDBM
|
||||
printf(deleted ?
|
||||
_("%s: the files have been updated; run mkpasswd\n") :
|
||||
_("%s: no changes\n"), Prog);
|
||||
printf (deleted ?
|
||||
_
|
||||
("%s: the files have been updated; run mkpasswd\n")
|
||||
: _("%s: no changes\n"), Prog);
|
||||
#else
|
||||
printf(deleted ?
|
||||
printf (deleted ?
|
||||
_("%s: the files have been updated\n") :
|
||||
_("%s: no changes\n"), Prog);
|
||||
#endif
|
||||
|
||||
exit(errors ? E_BAD_ENTRY : E_OKAY);
|
||||
exit (errors ? E_BAD_ENTRY : E_OKAY);
|
||||
}
|
||||
|
Reference in New Issue
Block a user