]> git.cameronkatri.com Git - pw-darwin.git/blobdiff - pw/edgroup.c
Grammar and spelling fixes
[pw-darwin.git] / pw / edgroup.c
index c927b06cc30a383b34d7fa22fca4aa55e3a89d21..649a398a51c9b9e0e005691cd7490cbd70ac228e 100644 (file)
@@ -26,7 +26,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id$";
+       "$Id: edgroup.c,v 1.6 1998/07/16 17:18:22 nate Exp $";
 #endif /* not lint */
 
 #include <stdio.h>
@@ -55,16 +55,20 @@ isingroup(char const * name, char **mem)
        return -1;
 }
 
-static char     groupfile[] = _PATH_GROUP;
-static char     grouptmp[] = _PATH_GROUP ".new";
-
 int
 editgroups(char *name, char **groups)
 {
        int             rc = 0;
        int             infd;
+       char            groupfile[MAXPATHLEN];
+       char            grouptmp[MAXPATHLEN];
+
+       strncpy(groupfile, getgrpath(_GROUP), MAXPATHLEN - 5);
+       groupfile[MAXPATHLEN - 5] = '\0';
+       strcpy(grouptmp, groupfile);
+       strcat(grouptmp, ".new");
 
-       if ((infd = open(groupfile, O_RDWR | O_CREAT | O_EXLOCK, 0644)) != -1) {
+       if ((infd = open(groupfile, O_RDWR | O_CREAT, 0644)) != -1) {
                FILE           *infp;
 
                if ((infp = fdopen(infd, "r+")) == NULL)
@@ -172,9 +176,9 @@ editgroups(char *name, char **groups)
                                                                                 */
                                                                                struct passwd  *pwd;
 
-                                                                               setpwent();
-                                                                               while ((pwd = getpwent()) != NULL && pwd->pw_gid != grp.gr_gid);
-                                                                               endpwent();
+                                                                               SETPWENT();
+                                                                               while ((pwd = GETPWENT()) != NULL && (gid_t)pwd->pw_gid != (gid_t)grp.gr_gid);
+                                                                               ENDPWENT();
                                                                                if (pwd == NULL)        /* No members at all */
                                                                                        continue;       /* Drop the group */
                                                                        }