summaryrefslogtreecommitdiffstats
path: root/pw/edgroup.c
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>1999-02-23 07:15:11 +0000
committerDavid Nugent <davidn@FreeBSD.org>1999-02-23 07:15:11 +0000
commite3d97c779d907e3556a40a69b84f001d95cf4d6a (patch)
tree40243c698d7a8550872dda80789eb5b3f487c65e /pw/edgroup.c
parente5cf543fa1fda398fa1207e1338b79c3efcf3f54 (diff)
downloadpw-darwin-e3d97c779d907e3556a40a69b84f001d95cf4d6a.tar.gz
pw-darwin-e3d97c779d907e3556a40a69b84f001d95cf4d6a.zip
1) Do not blindly ignore file update errors which may occur due to concurrent
updating 2) Add -V <etcdir>, which allows maintaining user/group database in alternate locations other than /etc.
Diffstat (limited to 'pw/edgroup.c')
-rw-r--r--pw/edgroup.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/pw/edgroup.c b/pw/edgroup.c
index 6116fa6..649a398 100644
--- a/pw/edgroup.c
+++ b/pw/edgroup.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id: edgroup.c,v 1.5 1997/10/10 06:23:30 charnier Exp $";
+ "$Id: edgroup.c,v 1.6 1998/07/16 17:18:22 nate Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -55,14 +55,18 @@ 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, 0644)) != -1) {
FILE *infp;
@@ -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 */
}