fix infinitive loop if there are duplicate entries in /etc/group (#240915)
This commit is contained in:
parent
9744679f21
commit
b061ab3bdf
2 changed files with 185 additions and 1 deletions
178
shadow-4.0.18.1-groupLoop.patch
Normal file
178
shadow-4.0.18.1-groupLoop.patch
Normal file
|
@ -0,0 +1,178 @@
|
||||||
|
--- shadow-4.0.18.1/src/usermod.c.groupLoop 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/src/usermod.c 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -628,7 +628,7 @@
|
||||||
|
continue;
|
||||||
|
|
||||||
|
changed = 0;
|
||||||
|
- if (!gr_update (ngrp)) {
|
||||||
|
+ if (!gr_update_entry (grp, ngrp)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: error adding new group entry\n"), Prog);
|
||||||
|
SYSLOG ((LOG_ERR, "error adding group entry"));
|
||||||
|
@@ -770,7 +770,7 @@
|
||||||
|
/*
|
||||||
|
* Update the group entry to reflect the changes.
|
||||||
|
*/
|
||||||
|
- if (!sgr_update (nsgrp)) {
|
||||||
|
+ if (!sgr_update_entry (sgrp, nsgrp)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: error adding new group entry\n"), Prog);
|
||||||
|
SYSLOG ((LOG_ERR, "error adding shadow group entry"));
|
||||||
|
--- shadow-4.0.18.1/src/userdel.c.groupLoop 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/src/userdel.c 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -153,7 +153,7 @@
|
||||||
|
exit (13); /* XXX */
|
||||||
|
}
|
||||||
|
ngrp->gr_mem = del_list (ngrp->gr_mem, user_name);
|
||||||
|
- if (!gr_update (ngrp))
|
||||||
|
+ if (!gr_update_entry (grp, ngrp))
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: error updating group entry\n"), Prog);
|
||||||
|
|
||||||
|
@@ -252,7 +252,7 @@
|
||||||
|
if (was_admin)
|
||||||
|
nsgrp->sg_adm = del_list (nsgrp->sg_adm, user_name);
|
||||||
|
|
||||||
|
- if (!sgr_update (nsgrp))
|
||||||
|
+ if (!sgr_update_entry (sgrp, nsgrp))
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: error updating group entry\n"), Prog);
|
||||||
|
#ifdef WITH_AUDIT
|
||||||
|
--- shadow-4.0.18.1/src/useradd.c.groupLoop 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/src/useradd.c 2007-05-25 11:54:28.000000000 +0200
|
||||||
|
@@ -727,30 +727,6 @@
|
||||||
|
struct sgrp *nsgrp;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * Test for unique entries of user_groups in /etc/group
|
||||||
|
- * pvrabec@redhat.com
|
||||||
|
- */
|
||||||
|
- char **user_groups_tmp = user_groups;
|
||||||
|
-
|
||||||
|
- while (*user_groups_tmp) {
|
||||||
|
- int count = 0;
|
||||||
|
-
|
||||||
|
- for (gr_rewind (), grp = gr_next (); grp && count < 2;
|
||||||
|
- grp = gr_next ()) {
|
||||||
|
- if (strcmp (*user_groups_tmp, grp->gr_name) == 0) {
|
||||||
|
- count++;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- if (count > 1) {
|
||||||
|
- fprintf (stderr,
|
||||||
|
- "%s: error not unique group names in group file\n",
|
||||||
|
- Prog);
|
||||||
|
- fail_exit (E_GRP_UPDATE);
|
||||||
|
- }
|
||||||
|
- user_groups_tmp++;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
/* Locking and opening of the group files moved to open_files() --gafton */
|
||||||
|
|
||||||
|
/*
|
||||||
|
@@ -780,7 +756,7 @@
|
||||||
|
* update the group entry to reflect the change.
|
||||||
|
*/
|
||||||
|
ngrp->gr_mem = add_list (ngrp->gr_mem, user_name);
|
||||||
|
- if (!gr_update (ngrp)) {
|
||||||
|
+ if (!gr_update_entry (grp, ngrp)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: error adding new group entry\n"), Prog);
|
||||||
|
fail_exit (E_GRP_UPDATE);
|
||||||
|
@@ -828,7 +804,7 @@
|
||||||
|
* update the group entry to reflect the change.
|
||||||
|
*/
|
||||||
|
nsgrp->sg_mem = add_list (nsgrp->sg_mem, user_name);
|
||||||
|
- if (!sgr_update (nsgrp)) {
|
||||||
|
+ if (!sgr_update_entry (sgrp, nsgrp)) {
|
||||||
|
fprintf (stderr,
|
||||||
|
_("%s: error adding new group entry\n"), Prog);
|
||||||
|
fail_exit (E_GRP_UPDATE);
|
||||||
|
--- shadow-4.0.18.1/lib/sgroupio.c.groupLoop 2005-08-31 19:24:56.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/lib/sgroupio.c 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -146,6 +146,13 @@
|
||||||
|
return commonio_update (&gshadow_db, (const void *) sg);
|
||||||
|
}
|
||||||
|
|
||||||
|
+int sgr_update_entry(const struct sgrp *oldgr, const struct sgrp *newgr)
|
||||||
|
+{
|
||||||
|
+ return commonio_update_entry(&gshadow_db, (const void *) oldgr,
|
||||||
|
+ (const void *) newgr);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
int sgr_remove (const char *name)
|
||||||
|
{
|
||||||
|
return commonio_remove (&gshadow_db, name);
|
||||||
|
--- shadow-4.0.18.1/lib/groupio.c.groupLoop 2005-08-31 19:24:56.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/lib/groupio.c 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -128,6 +128,12 @@
|
||||||
|
return commonio_remove (&group_db, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
+int gr_update_entry(const struct group *oldgr, const struct group *newgr)
|
||||||
|
+{
|
||||||
|
+ return commonio_update_entry(&group_db, (const void *) oldgr,
|
||||||
|
+ (const void *) newgr);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
int gr_rewind (void)
|
||||||
|
{
|
||||||
|
return commonio_rewind (&group_db);
|
||||||
|
--- shadow-4.0.18.1/lib/sgroupio.h.groupLoop 2005-03-31 07:14:49.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/lib/sgroupio.h 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -11,4 +11,5 @@
|
||||||
|
extern int sgr_rewind (void);
|
||||||
|
extern int sgr_unlock (void);
|
||||||
|
extern int sgr_update (const struct sgrp *);
|
||||||
|
+extern int sgr_update_entry(const struct sgrp *oldgr, const struct sgrp *newgr);
|
||||||
|
extern int sgr_sort (void);
|
||||||
|
--- shadow-4.0.18.1/lib/commonio.c.groupLoop 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/lib/commonio.c 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -826,6 +826,36 @@
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int commonio_update_entry(struct commonio_db *db, const void *oldgr,
|
||||||
|
+ const void *newgr)
|
||||||
|
+{
|
||||||
|
+ struct commonio_entry *tmp;
|
||||||
|
+
|
||||||
|
+ if (!db->isopen || db->readonly) {
|
||||||
|
+ errno = EINVAL;
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ tmp = db->head;
|
||||||
|
+ while (tmp != NULL) {
|
||||||
|
+ if (oldgr == tmp->eptr)
|
||||||
|
+ break;
|
||||||
|
+ tmp = tmp->next;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Didn't find this in the database; hop out */
|
||||||
|
+ if (tmp == NULL)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ tmp->eptr = db->ops->dup(newgr);
|
||||||
|
+ if (tmp->eptr == NULL)
|
||||||
|
+ return 1;
|
||||||
|
+ tmp->changed = 1;
|
||||||
|
+
|
||||||
|
+ db->changed = 1;
|
||||||
|
+
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
|
||||||
|
void commonio_del_entry (struct commonio_db *db, const struct commonio_entry *p)
|
||||||
|
{
|
||||||
|
--- shadow-4.0.18.1/lib/groupio.h.groupLoop 2005-03-31 07:14:49.000000000 +0200
|
||||||
|
+++ shadow-4.0.18.1/lib/groupio.h 2007-05-25 11:51:33.000000000 +0200
|
||||||
|
@@ -10,4 +10,6 @@
|
||||||
|
extern int gr_rewind (void);
|
||||||
|
extern int gr_unlock (void);
|
||||||
|
extern int gr_update (const struct group *);
|
||||||
|
+extern int gr_update_entry(const struct group *oldgr, const struct group *newgr);
|
||||||
|
extern int gr_sort (void);
|
||||||
|
+
|
|
@ -5,7 +5,7 @@
|
||||||
Summary: Utilities for managing accounts and shadow password files
|
Summary: Utilities for managing accounts and shadow password files
|
||||||
Name: shadow-utils
|
Name: shadow-utils
|
||||||
Version: 4.0.18.1
|
Version: 4.0.18.1
|
||||||
Release: 14%{?dist}
|
Release: 15%{?dist}
|
||||||
Epoch: 2
|
Epoch: 2
|
||||||
URL: http://shadow.pld.org.pl/
|
URL: http://shadow.pld.org.pl/
|
||||||
Source0: ftp://ftp.pld.org.pl/software/shadow/shadow-%{version}.tar.bz2
|
Source0: ftp://ftp.pld.org.pl/software/shadow/shadow-%{version}.tar.bz2
|
||||||
|
@ -27,6 +27,7 @@ Patch11: shadow-4.0.17-useradd.patch
|
||||||
Patch12: shadow-4.0.18.1-appendOption.patch
|
Patch12: shadow-4.0.18.1-appendOption.patch
|
||||||
Patch13: shadow-4.0.18.1-sysAccount.patch
|
Patch13: shadow-4.0.18.1-sysAccount.patch
|
||||||
Patch14: shadow-4.0.18.1-findNewUidOnce.patch
|
Patch14: shadow-4.0.18.1-findNewUidOnce.patch
|
||||||
|
Patch15: shadow-4.0.18.1-groupLoop.patch
|
||||||
License: BSD
|
License: BSD
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
BuildRequires: autoconf, automake, libtool, gettext-devel
|
BuildRequires: autoconf, automake, libtool, gettext-devel
|
||||||
|
@ -69,6 +70,7 @@ cp %{SOURCE3} lib/nscd.c
|
||||||
%patch12 -p1 -b .appendOption
|
%patch12 -p1 -b .appendOption
|
||||||
%patch13 -p1 -b .sysAccount
|
%patch13 -p1 -b .sysAccount
|
||||||
%patch14 -p1 -b .findNewUidOnce
|
%patch14 -p1 -b .findNewUidOnce
|
||||||
|
%patch15 -p1 -b .groupLoop
|
||||||
|
|
||||||
rm po/*.gmo
|
rm po/*.gmo
|
||||||
rm po/stamp-po
|
rm po/stamp-po
|
||||||
|
@ -224,6 +226,10 @@ rm -rf $RPM_BUILD_ROOT
|
||||||
%{_mandir}/*/man8/faillog.8*
|
%{_mandir}/*/man8/faillog.8*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Jun 06 2007 Peter Vrabec <pvrabec@redhat.com> 2:4.0.18.1-15
|
||||||
|
- fix infinitive loop if there are duplicate entries
|
||||||
|
in /etc/group (#240915)
|
||||||
|
|
||||||
* Tue Jun 06 2007 Peter Vrabec <pvrabec@redhat.com> 2:4.0.18.1-14
|
* Tue Jun 06 2007 Peter Vrabec <pvrabec@redhat.com> 2:4.0.18.1-14
|
||||||
- do not run find_new_uid() twice and use getpwuid() to check
|
- do not run find_new_uid() twice and use getpwuid() to check
|
||||||
UID uniqueness (#236871)
|
UID uniqueness (#236871)
|
||||||
|
|
Loading…
Reference in a new issue