* src/useradd.c: The ID argument of audit_logger is an unsigned
int. Use AUDIT_NO_ID instead of -1. * src/useradd.c: Cast the parsed GID/UID to a gid_t/uid_t. * src/useradd.c: The size argument of fgets is an int, not a size_t. * src/useradd.c: Cast number of days to a long integer. * src/useradd.c: Use SHADOW_SP_FLAG_UNSET for the initial value of spent.sp_flag. * src/useradd.c: Use a %lu format and cast group and user IDs to unsigned long integers.
This commit is contained in:
parent
73d36f5ece
commit
936bd6a191
13
ChangeLog
13
ChangeLog
@ -1,3 +1,16 @@
|
|||||||
|
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/useradd.c: The ID argument of audit_logger is an unsigned
|
||||||
|
int. Use AUDIT_NO_ID instead of -1.
|
||||||
|
* src/useradd.c: Cast the parsed GID/UID to a gid_t/uid_t.
|
||||||
|
* src/useradd.c: The size argument of fgets is an int, not a
|
||||||
|
size_t.
|
||||||
|
* src/useradd.c: Cast number of days to a long integer.
|
||||||
|
* src/useradd.c: Use SHADOW_SP_FLAG_UNSET for the initial
|
||||||
|
value of spent.sp_flag.
|
||||||
|
* src/useradd.c: Use a %lu format and cast group and user IDs to
|
||||||
|
unsigned long integers.
|
||||||
|
|
||||||
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/su.c: fork() and waitpid() return a pid_t, not an int.
|
* src/su.c: fork() and waitpid() return a pid_t, not an int.
|
||||||
|
@ -213,8 +213,9 @@ static void fail_exit (int code)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user", user_name, -1,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
0);
|
"adding user",
|
||||||
|
user_name, AUDIT_NO_ID, 0);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO, "failed adding user `%s', data deleted", user_name));
|
SYSLOG ((LOG_INFO, "failed adding user `%s', data deleted", user_name));
|
||||||
exit (code);
|
exit (code);
|
||||||
@ -226,8 +227,9 @@ static struct group *getgr_nam_gid (const char *grname)
|
|||||||
char *errptr;
|
char *errptr;
|
||||||
|
|
||||||
gid = strtol (grname, &errptr, 10);
|
gid = strtol (grname, &errptr, 10);
|
||||||
if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && gid >= 0)
|
if (*grname != '\0' && *errptr == '\0' && errno != ERANGE && gid >= 0) {
|
||||||
return xgetgrgid (gid);
|
return xgetgrgid ((gid_t) gid);
|
||||||
|
}
|
||||||
return xgetgrnam (grname);
|
return xgetgrnam (grname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +259,7 @@ static uid_t get_uid (const char *uidstr)
|
|||||||
uidstr);
|
uidstr);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
return val;
|
return (uid_t) val;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MATCH(x,y) (strncmp((x),(y),strlen(y)) == 0)
|
#define MATCH(x,y) (strncmp((x),(y),strlen(y)) == 0)
|
||||||
@ -288,7 +290,7 @@ static void get_defaults (void)
|
|||||||
* Read the file a line at a time. Only the lines that have relevant
|
* Read the file a line at a time. Only the lines that have relevant
|
||||||
* values are used, everything else can be ignored.
|
* values are used, everything else can be ignored.
|
||||||
*/
|
*/
|
||||||
while (fgets (buf, sizeof buf, fp) == buf) {
|
while (fgets (buf, (int) sizeof buf, fp) == buf) {
|
||||||
cp = strrchr (buf, '\n');
|
cp = strrchr (buf, '\n');
|
||||||
if (NULL != cp) {
|
if (NULL != cp) {
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
@ -455,7 +457,7 @@ static int set_defaults (void)
|
|||||||
goto skip;
|
goto skip;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets (buf, sizeof buf, ifp) == buf) {
|
while (fgets (buf, (int) sizeof buf, ifp) == buf) {
|
||||||
cp = strrchr (buf, '\n');
|
cp = strrchr (buf, '\n');
|
||||||
if (NULL != cp) {
|
if (NULL != cp) {
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
@ -541,8 +543,9 @@ static int set_defaults (void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "changing user defaults",
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
NULL, -1, 1);
|
"changing user defaults",
|
||||||
|
NULL, AUDIT_NO_ID, 1);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO,
|
SYSLOG ((LOG_INFO,
|
||||||
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
|
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
|
||||||
@ -731,7 +734,7 @@ static void new_spent (struct spwd *spent)
|
|||||||
memzero (spent, sizeof *spent);
|
memzero (spent, sizeof *spent);
|
||||||
spent->sp_namp = (char *) user_name;
|
spent->sp_namp = (char *) user_name;
|
||||||
spent->sp_pwdp = (char *) user_pass;
|
spent->sp_pwdp = (char *) user_pass;
|
||||||
spent->sp_lstchg = time ((time_t *) 0) / SCALE;
|
spent->sp_lstchg = (long) time ((time_t *) 0) / SCALE;
|
||||||
if (!rflg) {
|
if (!rflg) {
|
||||||
spent->sp_min = scale_age (getdef_num ("PASS_MIN_DAYS", -1));
|
spent->sp_min = scale_age (getdef_num ("PASS_MIN_DAYS", -1));
|
||||||
spent->sp_max = scale_age (getdef_num ("PASS_MAX_DAYS", -1));
|
spent->sp_max = scale_age (getdef_num ("PASS_MAX_DAYS", -1));
|
||||||
@ -745,7 +748,7 @@ static void new_spent (struct spwd *spent)
|
|||||||
spent->sp_inact = scale_age (-1);
|
spent->sp_inact = scale_age (-1);
|
||||||
spent->sp_expire = scale_age (-1);
|
spent->sp_expire = scale_age (-1);
|
||||||
}
|
}
|
||||||
spent->sp_flag = -1;
|
spent->sp_flag = SHADOW_SP_FLAG_UNSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -806,7 +809,8 @@ static void grp_update (void)
|
|||||||
}
|
}
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding user to group", user_name, -1, 1);
|
"adding user to group",
|
||||||
|
user_name, AUDIT_NO_ID, 1);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO, "add `%s' to group `%s'",
|
SYSLOG ((LOG_INFO, "add `%s' to group `%s'",
|
||||||
user_name, ngrp->gr_name));
|
user_name, ngrp->gr_name));
|
||||||
@ -857,7 +861,8 @@ static void grp_update (void)
|
|||||||
}
|
}
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding user to shadow group", user_name, -1, 1);
|
"adding user to shadow group",
|
||||||
|
user_name, AUDIT_NO_ID, 1);
|
||||||
#endif
|
#endif
|
||||||
SYSLOG ((LOG_INFO, "add `%s' to shadow group `%s'",
|
SYSLOG ((LOG_INFO, "add `%s' to shadow group `%s'",
|
||||||
user_name, nsgrp->sg_name));
|
user_name, nsgrp->sg_name));
|
||||||
@ -1152,8 +1157,9 @@ static void process_flags (int argc, char **argv)
|
|||||||
("%s: invalid user name '%s'\n"),
|
("%s: invalid user name '%s'\n"),
|
||||||
Prog, user_name);
|
Prog, user_name);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user",
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
user_name, -1, 0);
|
"adding user",
|
||||||
|
user_name, AUDIT_NO_ID, 0);
|
||||||
#endif
|
#endif
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
@ -1242,7 +1248,8 @@ static void open_files (void)
|
|||||||
fprintf (stderr, _("%s: unable to lock password file\n"), Prog);
|
fprintf (stderr, _("%s: unable to lock password file\n"), Prog);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"locking password file", user_name, user_id, 0);
|
"locking password file",
|
||||||
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
exit (E_PW_UPDATE);
|
exit (E_PW_UPDATE);
|
||||||
}
|
}
|
||||||
@ -1251,7 +1258,8 @@ static void open_files (void)
|
|||||||
fprintf (stderr, _("%s: unable to open password file\n"), Prog);
|
fprintf (stderr, _("%s: unable to open password file\n"), Prog);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"opening password file", user_name, user_id, 0);
|
"opening password file",
|
||||||
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_PW_UPDATE);
|
fail_exit (E_PW_UPDATE);
|
||||||
}
|
}
|
||||||
@ -1262,8 +1270,8 @@ static void open_files (void)
|
|||||||
Prog);
|
Prog);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"locking shadow password file", user_name,
|
"locking shadow password file",
|
||||||
user_id, 0);
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_PW_UPDATE);
|
fail_exit (E_PW_UPDATE);
|
||||||
}
|
}
|
||||||
@ -1274,8 +1282,8 @@ static void open_files (void)
|
|||||||
Prog);
|
Prog);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"opening shadow password file", user_name,
|
"opening shadow password file",
|
||||||
user_id, 0);
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_PW_UPDATE);
|
fail_exit (E_PW_UPDATE);
|
||||||
}
|
}
|
||||||
@ -1477,13 +1485,15 @@ static void usr_update (void)
|
|||||||
Prog);
|
Prog);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding shadow password", user_name, user_id, 0);
|
"adding shadow password",
|
||||||
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_PW_UPDATE);
|
fail_exit (E_PW_UPDATE);
|
||||||
}
|
}
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user", user_name,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
user_id, 1);
|
"adding user",
|
||||||
|
user_name, (unsigned int) user_id, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1512,8 +1522,8 @@ static void create_home (void)
|
|||||||
Prog, user_home);
|
Prog, user_home);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding home directory", user_name,
|
"adding home directory",
|
||||||
user_id, 0);
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_HOMEDIR);
|
fail_exit (E_HOMEDIR);
|
||||||
}
|
}
|
||||||
@ -1523,7 +1533,8 @@ static void create_home (void)
|
|||||||
home_added = true;
|
home_added = true;
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding home directory", user_name, user_id, 1);
|
"adding home directory",
|
||||||
|
user_name, (unsigned int) user_id, 1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1673,8 +1684,9 @@ int main (int argc, char **argv)
|
|||||||
if (getpwnam (user_name) != NULL) { /* local, no need for xgetpwnam */
|
if (getpwnam (user_name) != NULL) { /* local, no need for xgetpwnam */
|
||||||
fprintf (stderr, _("%s: user %s exists\n"), Prog, user_name);
|
fprintf (stderr, _("%s: user %s exists\n"), Prog, user_name);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user",
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
user_name, -1, 0);
|
"adding user",
|
||||||
|
user_name, AUDIT_NO_ID, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_NAME_IN_USE);
|
fail_exit (E_NAME_IN_USE);
|
||||||
}
|
}
|
||||||
@ -1694,7 +1706,8 @@ int main (int argc, char **argv)
|
|||||||
Prog, user_name);
|
Prog, user_name);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
"adding group", user_name, -1, 0);
|
"adding group",
|
||||||
|
user_name, AUDIT_NO_ID, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_NAME_IN_USE);
|
fail_exit (E_NAME_IN_USE);
|
||||||
}
|
}
|
||||||
@ -1722,9 +1735,13 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (getpwuid (user_id) != NULL) {
|
if (getpwuid (user_id) != NULL) {
|
||||||
fprintf (stderr, _("%s: UID %u is not unique\n"), Prog, (unsigned int) user_id);
|
fprintf (stderr,
|
||||||
|
_("%s: UID %lu is not unique\n"),
|
||||||
|
Prog, (unsigned long) user_id);
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding user", user_name, user_id, 0);
|
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
|
||||||
|
"adding user",
|
||||||
|
user_name, (unsigned int) user_id, 0);
|
||||||
#endif
|
#endif
|
||||||
fail_exit (E_UID_IN_USE);
|
fail_exit (E_UID_IN_USE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user