X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/blobdiff_plain/0b3bc144008c93d61f3720daf8aeff915df65ede..899452679cb55274ba89a3d37ed5ffe36738ecdf:/pw/edgroup.c diff --git a/pw/edgroup.c b/pw/edgroup.c index 62c2efe..649a398 100644 --- a/pw/edgroup.c +++ b/pw/edgroup.c @@ -22,16 +22,18 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ +#ifndef lint +static const char rcsid[] = + "$Id: edgroup.c,v 1.6 1998/07/16 17:18:22 nate Exp $"; +#endif /* not lint */ + #include #include #include #include #include -#include #include #include #include @@ -53,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) @@ -170,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 */ }