version 1.12, 1998/06/12 17:51:50 |
version 1.13, 2001/11/21 15:26:39 |
|
|
|
|
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93"; |
static const char sccsid[] = "@(#)v7.local.c 8.1 (Berkeley) 6/6/93"; |
#else |
#else |
static char rcsid[] = "$OpenBSD$"; |
static const char rcsid[] = "$OpenBSD$"; |
#endif |
#endif |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
|
|
* mail is queued). |
* mail is queued). |
*/ |
*/ |
void |
void |
findmail(user, buf, buflen) |
findmail(char *user, char *buf, int buflen) |
char *user, *buf; |
|
int buflen; |
|
{ |
{ |
char *mbox; |
char *mbox; |
struct stat sb; |
struct stat sb; |
|
|
sb.st_uid != getuid() && sb.st_uid != geteuid()) |
sb.st_uid != getuid() && sb.st_uid != geteuid()) |
mbox = NULL; |
mbox = NULL; |
|
|
if (mbox) { |
if (mbox) |
(void)strncpy(buf, mbox, buflen - 1); |
(void)strlcpy(buf, mbox, buflen); |
buf[buflen - 1] = '\0'; |
else |
} else |
|
(void)snprintf(buf, buflen, "%s/%s", _PATH_MAILDIR, user); |
(void)snprintf(buf, buflen, "%s/%s", _PATH_MAILDIR, user); |
} |
} |
|
|
|
|
* Get rid of the queued mail. |
* Get rid of the queued mail. |
*/ |
*/ |
void |
void |
demail() |
demail(void) |
{ |
{ |
|
|
if (value("keep") != NULL || rm(mailname) < 0) |
if (value("keep") != NULL || rm(mailname) < 0) |
|
|
* Discover user login name. |
* Discover user login name. |
*/ |
*/ |
char * |
char * |
username() |
username(void) |
{ |
{ |
char *np; |
char *np; |
uid_t uid; |
uid_t uid; |
|
|
if ((np = getenv("LOGNAME")) != NULL) |
if ((np = getenv("LOGNAME")) != NULL) |
return(np); |
return(np); |
if ((np = getname(uid = getuid())) != NULL) |
if ((np = getname(uid = getuid())) != NULL) |
|
return(np); |
|
if ((np = getlogin()) != NULL) |
return(np); |
return(np); |
printf("Cannot associate a name with uid %u\n", (unsigned)uid); |
printf("Cannot associate a name with uid %u\n", (unsigned)uid); |
return(NULL); |
return(NULL); |