Portability fixes for other bsd4.4 derivatives.
This commit is contained in:
parent
1e152b85f6
commit
923dc0b2c3
@ -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
|
||||
|
||||
|
@ -35,6 +35,9 @@ static const char rcsid[] =
|
||||
#include <sys/wait.h>
|
||||
#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;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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"
|
||||
|
@ -190,11 +190,13 @@ vendgrent(void)
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
RET_SETGRENT
|
||||
vsetgrent(void)
|
||||
{
|
||||
vendgrent();
|
||||
#if defined(__FreeBSD__)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
static struct group *
|
||||
|
@ -35,6 +35,12 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user