+2008-02-26 Nicolas François <nicolas.francois@centraliens.net>
+
+ * NEWS: Fix failures when the gshadow file is not present. Thanks
+ to Christian Henz (http://bugs.debian.org/467488)
+ * src/gpasswd.c (get_group): Do not fail if gshadow is not present. Just use
+ the group file and set the grent structure
+ * src/gpasswd.c (check_perms): The permissions should be checked
+ using both the gshadow and group file. Add a <struct group *>
+ parameter, and check if the gshadow file exists (is_shadowgrp).
+ * src/gpasswd.c (main): Do not use sgent.sg_mem or sgent.sg_adm if
+ the gshadow file is not present (sgent is not initialized in that
+ case). The fields of sgent can be set, but not used.
+
2008-02-26 Nicolas François <nicolas.francois@centraliens.net>
* src/gpasswd.c: Fix typo in comment.
static void close_files (void);
#ifdef SHADOWGRP
static void get_group (struct group *gr, struct sgrp *sg);
-static void check_perms (const struct sgrp *sg);
+static void check_perms (const struct group *gr, const struct sgrp *sg);
static void update_group (struct group *gr, struct sgrp *sg);
static void change_passwd (struct group *gr, struct sgrp *sg);
#else
* It only returns if the user is allowed.
*/
#ifdef SHADOWGRP
-static void check_perms (const struct sgrp *sg)
+static void check_perms (const struct group *gr, const struct sgrp *sg)
#else
static void check_perms (const struct group *gr)
#endif
{
#ifdef SHADOWGRP
+ if (is_shadowgrp) {
/*
* The policy here for changing a group is that 1) you must be root
* or 2). you must be listed as an administrative member.
#endif
failure ();
}
-#else /* ! SHADOWGRP */
-
+ } else
+#endif /* ! SHADOWGRP */
+ {
#ifdef FIRST_MEMBER_IS_ADMIN
/*
* The policy here for changing a group is that 1) you must be root
failure ();
}
#endif
-#endif /* SHADOWGRP */
+ }
}
/*
*
* The information are copied in group structure(s) so that they can be
* modified later.
+ *
+ * Note: If !is_shadowgrp, *sg will not be initialized.
*/
#ifdef SHADOWGRP
static void get_group (struct group *gr, struct sgrp *sg)
}
#ifdef SHADOWGRP
+ if (is_shadowgrp) {
if (sgr_open (O_RDONLY) == 0) {
fprintf (stderr, _("%s: can't open shadow file\n"), Prog);
SYSLOG ((LOG_WARN, "cannot open /etc/gshadow"));
#endif
exit (1);
}
+ }
#endif /* SHADOWGRP */
}
* Check if the user is allowed to change the password of this group.
*/
#ifdef SHADOWGRP
- check_perms (&sgent);
+ check_perms (&grent, &sgent);
#else
check_perms (&grent);
#endif
printf (_("Adding user %s to group %s\n"), user, group);
grent.gr_mem = add_list (grent.gr_mem, user);
#ifdef SHADOWGRP
+ if (is_shadowgrp) {
sgent.sg_mem = add_list (sgent.sg_mem, user);
+ }
#endif
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog, "adding group member",
grent.gr_mem = del_list (grent.gr_mem, user);
}
#ifdef SHADOWGRP
+ if (is_shadowgrp) {
if (is_on_list (sgent.sg_mem, user)) {
removed = 1;
sgent.sg_mem = del_list (sgent.sg_mem, user);
}
+ }
#endif
if (!removed) {
fprintf (stderr, _("%s: unknown member %s\n"),