]> granicus.if.org Git - procps-ng/commitdiff
library: rename clashing pwcache functions
authorCraig Small <csmall@enc.com.au>
Fri, 17 Jun 2016 22:17:45 +0000 (08:17 +1000)
committerCraig Small <csmall@enc.com.au>
Fri, 17 Jun 2016 22:17:45 +0000 (08:17 +1000)
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 <csmall@enc.com.au>
proc/pwcache.c
proc/pwcache.h
proc/readproc.c

index f2512515a28c54ac6edfb3e27458e86dfc19c5b4..83aed50d93d0b368bd3a14c46268f5dfd4855ac1 100644 (file)
@@ -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;
 
index b0c7353ffb3d14b3e01e5d964f913565edb6b27f..3c91674fc49a126bcd99e524c7b01497df930295 100644 (file)
@@ -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
 
index d87eeac6821baabc7f9a1199dd5f082cbfdd5363..98d3da143d170c1ae7252a9491e50639b32111d9 100644 (file)
@@ -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);
         }
     }