From 5a244c1095d9af7bfd7cc48ef64d651d78f5aaa3 Mon Sep 17 00:00:00 2001 From: Craig Small Date: Sat, 18 Jun 2016 08:17:45 +1000 Subject: [PATCH] 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. They were also exported but did not appear in the symbol file or used by any of the procps binaries. They are no longer exported. References: https://gitlab.com/procps-ng/procps/issues/34 Signed-off-by: Craig Small --- proc/pwcache.c | 4 ++-- proc/pwcache.h | 4 ++-- proc/readproc.c | 34 +++++++++++++++++----------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/proc/pwcache.c b/proc/pwcache.c index f2512515..83aed50d 100644 --- a/proc/pwcache.c +++ b/proc/pwcache.c @@ -43,7 +43,7 @@ static struct pwbuf { char name[P_G_SZ]; } *pwhash[HASHSIZE]; -PROCPS_EXPORT char *user_from_uid(uid_t uid) { +char *pwcache_get_user(uid_t uid) { struct pwbuf **p; struct passwd *pw; @@ -71,7 +71,7 @@ static struct grpbuf { char name[P_G_SZ]; } *grphash[HASHSIZE]; -PROCPS_EXPORT char *group_from_gid(gid_t gid) { +char *pwcache_get_group(gid_t gid) { struct grpbuf **g; struct group *gr; diff --git a/proc/pwcache.h b/proc/pwcache.h index b0c7353f..3c91674f 100644 --- a/proc/pwcache.h +++ b/proc/pwcache.h @@ -9,8 +9,8 @@ __BEGIN_DECLS // used in pwcache and in readproc to set size of username or groupname #define P_G_SZ 33 -char *user_from_uid(uid_t uid); -char *group_from_gid(gid_t gid); +char *pwcache_get_user(uid_t uid); +char *pwcache_get_group(gid_t gid); __END_DECLS diff --git a/proc/readproc.c b/proc/readproc.c index d87eeac6..98d3da14 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -467,7 +467,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); @@ -896,22 +896,22 @@ static proc_t* simple_readproc(PROCTAB *restrict const PT, proc_t *restrict cons /* some number->text resolving which is time consuming */ /* ( names are cached, so memcpy to arrays was silly ) */ if (flags & PROC_FILLUSR){ - p->euser = user_from_uid(p->euid); + p->euser = pwcache_get_user(p->euid); if(flags & PROC_FILLSTATUS) { - p->ruser = user_from_uid(p->ruid); - p->suser = user_from_uid(p->suid); - p->fuser = user_from_uid(p->fuid); + p->ruser = pwcache_get_user(p->ruid); + p->suser = pwcache_get_user(p->suid); + p->fuser = pwcache_get_user(p->fuid); } } /* some number->text resolving which is time consuming */ /* ( names are cached, so memcpy to arrays was silly ) */ if (flags & PROC_FILLGRP){ - p->egroup = group_from_gid(p->egid); + p->egroup = pwcache_get_group(p->egid); if(flags & PROC_FILLSTATUS) { - p->rgroup = group_from_gid(p->rgid); - p->sgroup = group_from_gid(p->sgid); - p->fgroup = group_from_gid(p->fgid); + p->rgroup = pwcache_get_group(p->rgid); + p->sgroup = pwcache_get_group(p->sgid); + p->fgroup = pwcache_get_group(p->fgid); } } @@ -1000,22 +1000,22 @@ static proc_t* simple_readtask(PROCTAB *restrict const PT, const proc_t *restric /* some number->text resolving which is time consuming */ /* ( names are cached, so memcpy to arrays was silly ) */ if (flags & PROC_FILLUSR){ - t->euser = user_from_uid(t->euid); + t->euser = pwcache_get_user(t->euid); if(flags & PROC_FILLSTATUS) { - t->ruser = user_from_uid(t->ruid); - t->suser = user_from_uid(t->suid); - t->fuser = user_from_uid(t->fuid); + t->ruser = pwcache_get_user(t->ruid); + t->suser = pwcache_get_user(t->suid); + t->fuser = pwcache_get_user(t->fuid); } } /* some number->text resolving which is time consuming */ /* ( names are cached, so memcpy to arrays was silly ) */ if (flags & PROC_FILLGRP){ - t->egroup = group_from_gid(t->egid); + t->egroup = pwcache_get_group(t->egid); if(flags & PROC_FILLSTATUS) { - t->rgroup = group_from_gid(t->rgid); - t->sgroup = group_from_gid(t->sgid); - t->fgroup = group_from_gid(t->fgid); + t->rgroup = pwcache_get_group(t->rgid); + t->sgroup = pwcache_get_group(t->sgid); + t->fgroup = pwcache_get_group(t->fgid); } }