Added support for gshadow.

This commit is contained in:
nekral-guest 2007-12-29 17:26:28 +00:00
parent 098173e1df
commit 623010396c
3 changed files with 54 additions and 1 deletions

View File

@ -1,3 +1,7 @@
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> 2007-12-29 Nicolas François <nicolas.francois@centraliens.net>
* NEWS, src/newusers.c: Do not add the new user to the group's * NEWS, src/newusers.c: Do not add the new user to the group's

1
NEWS
View File

@ -31,6 +31,7 @@ shadow-4.1.0 -> shadow-4.1.1 UNRELEASED
- newusers - newusers
* The new users are no more added to the list of members of their groups * 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. 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 shadow-4.0.18.2 -> shadow-4.1.0 09-12-2008

View File

@ -53,6 +53,7 @@
#include "groupio.h" #include "groupio.h"
#include "nscd.h" #include "nscd.h"
#include "pwio.h" #include "pwio.h"
#include "sgroupio.h"
#include "shadowio.h" #include "shadowio.h"
/* /*
* Global variables * Global variables
@ -65,6 +66,9 @@ static char *crypt_method = NULL;
static long sha_rounds = 5000; static long sha_rounds = 5000;
static int is_shadow; static int is_shadow;
#ifdef SHADOWGRP
static int is_shadow_grp;
#endif
/* local function prototypes */ /* local function prototypes */
static void usage (void); static void usage (void);
@ -110,6 +114,9 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
struct group grent; struct group grent;
char *members[1]; char *members[1];
int i; int i;
#ifdef SHADOWGRP
const struct sgrp *sg;
#endif
/* /*
* Start by seeing if the named group already exists. This will be * Start by seeing if the named group already exists. This will be
@ -119,6 +126,7 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
if (NULL != grp) { if (NULL != grp) {
/* The user will use this ID for her primary group */ /* The user will use this ID for her primary group */
*ngid = grp->gr_gid; *ngid = grp->gr_gid;
/* Don't check gshadow */
return 0; return 0;
} }
@ -152,6 +160,7 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
/* The user will use this ID for her /* The user will use this ID for her
* primary group */ * primary group */
*ngid = grp->gr_gid; *ngid = grp->gr_gid;
/* Don't check gshadow */
return 0; return 0;
} }
} }
@ -191,7 +200,42 @@ static int add_group (const char *name, const char *gid, gid_t * ngid)
grent.gr_mem = members; grent.gr_mem = members;
*ngid = grent.gr_gid; *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;
} }
/* /*
@ -557,6 +601,10 @@ int main (int argc, char **argv)
is_shadow = spw_file_present (); is_shadow = spw_file_present ();
#ifdef SHADOWGRP
is_shadow_grp = sgr_file_present ();
#endif
open_files (); open_files ();
/* /*