* src/newusers.c: Fix the check for GID/UID validity.
* src/newusers.c: Comment why we use both getgrgid() and gr_locate_gid(). * src/newusers.c: Cast the parsed GID/UID to a gid_t/uid_t. * src/newusers.c: Cast the number of days to a long integer. * src/newusers.c: Use SHADOW_SP_FLAG_UNSET for the initial value of spent.sp_flag. * src/newusers.c: The size argument of fgets is an int, not a size_t.
This commit is contained in:
parent
906e8c0001
commit
e50ff5c7b5
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
||||
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||
|
||||
* src/newusers.c: Fix the check for GID/UID validity.
|
||||
* src/newusers.c: Comment why we use both getgrgid() and
|
||||
gr_locate_gid().
|
||||
* src/newusers.c: Cast the parsed GID/UID to a gid_t/uid_t.
|
||||
* src/newusers.c: Cast the number of days to a long integer.
|
||||
* src/newusers.c: Use SHADOW_SP_FLAG_UNSET for the initial
|
||||
value of spent.sp_flag.
|
||||
* src/newusers.c: The size argument of fgets is an int, not a
|
||||
size_t.
|
||||
|
||||
2008-06-13 Nicolas François <nicolas.francois@centraliens.net>
|
||||
|
||||
* src/usermod.c: Cast dates to time_t, and number of days to a
|
||||
|
@ -179,21 +179,24 @@ static int add_group (const char *name, const char *gid, gid_t *ngid, uid_t uid)
|
||||
* new group, or an existing group.
|
||||
*/
|
||||
char *endptr;
|
||||
long int i = strtoul (gid, &endptr, 10);
|
||||
if ((*endptr != '\0') && (errno != ERANGE)) {
|
||||
unsigned long int i = strtoul (gid, &endptr, 10);
|
||||
if ((*endptr != '\0') || (ERANGE == errno)) {
|
||||
fprintf (stderr,
|
||||
_("%s: group ID `%s' is not valid\n"),
|
||||
Prog, gid);
|
||||
return -1;
|
||||
}
|
||||
if ( (getgrgid (i) != NULL)
|
||||
|| (gr_locate_gid (i) != NULL)) {
|
||||
/* Look in both the system database (getgrgid) and in the
|
||||
* internal database (gr_locate_gid), which may contain
|
||||
* uncommitted changes */
|
||||
if ( (getgrgid ((gid_t) i) != NULL)
|
||||
|| (gr_locate_gid ((gid_t) i) != NULL)) {
|
||||
/* The user will use this ID for her
|
||||
* primary group */
|
||||
*ngid = i;
|
||||
*ngid = (gid_t) i;
|
||||
return 0;
|
||||
}
|
||||
grent.gr_gid = i;
|
||||
grent.gr_gid = (gid_t) i;
|
||||
} else {
|
||||
/* The gid parameter can be "" or a name which is not
|
||||
* already the name of an existing group.
|
||||
@ -276,14 +279,14 @@ static int get_uid (const char *uid, uid_t *nuid) {
|
||||
*/
|
||||
if (isdigit (uid[0])) {
|
||||
char *endptr;
|
||||
long int i = strtoul (uid, &endptr, 10);
|
||||
if (('\0' != *endptr) && (ERANGE != errno)) {
|
||||
unsigned long int i = strtoul (uid, &endptr, 10);
|
||||
if (('\0' != *endptr) || (ERANGE == errno)) {
|
||||
fprintf (stderr,
|
||||
_("%s: user ID `%s' is not valid\n"),
|
||||
Prog, uid);
|
||||
return -1;
|
||||
}
|
||||
*nuid = i;
|
||||
*nuid = (uid_t) i;
|
||||
} else {
|
||||
if ('\0' != uid[0]) {
|
||||
/* local, no need for xgetpwnam */
|
||||
@ -423,14 +426,14 @@ static int add_passwd (struct passwd *pwd, const char *password)
|
||||
const char *salt = crypt_make_salt (crypt_method, crypt_arg);
|
||||
spent.sp_pwdp = pw_encrypt (password, salt);
|
||||
}
|
||||
spent.sp_lstchg = time ((time_t *) 0) / SCALE;
|
||||
spent.sp_min = getdef_num ("PASS_MIN_DAYS", 0);
|
||||
spent.sp_lstchg = (long) time ((time_t *) 0) / SCALE;
|
||||
spent.sp_min = getdef_num ("PASS_MIN_DAYS", 0);
|
||||
/* 10000 is infinity this week */
|
||||
spent.sp_max = getdef_num ("PASS_MAX_DAYS", 10000);
|
||||
spent.sp_warn = getdef_num ("PASS_WARN_AGE", -1);
|
||||
spent.sp_inact = -1;
|
||||
spent.sp_max = getdef_num ("PASS_MAX_DAYS", 10000);
|
||||
spent.sp_warn = getdef_num ("PASS_WARN_AGE", -1);
|
||||
spent.sp_inact = -1;
|
||||
spent.sp_expire = -1;
|
||||
spent.sp_flag = -1;
|
||||
spent.sp_flag = SHADOW_SP_FLAG_UNSET;
|
||||
|
||||
return (spw_update (&spent) == 0);
|
||||
}
|
||||
@ -699,7 +702,7 @@ int main (int argc, char **argv)
|
||||
* over 100 is allocated. The pw_gid field will be updated with that
|
||||
* value.
|
||||
*/
|
||||
while (fgets (buf, sizeof buf, stdin) != (char *) 0) {
|
||||
while (fgets (buf, (int) sizeof buf, stdin) != (char *) 0) {
|
||||
line++;
|
||||
cp = strrchr (buf, '\n');
|
||||
if (NULL != cp) {
|
||||
|
Loading…
Reference in New Issue
Block a user