X-Git-Url: https://git.cameronkatri.com/pw-darwin.git/blobdiff_plain/6924c20486d31cd8c84dfbcd4eecf8df045c8d57..67a0ef27644ad3ae9cd0df362ed185d28e53bca5:/pw/grupd.c diff --git a/pw/grupd.c b/pw/grupd.c index cf0584e..edff76d 100644 --- a/pw/grupd.c +++ b/pw/grupd.c @@ -22,21 +22,60 @@ * 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. - * - * $Id$ */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + #include #include #include #include #include -#include #include #include +#include #include "pwupd.h" +static char * grpath = _PATH_PWD; + +int +setgrdir(const char * dir) +{ + if (dir == NULL) + return -1; + else { + char * d = malloc(strlen(dir)+1); + if (d == NULL) + return -1; + grpath = strcpy(d, dir); + } + return 0; +} + +char * +getgrpath(const char * file) +{ + static char pathbuf[MAXPATHLEN]; + + snprintf(pathbuf, sizeof pathbuf, "%s/%s", grpath, file); + return pathbuf; +} + +int +grdb(char *arg,...) +{ + /* + * This is a stub for now, but maybe eventually be functional + * if ever an indexed version of /etc/groups is implemented. + */ + arg=arg; + return 0; +} + int fmtgrentry(char **buf, int * buflen, struct group * grp, int type) { @@ -94,7 +133,7 @@ gr_update(struct group * grp, char const * group, int mode) int grbuflen = 0; char *grbuf = NULL; - endgrent(); + ENDGRENT(); l = snprintf(pfx, sizeof pfx, "%s:", group); /* @@ -102,8 +141,11 @@ gr_update(struct group * grp, char const * group, int mode) */ if (grp != NULL && fmtgrentry(&grbuf, &grbuflen, grp, PWF_PASSWD) == -1) l = -1; - else - l = fileupdate(_PATH_GROUP, 0644, grbuf, pfx, l, mode); + else { + l = fileupdate(getgrpath(_GROUP), 0644, grbuf, pfx, l, mode); + if (l == 0) + l = grdb(NULL); + } if (grbuf != NULL) free(grbuf); return l;