version 1.17, 2016/07/19 06:43:27 |
version 1.18, 2018/09/16 02:38:57 |
|
|
#include "rcv.h" |
#include "rcv.h" |
#include <stdlib.h> |
#include <stdlib.h> |
#include <fcntl.h> |
#include <fcntl.h> |
|
#include <pwd.h> |
#include "extern.h" |
#include "extern.h" |
|
|
/* |
/* |
|
|
* mail is queued). |
* mail is queued). |
*/ |
*/ |
void |
void |
findmail(char *user, char *buf, int buflen) |
findmail(const char *user, char *buf, int buflen) |
{ |
{ |
char *mbox; |
char *mbox; |
struct stat sb; |
struct stat sb; |
|
|
/* |
/* |
* Discover user login name. |
* Discover user login name. |
*/ |
*/ |
char * |
const char * |
username(void) |
username(void) |
{ |
{ |
char *np; |
const char *np; |
uid_t uid; |
uid_t uid; |
|
|
if ((np = getenv("USER")) != NULL) |
if ((np = getenv("USER")) != NULL) |
return(np); |
return(np); |
if ((np = getenv("LOGNAME")) != NULL) |
if ((np = getenv("LOGNAME")) != NULL) |
return(np); |
return(np); |
if ((np = getname(uid = getuid())) != NULL) |
if ((np = user_from_uid(uid = getuid(), 1)) != NULL) |
return(np); |
return(np); |
if ((np = getlogin()) != NULL) |
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", uid); |
return(NULL); |
return(NULL); |
} |
} |