/*
* Global variables
*/
-static int group_locked = 0;
-static int gshadow_locked = 0;
+static bool group_locked = false;
+static bool gshadow_locked = false;
/* local function prototypes */
static void fail_exit (int);
static void fail_exit (int status)
{
- if (group_locked)
+ if (group_locked) {
gr_unlock ();
- if (gshadow_locked)
+ }
+ if (gshadow_locked) {
sgr_unlock ();
+ }
exit (status);
}
struct sgrp sgent;
char *Prog = argv[0];
- setlocale (LC_ALL, "");
- bindtextdomain (PACKAGE, LOCALEDIR);
- textdomain (PACKAGE);
+ (void) setlocale (LC_ALL, "");
+ (void) bindtextdomain (PACKAGE, LOCALEDIR);
+ (void) textdomain (PACKAGE);
- if (!gr_lock ()) {
+ if (gr_lock () == 0) {
fprintf (stderr, _("%s: can't lock group file\n"), Prog);
fail_exit (5);
}
- group_locked++;
- if (!gr_open (O_RDWR)) {
+ group_locked = true;
+ if (gr_open (O_RDWR) == 0) {
fprintf (stderr, _("%s: can't open group file\n"), Prog);
fail_exit (1);
}
- if (!sgr_lock ()) {
+ if (sgr_lock () == 0) {
fprintf (stderr, _("%s: can't lock shadow group file\n"), Prog);
fail_exit (5);
}
- gshadow_locked++;
- if (!sgr_open (O_CREAT | O_RDWR)) {
+ gshadow_locked = true;
+ if (sgr_open (O_CREAT | O_RDWR) == 0) {
fprintf (stderr, _("%s: can't open shadow group file\n"), Prog);
fail_exit (1);
}
* Remove /etc/gshadow entries for groups not in /etc/group.
*/
sgr_rewind ();
- while ((sg = sgr_next ())) {
- if (gr_locate (sg->sg_name))
+ while ((sg = sgr_next ()) != NULL) {
+ if (gr_locate (sg->sg_name) != NULL) {
continue;
+ }
- if (!sgr_remove (sg->sg_name)) {
+ if (sgr_remove (sg->sg_name) == 0) {
/*
* This shouldn't happen (the entry exists) but...
*/
* Add any missing shadow group entries.
*/
gr_rewind ();
- while ((gr = gr_next ())) {
+ while ((gr = gr_next ()) != NULL) {
sg = sgr_locate (gr->gr_name);
- if (sg) {
+ if (NULL != sg) {
/* update existing shadow group entry */
sgent = *sg;
if (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) != 0)
*/
sgent.sg_mem = gr->gr_mem;
- if (!sgr_update (&sgent)) {
+ if (sgr_update (&sgent) == 0) {
fprintf (stderr,
_
("%s: can't update shadow entry for %s\n"),
/* remove password from /etc/group */
grent = *gr;
grent.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
- if (!gr_update (&grent)) {
+ if (gr_update (&grent) == 0) {
fprintf (stderr,
_
("%s: can't update entry for group %s\n"),
}
}
- if (!sgr_close ()) {
+ if (sgr_close () == 0) {
fprintf (stderr, _("%s: can't update shadow group file\n"),
Prog);
fail_exit (3);
}
- if (!gr_close ()) {
+ if (gr_close () == 0) {
fprintf (stderr, _("%s: can't update group file\n"), Prog);
fail_exit (3);
}