utils.c (multitail-6.2.1.tgz) | : | utils.c (multitail-6.4.tgz) | ||
---|---|---|---|---|
skipping to change at line 342 | skipping to change at line 342 | |||
else if (amount >= M_KB) /* KB */ | else if (amount >= M_KB) /* KB */ | |||
snprintf(out, AMOUNT_STR_LEN, "%dKB", (int)((amount + M_KB - 1) / M_KB)); | snprintf(out, AMOUNT_STR_LEN, "%dKB", (int)((amount + M_KB - 1) / M_KB)); | |||
else | else | |||
snprintf(out, AMOUNT_STR_LEN, "%d", (int)(amount)); | snprintf(out, AMOUNT_STR_LEN, "%d", (int)(amount)); | |||
return out; | return out; | |||
} | } | |||
struct passwd *getuserinfo(void) | struct passwd *getuserinfo(void) | |||
{ | { | |||
struct passwd *pp = getpwuid(geteuid()); | return getpwuid(geteuid()); | |||
if (!pp) | ||||
error_exit(TRUE, FALSE, "Failed to get passwd-structure for effec | ||||
tive user id %d.\n", geteuid()); | ||||
return pp; | ||||
} | } | |||
char * getusername(void) | char * getusername(void) | |||
{ | { | |||
static char username[128] = { 0 }; | static char username[128] = "???"; | |||
if (!username[0]) | if (username[0] == '?') | |||
{ | { | |||
strncpy(username, getuserinfo() -> pw_name, sizeof(username)); | char *logname = getenv("LOGNAME"); | |||
username[sizeof(username) - 1] = 0x00; | if (logname) | |||
{ | ||||
strncpy(username, logname, 128); | ||||
logname[127] = 0x00; | ||||
} | ||||
} | ||||
if (username[0] == '?') | ||||
{ | ||||
struct passwd *pw = getuserinfo(); | ||||
if (pw) | ||||
{ | ||||
strncpy(username, getuserinfo() -> pw_name, sizeof(userna | ||||
me)); | ||||
username[sizeof(username) - 1] = 0x00; | ||||
} | ||||
} | } | |||
return username; | return username; | |||
} | } | |||
/* these are there because AIX/IRIX can return EINTR for those */ | /* these are there because AIX/IRIX can return EINTR for those */ | |||
int myopen(char *path, int mode) | int myopen(char *path, int mode) | |||
{ | { | |||
int fd; | int fd; | |||
End of changes. 4 change blocks. | ||||
10 lines changed or deleted | 21 lines changed or added |