version 1.27, 2003/06/03 02:56:06 |
version 1.28, 2005/11/14 15:31:11 |
|
|
#include "chpass.h" |
#include "chpass.h" |
|
|
int |
int |
edit(tempname, pw) |
edit(char *tempname, struct passwd *pw) |
char *tempname; |
|
struct passwd *pw; |
|
{ |
{ |
struct stat begin, end; |
struct stat begin, end; |
|
|
|
|
* set conditional flag if the user gets to edit the shell. |
* set conditional flag if the user gets to edit the shell. |
*/ |
*/ |
void |
void |
display(tempname, fd, pw) |
display(char *tempname, int fd, struct passwd *pw) |
char *tempname; |
|
int fd; |
|
struct passwd *pw; |
|
{ |
{ |
FILE *fp; |
FILE *fp; |
char *bp, *p; |
char *bp, *p; |
|
|
} |
} |
|
|
int |
int |
verify(tempname, pw) |
verify(char *tempname, struct passwd *pw) |
char *tempname; |
|
struct passwd *pw; |
|
{ |
{ |
unsigned int len, alen, line; |
unsigned int alen, line; |
static char buf[LINE_MAX]; |
static char buf[LINE_MAX]; |
struct stat sb; |
struct stat sb; |
char *p, *q; |
char *p, *q; |
|
|
list[E_LOCATE].save = ""; |
list[E_LOCATE].save = ""; |
|
|
/* Build the gecos field. */ |
/* Build the gecos field. */ |
len = strlen(list[E_NAME].save) + strlen(list[E_BPHONE].save) + |
|
strlen(list[E_HPHONE].save) + strlen(list[E_LOCATE].save) + 4; |
|
for (alen = 0, p = list[E_NAME].save; *p; p++) |
for (alen = 0, p = list[E_NAME].save; *p; p++) |
if (*p == '&') |
if (*p == '&') |
alen = alen + strlen(pw->pw_name) - 1; |
alen = alen + strlen(pw->pw_name) - 1; |
if (!(p = malloc(len))) |
if (asprintf(&p, "%s,%s,%s,%s", list[E_NAME].save, |
|
list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save) == -1) |
err(1, NULL); |
err(1, NULL); |
(void)snprintf(p, len, "%s,%s,%s,%s", list[E_NAME].save, |
|
list[E_LOCATE].save, list[E_BPHONE].save, list[E_HPHONE].save); |
|
pw->pw_gecos = p; |
pw->pw_gecos = p; |
|
|
if (snprintf(buf, sizeof(buf), |
if (snprintf(buf, sizeof(buf), |