It would appear that the RedHat patch to shadow-utils for the useradd.c always 
performs a gr_lock() in open_files(). However, it will only perform a gr_unlock() if 
the do_group_update flag is set.

This results in a leftover /etc/group.lock file if either the "-g" or the "-n" flag 
are used when calling useradd.

This problem was reported in RedHat's Bugzilla as 21038 in November of 2000.

https://bugzilla.redhat.com/bugzilla/show_bug.cgi ?id=21038

The following is a patch to address the issue, so that gr_unlock is always called when 
close_files() is called. This patch should be used if the RedHat patch is applied 
against shadow-utils.

Devin Heitmueller
Senior Software Engineer
Netilla Networks Inc

--- useradd.c-orig Wed May 15 11:34:09 2002
+++ useradd.c Wed May 15 11:34:28 2002
@@ -1448,24 +1448,23 @@
fail_exit(E_PW_UPDATE);
}
#endif
- if (do_grp_update) {
- if (!gr_close()) {
- fprintf(stderr, _("%s: cannot rewrite group file\n"),
- Prog);
- fail_exit(E_GRP_UPDATE);
- }
- gr_unlock();
+ if (!gr_close()) {
+ fprintf(stderr, _("%s: cannot rewrite group file\n"),
+ Prog);
+ fail_exit(E_GRP_UPDATE);
+ }
+ gr_unlock();
#ifdef SHADOWGRP
- if (is_shadow_grp && !sgr_close()) {
- fprintf (stderr,
- _("%s: cannot rewrite shadow group file\n"),
- Prog);
- fail_exit(E_GRP_UPDATE);
- }
- if (is_shadow_grp)
- sgr_unlock();
-#endif
+ if (is_shadow_grp && !sgr_close()) {
+ fprintf (stderr,
+ _("%s: cannot rewrite shadow group file\n"),
+ Prog);
+ fail_exit(E_GRP_UPDATE);
}
+ if (is_shadow_grp)
+ sgr_unlock();
+#endif
+
#ifdef SHADOWPWD
if (is_shadow_pwd)
spw_unlock(); 



Reply via email to