[Pkg-shadow-commits] r2152 - in upstream/trunk: . src
nekral-guest at alioth.debian.org
nekral-guest at alioth.debian.org
Fri Jun 13 20:56:44 UTC 2008
Author: nekral-guest
Date: 2008-06-13 20:56:44 +0000 (Fri, 13 Jun 2008)
New Revision: 2152
Modified:
upstream/trunk/ChangeLog
upstream/trunk/src/newusers.c
Log:
* 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.
Modified: upstream/trunk/ChangeLog
===================================================================
--- upstream/trunk/ChangeLog 2008-06-13 20:40:04 UTC (rev 2151)
+++ upstream/trunk/ChangeLog 2008-06-13 20:56:44 UTC (rev 2152)
@@ -1,5 +1,17 @@
2008-06-13 Nicolas François <nicolas.francois at 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 at centraliens.net>
+
* src/usermod.c: Cast dates to time_t, and number of days to a
long integer.
* src/usermod.c: Cast UIDs and GIDs to uid_t and gid_t after
Modified: upstream/trunk/src/newusers.c
===================================================================
--- upstream/trunk/src/newusers.c 2008-06-13 20:40:04 UTC (rev 2151)
+++ upstream/trunk/src/newusers.c 2008-06-13 20:56:44 UTC (rev 2152)
@@ -179,21 +179,24 @@
* 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 @@
*/
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 @@
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 @@
* 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) {
More information about the Pkg-shadow-commits
mailing list