Fix chpass.

This commit is contained in:
Serge
2022-05-27 00:46:24 -07:00
parent 4fdec2101b
commit bd9f0208d2
8 changed files with 49 additions and 9 deletions

View File

@@ -95,6 +95,7 @@ void setbuffer (FILE *, char *, size_t);
void setlinebuf (FILE *);
int setvbuf (FILE *, char *, int, size_t);
int fseek (FILE *, long, int);
int rename(const char *, const char *);
void rewind (FILE *);
int remove (const char *);
int getw(FILE *stream);

View File

@@ -105,6 +105,7 @@ int unlink (const char *pathname);
int link (const char *oldpath, const char *newpath);
ssize_t readlink (const char *path, char *buf, size_t bufsiz);
int chown (const char *path, uid_t owner, gid_t group);
int fchown(int fd, uid_t owner, gid_t group);
int nice (int inc);
int setuid (uid_t uid);
int setgid (gid_t gid);

View File

@@ -56,6 +56,7 @@ static char sccsid[] = "@(#)calendar.c 8.3 (Berkeley) 3/25/94";
#include <string.h>
#include <tzfile.h>
#include <unistd.h>
#include <strings.h>
#include "pathnames.h"

View File

@@ -20,6 +20,7 @@
#include <sys/signal.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <pwd.h>
#include <errno.h>
#include <stdio.h>
@@ -29,6 +30,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <paths.h>
#include <fcntl.h>
#include "chpass.h"
char e1[] = ": ";
@@ -57,6 +59,16 @@ struct entry list[] = {
uid_t uid;
void loadpw(char *arg, struct passwd *pw);
void usage(void);
int info(struct passwd *pw);
int copy(struct passwd *pw, FILE *fp);
int makedb(char *file);
int edit(char *file);
int check(FILE *fp, struct passwd *pw);
int prompt(void);
int
main(argc, argv)
int argc;
char **argv;
@@ -70,7 +82,6 @@ main(argc, argv)
int aflag, ch, fd;
char *fend, *passwd, *temp, *tend;
char from[MAXPATHLEN], to[MAXPATHLEN];
char *getusershell();
uid = getuid();
aflag = 0;
@@ -220,6 +231,7 @@ bad: (void)fprintf(stderr, "%s unchanged.\n", _PATH_SHADOW);
exit(0);
}
int
info(pw)
struct passwd *pw;
{
@@ -268,6 +280,7 @@ info(pw)
return(rval);
}
int
check(fp, pw)
FILE *fp;
struct passwd *pw;
@@ -331,6 +344,7 @@ check(fp, pw)
return(1);
}
int
copy(pw, fp)
struct passwd *pw;
FILE *fp;
@@ -371,6 +385,7 @@ copy(pw, fp)
return(1);
}
int
makedb(file)
char *file;
{
@@ -384,14 +399,17 @@ makedb(file)
return(w == -1 || status);
}
int
edit(file)
char *file;
{
int status, pid, w;
char *p, *editor, *getenv();
if (editor = getenv("EDITOR")) {
if (p = rindex(editor, '/'))
editor = getenv("EDITOR");
if (editor) {
p = rindex(editor, '/');
if (p)
++p;
else
p = editor;
@@ -408,6 +426,7 @@ edit(file)
return(w == -1 || status);
}
void
loadpw(arg, pw)
char *arg;
register struct passwd *pw;
@@ -432,6 +451,7 @@ bad: (void)fprintf(stderr, "chpass: bad password list.\n");
}
}
int
prompt()
{
register int c;
@@ -447,6 +467,7 @@ prompt()
/* NOTREACHED */
}
void
usage()
{
(void)fprintf(stderr, "usage: chpass [-a list] [user]\n");

View File

@@ -22,3 +22,5 @@ struct entry {
};
extern uid_t uid;
void print(FILE *fp, struct passwd *pw);

View File

@@ -23,9 +23,12 @@
#include <stdio.h>
#include <ctype.h>
#include <paths.h>
#include <stdlib.h>
#include <unistd.h>
#include "chpass.h"
/* ARGSUSED */
int
p_login(p, pw, ep)
char *p;
struct passwd *pw;
@@ -57,6 +60,7 @@ p_login(p, pw, ep)
}
/* ARGSUSED */
int
p_passwd(p, pw, ep)
char *p;
struct passwd *pw;
@@ -73,6 +77,7 @@ p_passwd(p, pw, ep)
}
/* ARGSUSED */
int
p_uid(p, pw, ep)
register char *p;
struct passwd *pw;
@@ -99,6 +104,7 @@ p_uid(p, pw, ep)
}
/* ARGSUSED */
int
p_gid(p, pw, ep)
register char *p;
struct passwd *pw;
@@ -131,6 +137,7 @@ p_gid(p, pw, ep)
}
/* ARGSUSED */
int
p_gecos(p, pw, ep)
char *p;
struct passwd *pw;
@@ -146,6 +153,7 @@ p_gecos(p, pw, ep)
}
/* ARGSUSED */
int
p_hdir(p, pw, ep)
char *p;
struct passwd *pw;
@@ -163,13 +171,13 @@ p_hdir(p, pw, ep)
}
/* ARGSUSED */
int
p_shell(p, pw, ep)
register char *p;
struct passwd *pw;
struct entry *ep;
{
register char *sh, *t;
char *getusershell();
if (!*p) {
pw->pw_shell = _PATH_BSHELL;

View File

@@ -19,7 +19,10 @@
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <paths.h>
#include "chpass.h"
@@ -46,6 +49,7 @@ ttoa(tval)
return(tbuf);
}
int
atot(p, store)
char *p;
time_t *store;
@@ -109,13 +113,13 @@ bad: return(1);
return(0);
}
void
print(fp, pw)
register FILE *fp;
struct passwd *pw;
{
register char *p;
char *bp;
char *getusershell(), *ttoa();
fprintf(fp, "#Changing user database information for %s.\n",
pw->pw_name);

View File

@@ -100,7 +100,9 @@ void ruadd (struct k_rusage *ru, struct k_rusage *ru2);
#else
int getrusage (int who, struct rusage *usage);
int getrlimit(int resource, struct rlimit *rlim);
int getrusage(int who, struct rusage *usage);
int setrlimit(int resource, const struct rlimit *rlim);
#endif