The glib versionf of getsgnam() is using /etc/nsswitch.conf, allowing the
group passwords to come from external database.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getexecname \
getmntinfo \
getrlimit \
+ getsgnam \
inotify_init \
inotify_init1 \
jrand48 \
# include <crypt.h>
#endif
+#ifdef HAVE_GETSGNAM
+# include <gshadow.h>
+#endif
+
#include "c.h"
#include "closestream.h"
#include "nls.h"
/* try to read password from gshadow */
static char *get_gshadow_pwd(char *groupname)
{
+#ifdef HAVE_GETSGNAM
+ struct sgrp *sgrp;
+
+ sgrp = getsgnam(groupname);
+ return sgrp ? xstrdup(sgrp->sg_passwd) : NULL;
+#else
char buf[BUFSIZ];
char *pwd = NULL;
FILE *f;
}
fclose(f);
return pwd ? xstrdup(pwd) : NULL;
+#endif /* HAVE_GETSGNAM */
}
static int allow_setgid(struct passwd *pe, struct group *ge)