library: rename clashing pwcache functions

On MacOS the system already has user_from_uid and group_from_gid.
These are renamed pwcache_get_user and pwcache_get_group.

For the old library, pwcache_get_user needs to be exported
for skill.

References:
 https://gitlab.com/procps-ng/procps/issues/34

Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
Craig Small 2016-06-18 08:17:45 +10:00
parent eca9168617
commit 639c58312b
5 changed files with 25 additions and 25 deletions

View File

@ -58,7 +58,7 @@ global:
tty_to_dev;
unix_print_signals;
uptime;
user_from_uid;
pwcache_get_user;
procps_linux_version;
local:
*;

View File

@ -41,7 +41,7 @@ static struct pwbuf {
char name[P_G_SZ];
} *pwhash[HASHSIZE];
char *user_from_uid(uid_t uid) {
char *pwcache_get_user(uid_t uid) {
struct pwbuf **p;
struct passwd *pw;
@ -69,7 +69,7 @@ static struct grpbuf {
char name[P_G_SZ];
} *grphash[HASHSIZE];
char *group_from_gid(gid_t gid) {
char *pwcache_get_group(gid_t gid) {
struct grpbuf **g;
struct group *gr;

View File

@ -9,8 +9,8 @@ EXTERN_C_BEGIN
// used in pwcache and in readproc to set size of username or groupname
#define P_G_SZ 33
extern char *user_from_uid(uid_t uid);
extern char *group_from_gid(gid_t gid);
char *pwcache_get_user(uid_t uid);
char *pwcache_get_group(gid_t gid);
EXTERN_C_END

View File

@ -459,7 +459,7 @@ static void supgrps_from_supgids (proc_t *p) {
t = 0;
do {
if (',' == *s) ++s;
g = group_from_gid((uid_t)strtol(s, &s, 10));
g = pwcache_get_group((uid_t)strtol(s, &s, 10));
p->supgrp = xrealloc(p->supgrp, P_G_SZ+t+2);
t += snprintf(p->supgrp+t, P_G_SZ+2, "%s%s", t ? "," : "", g);
} while (*s);
@ -955,21 +955,21 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons
/* some number->text resolving which is time consuming */
if (flags & PROC_FILLUSR){
memcpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
memcpy(p->euser, pwcache_get_user(p->euid), sizeof p->euser);
if(flags & PROC_FILLSTATUS) {
memcpy(p->ruser, user_from_uid(p->ruid), sizeof p->ruser);
memcpy(p->suser, user_from_uid(p->suid), sizeof p->suser);
memcpy(p->fuser, user_from_uid(p->fuid), sizeof p->fuser);
memcpy(p->ruser, pwcache_get_user(p->ruid), sizeof p->ruser);
memcpy(p->suser, pwcache_get_user(p->suid), sizeof p->suser);
memcpy(p->fuser, pwcache_get_user(p->fuid), sizeof p->fuser);
}
}
/* some number->text resolving which is time consuming */
if (flags & PROC_FILLGRP){
memcpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
memcpy(p->egroup, pwcache_get_group(p->egid), sizeof p->egroup);
if(flags & PROC_FILLSTATUS) {
memcpy(p->rgroup, group_from_gid(p->rgid), sizeof p->rgroup);
memcpy(p->sgroup, group_from_gid(p->sgid), sizeof p->sgroup);
memcpy(p->fgroup, group_from_gid(p->fgid), sizeof p->fgroup);
memcpy(p->rgroup, pwcache_get_group(p->rgid), sizeof p->rgroup);
memcpy(p->sgroup, pwcache_get_group(p->sgid), sizeof p->sgroup);
memcpy(p->fgroup, pwcache_get_group(p->fgid), sizeof p->fgroup);
}
}
@ -1062,21 +1062,21 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric
/* some number->text resolving which is time consuming */
if (flags & PROC_FILLUSR){
memcpy(t->euser, user_from_uid(t->euid), sizeof t->euser);
memcpy(t->euser, pwcache_get_user(t->euid), sizeof t->euser);
if(flags & PROC_FILLSTATUS) {
memcpy(t->ruser, user_from_uid(t->ruid), sizeof t->ruser);
memcpy(t->suser, user_from_uid(t->suid), sizeof t->suser);
memcpy(t->fuser, user_from_uid(t->fuid), sizeof t->fuser);
memcpy(t->ruser, pwcache_get_user(t->ruid), sizeof t->ruser);
memcpy(t->suser, pwcache_get_user(t->suid), sizeof t->suser);
memcpy(t->fuser, pwcache_get_user(t->fuid), sizeof t->fuser);
}
}
/* some number->text resolving which is time consuming */
if (flags & PROC_FILLGRP){
memcpy(t->egroup, group_from_gid(t->egid), sizeof t->egroup);
memcpy(t->egroup, pwcache_get_group(t->egid), sizeof t->egroup);
if(flags & PROC_FILLSTATUS) {
memcpy(t->rgroup, group_from_gid(t->rgid), sizeof t->rgroup);
memcpy(t->sgroup, group_from_gid(t->sgid), sizeof t->sgroup);
memcpy(t->fgroup, group_from_gid(t->fgid), sizeof t->fgroup);
memcpy(t->rgroup, pwcache_get_group(t->rgid), sizeof t->rgroup);
memcpy(t->sgroup, pwcache_get_group(t->sgid), sizeof t->sgroup);
memcpy(t->fgroup, pwcache_get_group(t->fgid), sizeof t->fgroup);
}
}

View File

@ -43,7 +43,7 @@
#include "proc/pwcache.h"
#include "proc/sig.h"
#include "proc/devname.h"
#include "proc/procps.h" /* char *user_from_uid(uid_t uid) */
#include "proc/procps.h" /* char *pwcache_get_user(uid_t uid) */
#include "proc/readproc.h"
#include "proc/version.h" /* procps_version */
#include "rpmatch.h"
@ -134,7 +134,7 @@ static void hurt_proc(int tty, int uid, int pid, const char *restrict const cmd,
char *buf;
size_t len = 0;
fprintf(stderr, "%-8s %-8s %5d %-16.16s ? ",
(char *)dn_buf, user_from_uid(uid), pid, cmd);
(char *)dn_buf, pwcache_get_user(uid), pid, cmd);
fflush (stdout);
if (getline(&buf, &len, stdin) == -1)
return;
@ -152,7 +152,7 @@ static void hurt_proc(int tty, int uid, int pid, const char *restrict const cmd,
failed = setpriority(PRIO_PROCESS, pid, sig_or_pri);
if ((run_time->warnings && failed) || run_time->debugging || run_time->verbose) {
fprintf(stderr, "%-8s %-8s %5d %-16.16s ",
(char *)dn_buf, user_from_uid(uid), pid, cmd);
(char *)dn_buf, pwcache_get_user(uid), pid, cmd);
perror("");
return;
}