update pam config to use common-session
[debian/sudo] / tsgetgrpw.c
index 6f14d3fb5ab928b01dc734432e1906dd34d6e792..5b38298c54348a898604940c1348c7ad0d62207f 100644 (file)
@@ -44,9 +44,8 @@
 #endif /* HAVE_STRINGS_H */
 #include <fcntl.h>
 #include <limits.h>
-#include <pwd.h>
-#include <grp.h>
 
+#include "tsgetgrpw.h"
 #include "sudo.h"
 
 #ifndef LINE_MAX
@@ -64,20 +63,6 @@ static FILE *grf;
 static const char *grfile = "/etc/group";
 static int gr_stayopen;
 
-void setgrfile __P((const char *));
-void setgrent __P((void));
-void endgrent __P((void));
-struct group *getgrent __P((void));
-struct group *getgrnam __P((const char *));
-struct group *getgrgid __P((gid_t));
-
-void setpwfile __P((const char *));
-void setpwent __P((void));
-void endpwent __P((void));
-struct passwd *getpwent __P((void));
-struct passwd *getpwnam __P((const char *));
-struct passwd *getpwuid __P((uid_t));
-
 void
 setpwfile(file)
     const char *file;
@@ -119,38 +104,38 @@ getpwent()
     char *cp, *colon;
 
     if ((colon = fgets(pwbuf, sizeof(pwbuf), pwf)) == NULL)
-       return(NULL);
+       return NULL;
 
     zero_bytes(&pw, sizeof(pw));
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     pw.pw_name = cp;
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     pw.pw_passwd = cp;
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     pw.pw_uid = atoi(cp);
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     pw.pw_gid = atoi(cp);
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     pw.pw_gecos = cp;
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     pw.pw_dir = cp;
     pw.pw_shell = colon;
     len = strlen(colon);
     if (len > 0 && colon[len - 1] == '\n')
        colon[len - 1] = '\0';
-    return(&pw);
+    return &pw;
 }
 
 struct passwd *
@@ -161,7 +146,7 @@ getpwnam(name)
 
     if (pwf == NULL) {
        if ((pwf = fopen(pwfile, "r")) == NULL)
-           return(NULL);
+           return NULL;
        fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC);
     } else {
        rewind(pwf);
@@ -174,7 +159,7 @@ getpwnam(name)
        fclose(pwf);
        pwf = NULL;
     }
-    return(pw);
+    return pw;
 }
 
 struct passwd *
@@ -185,7 +170,7 @@ getpwuid(uid)
 
     if (pwf == NULL) {
        if ((pwf = fopen(pwfile, "r")) == NULL)
-           return(NULL);
+           return NULL;
        fcntl(fileno(pwf), F_SETFD, FD_CLOEXEC);
     } else {
        rewind(pwf);
@@ -198,7 +183,7 @@ getpwuid(uid)
        fclose(pwf);
        pwf = NULL;
     }
-    return(pw);
+    return pw;
 }
 
 void
@@ -243,19 +228,19 @@ getgrent()
     int n;
 
     if ((colon = fgets(grbuf, sizeof(grbuf), grf)) == NULL)
-       return(NULL);
+       return NULL;
 
     zero_bytes(&gr, sizeof(gr));
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     gr.gr_name = cp;
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     gr.gr_passwd = cp;
     if ((colon = strchr(cp = colon, ':')) == NULL)
-       return(NULL);
+       return NULL;
     *colon++ = '\0';
     gr.gr_gid = atoi(cp);
     len = strlen(colon);
@@ -271,7 +256,7 @@ getgrent()
        gr.gr_mem[n++] = NULL;
     } else
        gr.gr_mem = NULL;
-    return(&gr);
+    return &gr;
 }
 
 struct group *
@@ -282,7 +267,7 @@ getgrnam(name)
 
     if (grf == NULL) {
        if ((grf = fopen(grfile, "r")) == NULL)
-           return(NULL);
+           return NULL;
        fcntl(fileno(grf), F_SETFD, FD_CLOEXEC);
     } else {
        rewind(grf);
@@ -295,7 +280,7 @@ getgrnam(name)
        fclose(grf);
        grf = NULL;
     }
-    return(gr);
+    return gr;
 }
 
 struct group *
@@ -306,7 +291,7 @@ getgrgid(gid)
 
     if (grf == NULL) {
        if ((grf = fopen(grfile, "r")) == NULL)
-           return(NULL);
+           return NULL;
        fcntl(fileno(grf), F_SETFD, FD_CLOEXEC);
     } else {
        rewind(grf);
@@ -319,5 +304,5 @@ getgrgid(gid)
        fclose(grf);
        grf = NULL;
     }
-    return(gr);
+    return gr;
 }