diff --git a/ChangeLog b/ChangeLog index 5a1bed90..660fc56c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-03-21 Nicolas François + + * libmisc/find_new_gid.c, libmisc/find_new_uid.c: Detect some + misconfigurations of UID_MIN, UID_MAX, SYS_UID_MIN, SYS_UID_MAX (and + the GID equivalents) + 2010-03-20 Nicolas François * NEWS, configure.in: Next version will be 4.1.5. diff --git a/libmisc/find_new_gid.c b/libmisc/find_new_gid.c index 19bc1966..1c08b9b4 100644 --- a/libmisc/find_new_gid.c +++ b/libmisc/find_new_gid.c @@ -60,10 +60,20 @@ int find_new_gid (bool sys_group, if (!sys_group) { gid_min = (gid_t) getdef_ulong ("GID_MIN", 1000UL); gid_max = (gid_t) getdef_ulong ("GID_MAX", 60000UL); + if (gid_max < gid_min) { + (void) fprintf (stderr, + _("%s: Invalid configuration: GID_MIN (%lu), GID_MAX (%lu)\n"), + Prog, (unsigned long) gid_min, (unsigned long) gid_max); + } } else { gid_min = (gid_t) getdef_ulong ("SYS_GID_MIN", 101UL); gid_max = (gid_t) getdef_ulong ("GID_MIN", 1000UL) - 1; gid_max = (gid_t) getdef_ulong ("SYS_GID_MAX", (unsigned long) gid_max); + if (gid_max < gid_min) { + (void) fprintf (stderr, + _("%s: Invalid configuration: SYS_GID_MIN (%lu), GID_MIN (%lu), SYS_GID_MAX (%lu)\n"), + Prog, (unsigned long) gid_min, getdef_ulong ("GID_MIN", 1000UL), (unsigned long) gid_max); + } } used_gids = alloca (sizeof (bool) * (gid_max +1)); memset (used_gids, false, sizeof (bool) * (gid_max + 1)); diff --git a/libmisc/find_new_uid.c b/libmisc/find_new_uid.c index b1a188af..139fe5f8 100644 --- a/libmisc/find_new_uid.c +++ b/libmisc/find_new_uid.c @@ -60,10 +60,20 @@ int find_new_uid (bool sys_user, if (!sys_user) { uid_min = (uid_t) getdef_ulong ("UID_MIN", 1000UL); uid_max = (uid_t) getdef_ulong ("UID_MAX", 60000UL); + if (uid_max < uid_min) { + (void) fprintf (stderr, + _("%s: Invalid configuration: UID_MIN (%lu), UID_MAX (%lu)\n"), + Prog, (unsigned long) uid_min, (unsigned long) uid_max); + } } else { uid_min = (uid_t) getdef_ulong ("SYS_UID_MIN", 101UL); uid_max = (uid_t) getdef_ulong ("UID_MIN", 1000UL) - 1; uid_max = (uid_t) getdef_ulong ("SYS_UID_MAX", (unsigned long) uid_max); + if (uid_max < uid_min) { + (void) fprintf (stderr, + _("%s: Invalid configuration: SYS_UID_MIN (%lu), UID_MIN (%lu), SYS_UID_MAX (%lu)\n"), + Prog, (unsigned long) uid_min, getdef_ulong ("UID_MIN", 1000UL), (unsigned long) uid_max); + } } used_uids = alloca (sizeof (bool) * (uid_max +1)); memset (used_uids, false, sizeof (bool) * (uid_max + 1));