* src/grpconv.c: Use a bool when possible instead of int integers.
* src/grpconv.c: Add brackets and parenthesis. * src/grpconv.c: Ignore return value of setlocale(), bindtextdomain(), and textdomain(). * src/grpconv.c: Avoid implicit conversion of pointers / integers to booleans.
This commit is contained in:
parent
e31af5f255
commit
cd9e4d1b2b
@ -1,3 +1,12 @@
|
|||||||
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/grpconv.c: Use a bool when possible instead of int integers.
|
||||||
|
* src/grpconv.c: Add brackets and parenthesis.
|
||||||
|
* src/grpconv.c: Ignore return value of setlocale(),
|
||||||
|
bindtextdomain(), and textdomain().
|
||||||
|
* src/grpconv.c: Avoid implicit conversion of pointers / integers
|
||||||
|
to booleans.
|
||||||
|
|
||||||
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/faillog.c: Use a bool when possible instead of int integers.
|
* src/faillog.c: Use a bool when possible instead of int integers.
|
||||||
|
@ -53,18 +53,20 @@
|
|||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
static int group_locked = 0;
|
static bool group_locked = false;
|
||||||
static int gshadow_locked = 0;
|
static bool gshadow_locked = false;
|
||||||
|
|
||||||
/* local function prototypes */
|
/* local function prototypes */
|
||||||
static void fail_exit (int);
|
static void fail_exit (int);
|
||||||
|
|
||||||
static void fail_exit (int status)
|
static void fail_exit (int status)
|
||||||
{
|
{
|
||||||
if (group_locked)
|
if (group_locked) {
|
||||||
gr_unlock ();
|
gr_unlock ();
|
||||||
if (gshadow_locked)
|
}
|
||||||
|
if (gshadow_locked) {
|
||||||
sgr_unlock ();
|
sgr_unlock ();
|
||||||
|
}
|
||||||
exit (status);
|
exit (status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,26 +78,26 @@ int main (int argc, char **argv)
|
|||||||
struct sgrp sgent;
|
struct sgrp sgent;
|
||||||
char *Prog = argv[0];
|
char *Prog = argv[0];
|
||||||
|
|
||||||
setlocale (LC_ALL, "");
|
(void) setlocale (LC_ALL, "");
|
||||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
(void) bindtextdomain (PACKAGE, LOCALEDIR);
|
||||||
textdomain (PACKAGE);
|
(void) textdomain (PACKAGE);
|
||||||
|
|
||||||
if (!gr_lock ()) {
|
if (gr_lock () == 0) {
|
||||||
fprintf (stderr, _("%s: can't lock group file\n"), Prog);
|
fprintf (stderr, _("%s: can't lock group file\n"), Prog);
|
||||||
fail_exit (5);
|
fail_exit (5);
|
||||||
}
|
}
|
||||||
group_locked++;
|
group_locked = true;
|
||||||
if (!gr_open (O_RDWR)) {
|
if (gr_open (O_RDWR) == 0) {
|
||||||
fprintf (stderr, _("%s: can't open group file\n"), Prog);
|
fprintf (stderr, _("%s: can't open group file\n"), Prog);
|
||||||
fail_exit (1);
|
fail_exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sgr_lock ()) {
|
if (sgr_lock () == 0) {
|
||||||
fprintf (stderr, _("%s: can't lock shadow group file\n"), Prog);
|
fprintf (stderr, _("%s: can't lock shadow group file\n"), Prog);
|
||||||
fail_exit (5);
|
fail_exit (5);
|
||||||
}
|
}
|
||||||
gshadow_locked++;
|
gshadow_locked = true;
|
||||||
if (!sgr_open (O_CREAT | O_RDWR)) {
|
if (sgr_open (O_CREAT | O_RDWR) == 0) {
|
||||||
fprintf (stderr, _("%s: can't open shadow group file\n"), Prog);
|
fprintf (stderr, _("%s: can't open shadow group file\n"), Prog);
|
||||||
fail_exit (1);
|
fail_exit (1);
|
||||||
}
|
}
|
||||||
@ -104,11 +106,12 @@ int main (int argc, char **argv)
|
|||||||
* Remove /etc/gshadow entries for groups not in /etc/group.
|
* Remove /etc/gshadow entries for groups not in /etc/group.
|
||||||
*/
|
*/
|
||||||
sgr_rewind ();
|
sgr_rewind ();
|
||||||
while ((sg = sgr_next ())) {
|
while ((sg = sgr_next ()) != NULL) {
|
||||||
if (gr_locate (sg->sg_name))
|
if (gr_locate (sg->sg_name) != NULL) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!sgr_remove (sg->sg_name)) {
|
if (sgr_remove (sg->sg_name) == 0) {
|
||||||
/*
|
/*
|
||||||
* This shouldn't happen (the entry exists) but...
|
* This shouldn't happen (the entry exists) but...
|
||||||
*/
|
*/
|
||||||
@ -124,9 +127,9 @@ int main (int argc, char **argv)
|
|||||||
* Add any missing shadow group entries.
|
* Add any missing shadow group entries.
|
||||||
*/
|
*/
|
||||||
gr_rewind ();
|
gr_rewind ();
|
||||||
while ((gr = gr_next ())) {
|
while ((gr = gr_next ()) != NULL) {
|
||||||
sg = sgr_locate (gr->gr_name);
|
sg = sgr_locate (gr->gr_name);
|
||||||
if (sg) {
|
if (NULL != sg) {
|
||||||
/* update existing shadow group entry */
|
/* update existing shadow group entry */
|
||||||
sgent = *sg;
|
sgent = *sg;
|
||||||
if (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) != 0)
|
if (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) != 0)
|
||||||
@ -148,7 +151,7 @@ int main (int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
sgent.sg_mem = gr->gr_mem;
|
sgent.sg_mem = gr->gr_mem;
|
||||||
|
|
||||||
if (!sgr_update (&sgent)) {
|
if (sgr_update (&sgent) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_
|
||||||
("%s: can't update shadow entry for %s\n"),
|
("%s: can't update shadow entry for %s\n"),
|
||||||
@ -158,7 +161,7 @@ int main (int argc, char **argv)
|
|||||||
/* remove password from /etc/group */
|
/* remove password from /etc/group */
|
||||||
grent = *gr;
|
grent = *gr;
|
||||||
grent.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
|
grent.gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
|
||||||
if (!gr_update (&grent)) {
|
if (gr_update (&grent) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_
|
||||||
("%s: can't update entry for group %s\n"),
|
("%s: can't update entry for group %s\n"),
|
||||||
@ -167,12 +170,12 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sgr_close ()) {
|
if (sgr_close () == 0) {
|
||||||
fprintf (stderr, _("%s: can't update shadow group file\n"),
|
fprintf (stderr, _("%s: can't update shadow group file\n"),
|
||||||
Prog);
|
Prog);
|
||||||
fail_exit (3);
|
fail_exit (3);
|
||||||
}
|
}
|
||||||
if (!gr_close ()) {
|
if (gr_close () == 0) {
|
||||||
fprintf (stderr, _("%s: can't update group file\n"), Prog);
|
fprintf (stderr, _("%s: can't update group file\n"), Prog);
|
||||||
fail_exit (3);
|
fail_exit (3);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user