tavoid pw library - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 63fcc2bc3c1b37227cc9f5b9b8ca45ce091a1477
 (DIR) parent d93cc14ecee8fbb0dc0fc746713aba7ee0979c4c
 (HTM) Author: rsc <devnull@localhost>
       Date:   Mon, 12 Jun 2006 17:21:10 +0000
       
       avoid pw library
       
       Diffstat:
         M src/lib9/_p9dir.c                   |       9 +++++----
       
       1 file changed, 5 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/src/lib9/_p9dir.c b/src/lib9/_p9dir.c
       t@@ -77,6 +77,7 @@ disksize(int fd, int dev)
        #define _HAVESTGEN
        #endif
        
       +int _p9usepwlibrary = 1;
        /*
         * Caching the last group and passwd looked up is
         * a significant win (stupidly enough) on most systems.
       t@@ -123,11 +124,11 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *
                /* user */
                if(p && st->st_uid == uid && p->pw_uid == uid)
                        ;
       -        else{
       +        else if(_p9usepwlibrary){
                        p = getpwuid(st->st_uid);
                        uid = st->st_uid;
                }
       -        if(p == nil){
       +        if(p == nil || st->st_uid != uid || p->pw_uid != uid){
                        snprint(tmp, sizeof tmp, "%d", (int)st->st_uid);
                        s = tmp;
                }else
       t@@ -146,11 +147,11 @@ _p9dir(struct stat *lst, struct stat *st, char *name, Dir *d, char **str, char *
                /* group */
                if(g && st->st_gid == gid && g->gr_gid == gid)
                        ;
       -        else{
       +        else if(_p9usepwlibrary){
                        g = getgrgid(st->st_gid);
                        gid = st->st_gid;
                }
       -        if(g == nil){
       +        if(g == nil || st->st_gid != gid || g->gr_gid != gid){
                        snprint(tmp, sizeof tmp, "%d", (int)st->st_gid);
                        s = tmp;
                }else