* src/groupmems.c: Really use booleans.
* src/groupmems.c: Change isroot() to a macro that returns a boolean.
This commit is contained in:
parent
a363e1c51f
commit
6f571dbfc6
@ -1,3 +1,9 @@
|
|||||||
|
2008-07-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/groupmems.c: Really use booleans.
|
||||||
|
* src/groupmems.c: Change isroot() to a macro that returns a
|
||||||
|
boolean.
|
||||||
|
|
||||||
2008-07-26 Nicolas François <nicolas.francois@centraliens.net>
|
2008-07-26 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* lib/defines.h: Make sure the booleans are defined before using
|
* lib/defines.h: Make sure the booleans are defined before using
|
||||||
|
@ -57,24 +57,18 @@
|
|||||||
#define EXIT_INVALID_USER 8 /* specified user does not exist */
|
#define EXIT_INVALID_USER 8 /* specified user does not exist */
|
||||||
#define EXIT_INVALID_GROUP 9 /* specified group does not exist */
|
#define EXIT_INVALID_GROUP 9 /* specified group does not exist */
|
||||||
|
|
||||||
#define TRUE 1
|
|
||||||
#define FALSE 0
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
*/
|
*/
|
||||||
static char *adduser = NULL;
|
static char *adduser = NULL;
|
||||||
static char *deluser = NULL;
|
static char *deluser = NULL;
|
||||||
static char *thisgroup = NULL;
|
static char *thisgroup = NULL;
|
||||||
static int purge = FALSE;
|
static bool purge = false;
|
||||||
static int list = FALSE;
|
static bool list = false;
|
||||||
static int exclusive = 0;
|
static int exclusive = 0;
|
||||||
static char *Prog;
|
static char *Prog;
|
||||||
|
|
||||||
static int isroot (void)
|
#define isroot () (getuid () == 0)
|
||||||
{
|
|
||||||
return getuid ()? FALSE : TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int isgroup (void)
|
static int isgroup (void)
|
||||||
{
|
{
|
||||||
@ -117,12 +111,12 @@ static void addtogroup (char *user, char **members)
|
|||||||
static void rmfromgroup (char *user, char **members)
|
static void rmfromgroup (char *user, char **members)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int found = FALSE;
|
bool found = false;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while (!found && NULL != members[i]) {
|
while (!found && NULL != members[i]) {
|
||||||
if (0 == strcmp (user, members[i])) {
|
if (0 == strcmp (user, members[i])) {
|
||||||
found = TRUE;
|
found = true;
|
||||||
} else {
|
} else {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -212,14 +206,14 @@ int main (int argc, char **argv)
|
|||||||
++exclusive;
|
++exclusive;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
purge = TRUE;
|
purge = true;
|
||||||
++exclusive;
|
++exclusive;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
thisgroup = strdup (optarg);
|
thisgroup = strdup (optarg);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
list = TRUE;
|
list = true;
|
||||||
++exclusive;
|
++exclusive;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -231,6 +225,7 @@ int main (int argc, char **argv)
|
|||||||
usage ();
|
usage ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* local, no need for xgetpwnam */
|
||||||
if (getpwnam(adduser) == NULL) {
|
if (getpwnam(adduser) == NULL) {
|
||||||
fprintf (stderr, _("%s: user `%s' does not exist\n")
|
fprintf (stderr, _("%s: user `%s' does not exist\n")
|
||||||
Prog, adduser);
|
Prog, adduser);
|
||||||
|
Loading…
Reference in New Issue
Block a user