diff options
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | login-utils/newgrp.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 387372fd9..8cf17cc11 100644 --- a/configure.ac +++ b/configure.ac @@ -310,6 +310,7 @@ AC_CHECK_FUNCS([ \ getexecname \ getmntinfo \ getrlimit \ + getsgnam \ inotify_init \ inotify_init1 \ jrand48 \ diff --git a/login-utils/newgrp.c b/login-utils/newgrp.c index 55dad1bb4..d492f23ff 100644 --- a/login-utils/newgrp.c +++ b/login-utils/newgrp.c @@ -28,6 +28,10 @@ # include <crypt.h> #endif +#ifdef HAVE_GETSGNAM +# include <gshadow.h> +#endif + #include "c.h" #include "closestream.h" #include "nls.h" @@ -37,6 +41,12 @@ /* 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; @@ -69,6 +79,7 @@ static char *get_gshadow_pwd(char *groupname) } fclose(f); return pwd ? xstrdup(pwd) : NULL; +#endif /* HAVE_GETSGNAM */ } static int allow_setgid(struct passwd *pe, struct group *ge) |