8c824a0b04
- reduce the reuse of system IDs - speed up sys users look up on LDAP boxes (#511813) - upgrade
85 lines
2.8 KiB
Diff
85 lines
2.8 KiB
Diff
diff -up shadow-4.1.4.1/libmisc/find_new_gid.c.ldap shadow-4.1.4.1/libmisc/find_new_gid.c
|
|
--- shadow-4.1.4.1/libmisc/find_new_gid.c.ldap 2009-07-16 10:37:41.653798746 +0200
|
|
+++ shadow-4.1.4.1/libmisc/find_new_gid.c 2009-07-16 10:44:14.482808945 +0200
|
|
@@ -90,17 +90,26 @@ int find_new_gid (bool sys_group,
|
|
* but we also check the local database (gr_rewind/gr_next) in case
|
|
* some groups were created but the changes were not committed yet.
|
|
*/
|
|
- setgrent ();
|
|
- while ((grp = getgrent ()) != NULL) {
|
|
- if ((grp->gr_gid >= group_id) && (grp->gr_gid <= gid_max)) {
|
|
- group_id = grp->gr_gid + 1;
|
|
+ if (sys_group ) {
|
|
+ for(group_id = gid_min; group_id<=gid_max; group_id++) {
|
|
+ grp = getgrgid(group_id);
|
|
+ if(grp)
|
|
+ used_gids[grp->gr_gid] = true;
|
|
}
|
|
- /* create index of used GIDs */
|
|
- if (grp->gr_gid <= gid_max) {
|
|
- used_gids[grp->gr_gid] = true;
|
|
+ }
|
|
+ else {
|
|
+ setgrent ();
|
|
+ while ((grp = getgrent ()) != NULL) {
|
|
+ if ((grp->gr_gid >= group_id) && (grp->gr_gid <= gid_max)) {
|
|
+ group_id = grp->gr_gid + 1;
|
|
+ }
|
|
+ /* create index of used GIDs */
|
|
+ if (grp->gr_gid <= gid_max) {
|
|
+ used_gids[grp->gr_gid] = true;
|
|
+ }
|
|
}
|
|
+ endgrent ();
|
|
}
|
|
- endgrent ();
|
|
gr_rewind ();
|
|
while ((grp = gr_next ()) != NULL) {
|
|
if ((grp->gr_gid >= group_id) && (grp->gr_gid <= gid_max)) {
|
|
diff -up shadow-4.1.4.1/libmisc/find_new_uid.c.ldap shadow-4.1.4.1/libmisc/find_new_uid.c
|
|
--- shadow-4.1.4.1/libmisc/find_new_uid.c.ldap 2009-07-16 10:37:41.653798746 +0200
|
|
+++ shadow-4.1.4.1/libmisc/find_new_uid.c 2009-07-16 10:37:41.668798323 +0200
|
|
@@ -91,17 +91,27 @@ int find_new_uid (bool sys_user,
|
|
* but we also check the local database (pw_rewind/pw_next) in case
|
|
* some users were created but the changes were not committed yet.
|
|
*/
|
|
- setpwent ();
|
|
- while ((pwd = getpwent ()) != NULL) {
|
|
- if ((pwd->pw_uid >= user_id) && (pwd->pw_uid <= uid_max)) {
|
|
- user_id = pwd->pw_uid + 1;
|
|
+ /* speed up sys users look up on LDAP boxes */
|
|
+ if (sys_user) {
|
|
+ for (user_id = uid_min; user_id<=uid_max; user_id++) {
|
|
+ pwd = getpwuid(user_id);
|
|
+ if(pwd)
|
|
+ used_uids[user_id] = true;
|
|
}
|
|
- /* create index of used UIDs */
|
|
- if (pwd->pw_uid <= uid_max) {
|
|
- used_uids[pwd->pw_uid] = true;
|
|
+ }
|
|
+ else {
|
|
+ setpwent ();
|
|
+ while ((pwd = getpwent ()) != NULL) {
|
|
+ if ((pwd->pw_uid >= user_id) && (pwd->pw_uid <= uid_max)) {
|
|
+ user_id = pwd->pw_uid + 1;
|
|
+ }
|
|
+ /* create index of used UIDs */
|
|
+ if (pwd->pw_uid <= uid_max) {
|
|
+ used_uids[pwd->pw_uid] = true;
|
|
+ }
|
|
}
|
|
+ endpwent ();
|
|
}
|
|
- endpwent ();
|
|
pw_rewind ();
|
|
while ((pwd = pw_next ()) != NULL) {
|
|
if ((pwd->pw_uid >= user_id) && (pwd->pw_uid <= uid_max)) {
|
|
@@ -113,6 +123,7 @@ int find_new_uid (bool sys_user,
|
|
}
|
|
}
|
|
|
|
+
|
|
/* find free system account in reverse order */
|
|
if (sys_user) {
|
|
for (user_id = uid_max; user_id >= uid_min; user_id--) {
|