From 8888c5de4c415b857f260212229893f3605b9097 Mon Sep 17 00:00:00 2001 From: David Nugent Date: Sat, 15 Jan 2000 00:20:22 +0000 Subject: Portability fixes for other bsd4.4 derivatives. --- pw/Makefile | 1 + pw/pw.c | 5 ++++- pw/pw_group.c | 7 ++++--- pw/pw_user.c | 22 ++++++++++++---------- pw/pw_vpw.c | 4 +++- pw/pwupd.h | 14 +++++++++----- 6 files changed, 33 insertions(+), 20 deletions(-) (limited to 'pw') diff --git a/pw/Makefile b/pw/Makefile index e6c9fa3..bee05cc 100644 --- a/pw/Makefile +++ b/pw/Makefile @@ -5,6 +5,7 @@ SRCS= pw.c pw_conf.c pw_user.c pw_group.c pw_log.c pw_nis.c pw_vpw.c \ grupd.c pwupd.c fileupd.c edgroup.c psdate.c \ bitmap.c cpdir.c rm_r.c +MAN= pw.8 pw.conf.5 MAN5= pw.conf.5 MAN8= pw.8 diff --git a/pw/pw.c b/pw/pw.c index 2118854..c17775f 100644 --- a/pw/pw.c +++ b/pw/pw.c @@ -35,6 +35,9 @@ static const char rcsid[] = #include #include "pw.h" +#if !defined(_PATH_YP) +#define _PATH_YP "/var/yp/" +#endif const char *Modes[] = { "add", "del", "mod", "show", "next", NULL}; @@ -181,7 +184,7 @@ main(int argc, char *argv[]) while ((ch = getopt(argc, argv, opts[which][mode])) != -1) { if (ch == '?') - errx(EX_USAGE, NULL); + errx(EX_USAGE, "unknown switch"); else addarg(&arglist, ch, optarg); optarg = NULL; diff --git a/pw/pw_group.c b/pw/pw_group.c index d489a6b..6042a68 100644 --- a/pw/pw_group.c +++ b/pw/pw_group.c @@ -123,7 +123,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) if (rc == -1) err(EX_IOERR, "group '%s' not available (NIS?)", grp->gr_name); else if (rc != 0) { - warnc(rc, "group update"); + warn("group update"); return EX_IOERR; } pw_log(cnf, mode, W_GROUP, "%s(%ld) removed", a_name->val, (long) gid); @@ -249,7 +249,7 @@ pw_group(struct userconf * cnf, int mode, struct cargs * args) if (rc == -1) warnx("group '%s' not available (NIS?)", grp->gr_name); else - warnc(rc, "group update"); + warn("group update"); return EX_IOERR; } /* grp may have been invalidated */ @@ -299,7 +299,8 @@ gr_gidpolicy(struct userconf * cnf, struct cargs * args) */ SETGRENT(); while ((grp = GETGRENT()) != NULL) - if (grp->gr_gid >= (int) cnf->min_gid && grp->gr_gid <= (int) cnf->max_gid) + if ((gid_t)grp->gr_gid >= (gid_t)cnf->min_gid && + (gid_t)grp->gr_gid <= (gid_t)cnf->max_gid) bm_setbit(&bm, grp->gr_gid - cnf->min_gid); ENDGRENT(); diff --git a/pw/pw_user.c b/pw/pw_user.c index cf9a267..395b69a 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -123,10 +123,12 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) 0, "", "User &", + "/nonexistent", "/bin/sh", - 0, - 0, 0 +#if defined(__FreeBSD__) + ,0 +#endif }; @@ -396,7 +398,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if (rc == -1) err(EX_IOERR, "user '%s' does not exist", pwd->pw_name); else if (rc != 0) { - warnc(rc, "passwd update"); + warn("passwd update"); return EX_IOERR; } @@ -405,7 +407,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if (rc == -1) warnx("WARNING: user '%s' does not exist in NIS passwd", pwd->pw_name); else if (rc != 0) - warnc(rc, "WARNING: NIS passwd update"); + warn("WARNING: NIS passwd update"); /* non-fatal */ } @@ -640,7 +642,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) warnx("user '%s' already exists", pwd->pw_name); return EX_IOERR; } else if (rc != 0) { - warnc(rc, "passwd file update"); + warn("passwd file update"); return EX_IOERR; } if (cnf->nispasswd && *cnf->nispasswd=='/') { @@ -648,7 +650,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if (rc == -1) warnx("User '%s' already exists in NIS passwd", pwd->pw_name); else - warnc(rc, "NIS passwd update"); + warn("NIS passwd update"); /* NOTE: we treat NIS-only update errors as non-fatal */ } } else if (mode == M_UPDATE || mode == M_LOCK || mode == M_UNLOCK) { @@ -658,7 +660,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) warnx("user '%s' does not exist (NIS?)", pwd->pw_name); return EX_IOERR; } else if (rc != 0) { - warnc(rc, "passwd file update"); + warn("passwd file update"); return EX_IOERR; } if ( cnf->nispasswd && *cnf->nispasswd=='/') { @@ -666,7 +668,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) if (rc == -1) warn("User '%s' not found in NIS passwd", pwd->pw_name); else - warnc(rc, "NIS passwd update"); + warn("NIS passwd update"); /* NOTE: NIS-only update errors are not fatal */ } } @@ -1136,9 +1138,9 @@ print_user(struct passwd * pwd, int pretty, int v7) *p = (char) toupper(*p); } if (pwd->pw_expire > (time_t)0 && (tptr = localtime(&pwd->pw_expire)) != NULL) - strftime(acexpire, sizeof acexpire, "%c", tptr); + strftime(acexpire, sizeof acexpire, "%e-%b-%Y %T", tptr); if (pwd->pw_change > (time_t)9 && (tptr = localtime(&pwd->pw_change)) != NULL) - strftime(pwexpire, sizeof pwexpire, "%c", tptr); + strftime(pwexpire, sizeof pwexpire, "%e-%b-%Y %T", tptr); printf("Login Name: %-15s #%-12ld Group: %-15s #%ld\n" " Full Name: %s\n" " Home: %-26.26s Class: %s\n" diff --git a/pw/pw_vpw.c b/pw/pw_vpw.c index ef12437..bc5713e 100644 --- a/pw/pw_vpw.c +++ b/pw/pw_vpw.c @@ -190,11 +190,13 @@ vendgrent(void) } } -int +RET_SETGRENT vsetgrent(void) { vendgrent(); +#if defined(__FreeBSD__) return 0; +#endif } static struct group * diff --git a/pw/pwupd.h b/pw/pwupd.h index 046bd2e..8da036d 100644 --- a/pw/pwupd.h +++ b/pw/pwupd.h @@ -35,6 +35,12 @@ #include +#if defined(__FreeBSD__) +#define RET_SETGRENT int +#else +#define RET_SETGRENT void +#endif + enum updtype { UPD_DELETE = -1, @@ -63,7 +69,7 @@ struct pwf struct passwd * (*_getpwuid)(uid_t uid); struct passwd * (*_getpwnam)(const char * nam); int (*_pwdb)(char *arg, ...); - int (*_setgrent)(void); + RET_SETGRENT (*_setgrent)(void); void (*_endgrent)(void); struct group * (*_getgrent)(void); struct group * (*_getgrgid)(gid_t gid); @@ -135,15 +141,13 @@ struct passwd * vgetpwnam __P((const char * nam)); struct passwd * vgetpwent __P((void)); int vpwdb __P((char *arg, ...)); -int vsetgrent __P((void)); -void vendgrent __P((void)); struct group * vgetgrent __P((void)); struct group * vgetgrgid __P((gid_t gid)); struct group * vgetgrnam __P((const char * nam)); struct group * vgetgrent __P((void)); int vgrdb __P((char *arg, ...)); -int vsetgrent __P((void)); -void vendgrent __P((void)); +RET_SETGRENT vsetgrent __P((void)); +void vendgrent __P((void)); void copymkdir __P((char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid)); void rm_r __P((char const * dir, uid_t uid)); -- cgit v1.2.3-56-ge451