+2007-12-29 Nicolas François <nicolas.francois@centraliens.net>
+
+ * NEWS, src/newusers.c: Added support for gshadow.
+
2007-12-29 Nicolas François <nicolas.francois@centraliens.net>
* NEWS, src/newusers.c: Do not add the new user to the group's
- newusers
* The new users are no more added to the list of members of their groups
because the membership is already set by their primary group.
+ * Added support for gshadow.
shadow-4.0.18.2 -> shadow-4.1.0 09-12-2008
#include "groupio.h"
#include "nscd.h"
#include "pwio.h"
+#include "sgroupio.h"
#include "shadowio.h"
/*
* Global variables
static long sha_rounds = 5000;
static int is_shadow;
+#ifdef SHADOWGRP
+static int is_shadow_grp;
+#endif
/* local function prototypes */
static void usage (void);
struct group grent;
char *members[1];
int i;
+#ifdef SHADOWGRP
+ const struct sgrp *sg;
+#endif
/*
* Start by seeing if the named group already exists. This will be
if (NULL != grp) {
/* The user will use this ID for her primary group */
*ngid = grp->gr_gid;
+ /* Don't check gshadow */
return 0;
}
/* The user will use this ID for her
* primary group */
*ngid = grp->gr_gid;
+ /* Don't check gshadow */
return 0;
}
}
grent.gr_mem = members;
*ngid = grent.gr_gid;
- return !gr_update (&grent);
+
+#ifdef SHADOWGRP
+ if (is_shadow_grp) {
+ sg = sgr_locate (grp->gr_name);
+
+ if (NULL != sg) {
+ fprintf (stderr,
+ _("%s: group %s is a shadow group, but does not exist in /etc/group\n"),
+ Prog, grp->gr_name);
+ return -1;
+ }
+ }
+#endif
+
+ if (gr_update (&grent) == 0) {
+ return -1;
+ }
+
+#ifdef SHADOWGRP
+ if (is_shadow_grp) {
+ struct sgrp sgrent;
+ sgrent.sg_name = grent.gr_name;
+ sgrent.sg_passwd = "*"; /* XXX warning: const */
+ sgrent.sg_adm = NULL;
+ sgrent.sg_mem = members;
+
+ if (sgr_update (&sgrent) == 0) {
+ fprintf (stderr,
+ _("%s: group %s created, failure during the creation of the corresponding gshadow group\n"),
+ Prog, grent.gr_name);
+ return -1;
+ }
+ }
+#endif
+
+ return 0;
}
/*
is_shadow = spw_file_present ();
+#ifdef SHADOWGRP
+ is_shadow_grp = sgr_file_present ();
+#endif
+
open_files ();
/*