URI: 
       tcleanup - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit 605c0ea102e334b6c05d635ca0e5b93bad0031ec
   DIR parent 5a1e9de7b160033e85a77ad4c60193186364a2fb
  HTML Author: rsc <devnull@localhost>
       Date:   Wed,  8 Feb 2006 22:39:54 +0000
       
       cleanup
       
       Diffstat:
         M src/cmd/faces/faces.h               |       2 +-
         M src/cmd/faces/main.c                |     137 ++++++++-----------------------
         M src/cmd/faces/plumb.c               |     218 ++++++++-----------------------
         M src/cmd/upas/common/aux.c           |       6 +++---
         M src/cmd/upas/common/config.c        |      16 ++++++++++++++++
         M src/cmd/upas/common/libcommon.a     |       0 
         M src/cmd/upas/common/libsys.c        |     104 +++----------------------------
         M src/cmd/upas/common/mkfile          |      16 +++++++---------
         M src/cmd/upas/common/process.c       |       9 ++++-----
         M src/cmd/upas/common/sys.h           |       6 +++---
         M src/cmd/upas/fs/pop3.c              |       4 +---
       
       11 files changed, 132 insertions(+), 386 deletions(-)
       ---
   DIR diff --git a/src/cmd/faces/faces.h b/src/cmd/faces/faces.h
       t@@ -45,7 +45,7 @@ extern char        date[];
        extern char        *maildir;
        extern char        **maildirs;
        extern int        nmaildirs;
       -extern CFsys        *upasfs;
       +extern CFsys        *mailfs;
        
        Face*        nextface(void);
        void        findbit(Face*);
   DIR diff --git a/src/cmd/faces/main.c b/src/cmd/faces/main.c
       t@@ -3,7 +3,6 @@
        #include <draw.h>
        #include <plumb.h>
        #include <regexp.h>
       -//jpc #include <event.h>        /* for support routines only */
        #include <bio.h>
        #include <thread.h>
        #include <mouse.h>
       t@@ -20,6 +19,8 @@ enum
                Infolines = 9,
        
                HhmmTime = 18*60*60,        /* max age of face to display hh:mm time */
       +        
       +        STACK = 32768
        };
        
        enum
       t@@ -27,6 +28,7 @@ enum
                Mainp,
                Timep,
                Mousep,
       +        Resizep,
                NPROC
        };
        
       t@@ -34,7 +36,8 @@ int pids[NPROC];
        char *procnames[] = {
                "main",
                "time",
       -        "mouse"
       +        "mouse",
       +        "resize",
        };
        
        Rectangle leftright = {0, 0, 20, 15};
       t@@ -57,7 +60,7 @@ uchar rightdata[] = {
                0x18, 0x00, 0x00, 0x10, 0x00
        };
        
       -CFsys        *upasfs;
       +CFsys        *mailfs;
        Mousectl        *mousectl;
        Image        *blue;                /* full arrow */
        Image        *bgrnd;                /* pale blue background color */
       t@@ -74,7 +77,7 @@ int        ndown;
        
        char        date[64];
        Face        **faces;
       -char        *maildir = "/mail/fs/mbox";
       +char        *maildir = "INBOX";
        ulong        now;
        
        Point        datep = { 8, 6 };
       t@@ -83,6 +86,7 @@ Point        enddate;                        /* where date ends on display; used to place arrows */
        Rectangle        leftr;                        /* location of left arrow on display */
        Rectangle        rightr;                /* location of right arrow on display */
        void updatetimes(void);
       +void eresized(int);
        
        void
        setdate(void)
       t@@ -95,15 +99,12 @@ setdate(void)
        void
        init(void)
        {
       -#if 0
       -        mousefd = open("/dev/mouse", OREAD);
       -        if(mousefd < 0){
       -                fprint(2, "faces: can't open mouse: %r\n");
       -                threadexitsall("mouse");
       -        }
       -#endif
       -        upasfs = nsmount("upasfs",nil);
       -        mousectl = initmouse(nil,screen);
       +        mailfs = nsmount("mail", nil);
       +        if(mailfs == nil)
       +                sysfatal("mount mail: %r");
       +        mousectl = initmouse(nil, screen);
       +        if(mousectl == nil)
       +                sysfatal("initmouse: %r");
                initplumb();
        
                /* make background color */
       t@@ -332,7 +333,7 @@ addface(Face *f)        /* always adds at 0 */
                lockdisplay(display);
                if(first != 0){
                        first = 0;
       -                resized();
       +                eresized(0);
                }
                findbit(f);
        
       t@@ -366,27 +367,6 @@ addface(Face *f)        /* always adds at 0 */
                unlockdisplay(display);
        }
        
       -#if 0
       -void
       -loadmboxfaces(char *maildir)
       -{
       -        int dirfd;
       -        Dir *d;
       -        int i, n;
       -
       -        dirfd = open(maildir, OREAD);
       -        if(dirfd >= 0){
       -                chdir(maildir);
       -                while((n = dirread(dirfd, &d)) > 0){
       -                        for(i=0; i<n; i++)
       -                                addface(dirface(maildir, d[i].name));
       -                        free(d);
       -                }
       -                close(dirfd);
       -        }
       -}
       -#endif
       -
        void
        loadmboxfaces(char *maildir)
        {
       t@@ -394,20 +374,16 @@ loadmboxfaces(char *maildir)
                Dir *d;
                int i, n;
        
       -        dirfd = fsopen(upasfs,maildir, OREAD);
       +        dirfd = fsopen(mailfs, maildir, OREAD);
                if(dirfd != nil){
       -                //jpc chdir(maildir);
                        while((n = fsdirread(dirfd, &d)) > 0){
       -                        for(i=0; i<n; i++) {
       +                        for(i=0; i<n; i++)
                                        addface(dirface(maildir, d[i].name));
       -                        }
                                free(d);
                        }
                        fsclose(dirfd);
       -        }
       -        else {
       -                error("cannot open %s: %r",maildir);
       -        }
       +        }else
       +                sysfatal("open %s: %r", maildir);
        }
        
        void
       t@@ -542,30 +518,15 @@ eresized(int new)
                unlockdisplay(display);
        }
        
       -#if 0
       -int
       -getmouse(Mouse *m)
       +void
       +resizeproc(void *v)
        {
       -        int n;
       -        static int eof;
       -        char buf[128];
       +        USED(v);
        
       -        if(eof)
       -                return 0;
       -        for(;;){
       -                n = read(mousefd, buf, sizeof(buf));
       -                if(n <= 0){
       -                        /* so callers needn't check return value every time */
       -                        eof = 1;
       -                        m->buttons = 0;
       -                        return 0;
       -                }
       -                //jpc n = eatomouse(m, buf, n);
       -                if(n > 0)
       -                        return 1;
       -        }
       +        while(recv(mousectl->resizec, 0) == 1)
       +                eresized(1);
        }
       -#endif
       +
        int
        getmouse(Mouse *m)
        {
       t@@ -573,19 +534,13 @@ getmouse(Mouse *m)
        
                if(eof)
                        return 0;
       -        if( readmouse(mousectl) < 0 ) {
       +        if(readmouse(mousectl) < 0){
                        eof = 1;
                        m->buttons = 0;
                        return 0;
                }
       -        else {
       -                *m = mousectl->m;
       -/*                m->buttons = mousectl->m.buttons;
       -                m->xy.x = mousectl->m.xy.x;
       -                m->xy.y = mousectl->m.xy.y;
       -                m->msec = mousectl->m.msec;        */
       -                return 1;
       -        }
       +        *m = mousectl->m;
       +        return 1;
        }
        
        enum
       t@@ -680,9 +635,10 @@ click(int button, Mouse *m)
        }
        
        void
       -mouseproc(void *dummy)
       +mouseproc(void *v)
        {
                Mouse mouse;
       +        USED(v);
        
                while(getmouse(&mouse)){
                        if(mouse.buttons == 1)
       t@@ -700,36 +656,10 @@ mouseproc(void *dummy)
        void
        killall(char *s)
        {
       -        int i, pid;
       -
       -        pid = getpid();
       -        for(i=0; i<NPROC; i++)
       -                if(pids[i] && pids[i]!=pid)
       -                        postnote(PNPROC, pids[i], "kill");
                threadexitsall(s);
        }
        
        void
       -startproc(void (*f)(void), int index)
       -{
       -        int pid;
       -
       -        switch(pid = rfork(RFPROC|RFNOWAIT)){ //jpc removed |RFMEM
       -        case -1:
       -                fprint(2, "faces: fork failed: %r\n");
       -                killall("fork failed");
       -        case 0:
       -                f();
       -                fprint(2, "faces: %s process exits\n", procnames[index]);
       -                if(index >= 0)
       -                        killall("process died");
       -                threadexitsall(nil);
       -        }
       -        if(index >= 0)
       -                pids[index] = pid;
       -}
       -
       -void
        usage(void)
        {
                fprint(2, "usage: faces [-hi] [-m maildir] -W winsize\n");
       t@@ -741,6 +671,8 @@ threadmain(int argc, char *argv[])
        {
                int i;
        
       +        rfork(RFNOTEG);
       +
                ARGBEGIN{
                case 'h':
                        history++;
       t@@ -772,8 +704,9 @@ threadmain(int argc, char *argv[])
                eresized(0);
        
                pids[Mainp] = getpid();
       -        pids[Timep] = proccreate(timeproc, nil, 16000);
       -        pids[Mousep] = proccreate(mouseproc, nil, 16000);
       +        pids[Timep] = proccreate(timeproc, nil, STACK);
       +        pids[Mousep] = proccreate(mouseproc, nil, STACK);
       +        pids[Resizep] = proccreate(resizeproc, nil, STACK);
                if(initload)
                        for(i = 0; i < nmaildirs; i++)
                                loadmboxfaces(maildirs[i]);
   DIR diff --git a/src/cmd/faces/plumb.c b/src/cmd/faces/plumb.c
       t@@ -1,17 +1,15 @@
        #include <u.h>
        #include <libc.h>
       +#include <thread.h>
        #include <draw.h>
       -#include <plumb.h>
        #include <regexp.h>
        #include <bio.h>
        #include <9pclient.h>
       +#include <plumb.h>
        #include "faces.h"
        
       -static int                showfd = -1;
       -static int                seefd = -1;
       -static int                logfd = -1;
       -static char        *user;
       -static char        *logtag;
       +static CFid*        showfd;
       +static CFid*        seefd;
        
        char                **maildirs;
        int                nmaildirs;
       t@@ -19,20 +17,10 @@ int                nmaildirs;
        void
        initplumb(void)
        {
       -        showfd = plumbopen("send", OWRITE);
       -        seefd = plumbopen("seemail", OREAD);
       -
       -        if(seefd < 0){
       -                logfd = open(unsharp("#9/log/mail"), OREAD);
       -                seek(logfd, 0LL, 2);
       -                user = getenv("user");
       -                if(user == nil){
       -                        fprint(2, "faces: can't find user name: %r\n");
       -                        exits("$user");
       -                }
       -                logtag = emalloc(32+strlen(user)+1);
       -                sprint(logtag, " delivered %s From ", user);
       -        }
       +        showfd = plumbopenfid("send", OWRITE);
       +        seefd = plumbopenfid("seemail", OREAD);
       +        if(showfd == nil || seefd == nil)
       +                sysfatal("plumbopen: %r");
        }
        
        void
       t@@ -75,7 +63,7 @@ showmail(Face *f)
                pm.attr = &a;
                pm.ndata = strlen(s);
                pm.data = s;
       -        plumbsend(showfd,&pm);
       +        plumbsendtofid(showfd, &pm);
        }
        
        char*
       t@@ -114,43 +102,6 @@ setname(Face *f, char *sender)
                }
        }
        
       -int
       -getc(void)
       -{
       -        static uchar buf[512];
       -        static int nbuf = 0;
       -        static int i = 0;
       -
       -        while(i == nbuf){
       -                i = 0;
       -                nbuf = read(logfd, buf, sizeof buf);
       -                if(nbuf == 0){
       -                        sleep(15000);
       -                        continue;
       -                }
       -                if(nbuf < 0)
       -                        return -1;
       -        }
       -        return buf[i++];
       -}
       -
       -char*
       -getline(char *buf, int n)
       -{
       -        int i, c;
       -
       -        for(i=0; i<n-1; i++){
       -                c = getc();
       -                if(c <= 0)
       -                        return nil;
       -                if(c == '\n')
       -                        break;
       -                buf[i] = c;
       -        }
       -        buf[i] = '\0';
       -        return buf;
       -}
       -
        static char* months[] = {
                "jan", "feb", "mar", "apr",
                "may", "jun", "jul", "aug", 
       t@@ -216,42 +167,6 @@ parsedate(char *s)
                return parsedatev(f);
        }
        
       -/* achille Jul 23 14:05:15 delivered jmk From ms.com!bub Fri Jul 23 14:05:14 EDT 1999 (plan9.bell-labs.com!jmk) 1352 */
       -/* achille Oct 26 13:45:42 remote local!rsc From rsc Sat Oct 26 13:45:41 EDT 2002 (rsc) 170 */
       -int
       -parselog(char *s, char **sender, ulong *xtime)
       -{
       -        char *f[20];
       -        int nf;
       -
       -        nf = getfields(s, f, nelem(f), 1, " ");
       -        if(nf < 14)
       -                return 0;
       -        if(strcmp(f[4], "delivered") == 0 && strcmp(f[5], user) == 0)
       -                goto Found;
       -        if(strcmp(f[4], "remote") == 0 && strncmp(f[5], "local!", 6) == 0 && strcmp(f[5]+6, user) == 0)
       -                goto Found;
       -        return 0;
       -
       -Found:
       -        *sender = estrdup(f[7]);
       -        *xtime = parsedatev(&f[8]);
       -        return 1;
       -}
       -
       -int
       -logrecv(char **sender, ulong *xtime)
       -{
       -        char buf[4096];
       -
       -        for(;;){
       -                if(getline(buf, sizeof buf) == nil)
       -                        return 0;
       -                if(parselog(buf, sender, xtime))
       -                        return 1;
       -        }
       -        return -1;
       -}
        
        char*
        tweakdate(char *d)
       t@@ -280,49 +195,36 @@ nextface(void)
        
                f = emalloc(sizeof(Face));
                for(;;){
       -                if(seefd >= 0){
       -                        m = plumbrecv(seefd);
       -                        if(m == nil)
       -                                killall("error on seemail plumb port");
       -                        t = value(m->attr, "mailtype", "");
       -                        if(strcmp(t, "delete") == 0)
       -                                delete(m->data, value(m->attr, "digest", nil));
       -                        else if(strcmp(t, "new") != 0)
       -                                fprint(2, "faces: unknown plumb message type %s\n", t);
       -                        else for(i=0; i<nmaildirs; i++) {
       -                                if(strncmp(m->data,"/mail/fs/",strlen("/mail/fs/")) == 0)
       -                                        m->data += strlen("/mail/fs/");
       -                                if(strncmp(m->data, maildirs[i], strlen(maildirs[i])) == 0)
       -                                        goto Found;
       -                        }
       +                m = plumbrecvfid(seefd);
       +                if(m == nil)
       +                        killall("error on seemail plumb port");
       +                t = value(m->attr, "mailtype", "");
       +                if(strcmp(t, "delete") == 0)
       +                        delete(m->data, value(m->attr, "digest", nil));
       +                else if(strcmp(t, "new") != 0)
       +                        fprint(2, "faces: unknown plumb message type %s\n", t);
       +                else for(i=0; i<nmaildirs; i++) {        /* XXX */
       +                        if(strncmp(m->data,"/mail/fs/",strlen("/mail/fs/")) == 0)
       +                                m->data += strlen("/mail/fs/");
       +                        if(strncmp(m->data, maildirs[i], strlen(maildirs[i])) == 0)
       +                                goto Found;
       +                }
       +                plumbfree(m);
       +                continue;
       +
       +        Found:
       +                xtime = parsedate(value(m->attr, "date", date));
       +                digestp = value(m->attr, "digest", nil);
       +                if(alreadyseen(digestp)){
       +                        /* duplicate upas/fs can send duplicate messages */
                                plumbfree(m);
                                continue;
       -
       -                Found:
       -                        xtime = parsedate(value(m->attr, "date", date));
       -                        digestp = value(m->attr, "digest", nil);
       -                        if(alreadyseen(digestp)){
       -                                /* duplicate upas/fs can send duplicate messages */
       -                                plumbfree(m);
       -                                continue;
       -                        }
       -                        senderp = estrdup(value(m->attr, "sender", "???"));
       -                        showmailp = estrdup(m->data);
       -                        if(digestp)
       -                                digestp = estrdup(digestp);
       -                        plumbfree(m);
       -                }else{
       -                        if(logrecv(&senderp, &xtime) <= 0)
       -                                killall("error reading log file");
       -                        showmailp = estrdup("");
       -                        digestp = nil;
                        }
       -                setname(f, senderp);
       -                f->time = xtime;
       -                f->tm = *localtime(xtime);
       -                f->str[Sshow] = showmailp;
       -                f->str[Sdigest] = digestp;
       -                return f;
       +                senderp = estrdup(value(m->attr, "sender", "???"));
       +                showmailp = estrdup(m->data);
       +                if(digestp)
       +                        digestp = estrdup(digestp);
       +                plumbfree(m);
                }
                return nil;
        }
       t@@ -332,6 +234,8 @@ iline(char *data, char **pp)
        {
                char *p;
        
       +        if(*data == 0)
       +                return nil;
                for(p=data; *p!='\0' && *p!='\n'; p++)
                        ;
                if(*p == '\n')
       t@@ -344,28 +248,16 @@ Face*
        dirface(char *dir, char *num)
        {
                Face *f;
       -        char *from, *date;
       -        char buf[1024],  *info, *p, *digest;
       +        char buf[1024],  *fld[3], *info, *p, *t, *s;
                int n;
                ulong len;
                CFid *fid;
        
       -#if 0
       -        /*
       -         * loadmbox leaves us in maildir, so we needn't
       -         * walk /mail/fs/mbox for each face; this makes startup
       -         * a fair bit quicker.
       -         */
       -        if(getwd(pwd, sizeof pwd) != nil && strcmp(pwd, dir) == 0)
       -                sprint(buf, "%s/info", num);
       -        else
       -                sprint(buf, "%s/%s/info", dir, num);
       -#endif
                sprint(buf, "%s/%s/info", dir, num);
       -        len = fsdirlen(upasfs, buf);
       +        len = fsdirlen(mailfs, buf);
                if(len <= 0)
                        return nil;
       -        fid = fsopen(upasfs,buf, OREAD);
       +        fid = fsopen(mailfs, buf, OREAD);
                if(fid == nil)
                        return nil;
                info = emalloc(len+1);
       t@@ -377,22 +269,22 @@ dirface(char *dir, char *num)
                }
                info[n] = '\0';
                f = emalloc(sizeof(Face));
       -        from = iline(info, &p);        /* from */
       -        iline(p, &p);        /* to */
       -        iline(p, &p);        /* cc */
       -        iline(p, &p);        /* replyto */
       -        date = iline(p, &p);        /* date */
       -        setname(f, estrdup(from));
       -        f->time = parsedate(date);
       -        f->tm = *localtime(f->time);
       +        for(p=info; (s=iline(p, &p)) != nil; ){
       +                t = strchr(s, ' ');
       +                if(t == nil)
       +                        continue;
       +                *t++ = 0;
       +                if(strcmp(s, "unixdate") == 0){
       +                        f->time = atoi(t);
       +                        f->tm = *localtime(f->time);
       +                }
       +                else if(strcmp(s, "from") == 0 && tokenize(t, fld, 3) >= 2)
       +                        setname(f, estrdup(fld[1]));
       +                else if(strcmp(s, "digest") == 0)
       +                        f->str[Sdigest] = estrdup(t);
       +        }
                sprint(buf, "%s/%s", dir, num);
                f->str[Sshow] = estrdup(buf);
       -        iline(p, &p);        /* subject */
       -        iline(p, &p);        /* mime content type */
       -        iline(p, &p);        /* mime disposition */
       -        iline(p, &p);        /* filename */
       -        digest = iline(p, &p);        /* digest */
       -        f->str[Sdigest] = estrdup(digest);
                free(info);
                return f;
        }
   DIR diff --git a/src/cmd/upas/common/aux.c b/src/cmd/upas/common/aux.c
       t@@ -30,8 +30,8 @@ append_match(Resub *subexp, String *sp, int se)
        {
                char *cp, *ep;
        
       -        cp = subexp[se].s.sp;    /* jpc .sp -> .s.sp */
       -        ep = subexp[se].e.ep;    /* jpc .ep -> .e.ep */
       +        cp = subexp[se].s.sp;
       +        ep = subexp[se].e.ep;
                for (; cp < ep; cp++)
                        s_putc(sp, *cp);
                s_terminate(sp);
       t@@ -53,7 +53,7 @@ shellchars(char *cp)
                return 0;
        }
        
       -static char *specialchars = " ()<>{};=\\'\`^&|";
       +static char *specialchars = " ()<>{};=\\'`^&|";
        static char *escape = "%%";
        
        int
   DIR diff --git a/src/cmd/upas/common/config.c b/src/cmd/upas/common/config.c
       t@@ -9,3 +9,19 @@ char *SHELL =                 "#9/bin/rc";
        char *POST =                "#9/sys/lib/post/dispatch";
        
        int MBOXMODE = 0662;
       +
       +void
       +upasconfig(void)
       +{
       +        static int did;
       +        
       +        if(did)
       +                return;
       +        did = 1;
       +        MAILROOT = unsharp(MAILROOT);
       +        UPASLOG = unsharp(UPASLOG);
       +        UPASLIB = unsharp(UPASLIB);
       +        UPASBIN = unsharp(UPASBIN);
       +        SHELL = unsharp(SHELL);
       +        POST = unsharp(POST);
       +}
   DIR diff --git a/src/cmd/upas/common/libcommon.a b/src/cmd/upas/common/libcommon.a
       Binary files differ.
   DIR diff --git a/src/cmd/upas/common/libsys.c b/src/cmd/upas/common/libsys.c
       t@@ -33,24 +33,7 @@ getlog(void)
        {
                return getuser();
        }
       -#if 0  /* jpc */
       -extern char *
       -getlog(void)
       -{
       -        static char user[64];
       -        int fd;
       -        int n;
        
       -        fd = open("/dev/user", 0);
       -        if(fd < 0)
       -                return nil;
       -        if((n=read(fd, user, sizeof(user)-1)) <= 0)
       -                return nil;
       -        close(fd);
       -        user[n] = 0;
       -        return user;
       -}
       -#endif /* jpc */
        /*
         *  return the lock name (we use one lock per directory)
         */
       t@@ -704,64 +687,17 @@ pipesigoff(void)
                atnotify(catchpipe, 0);
        }
        
       -void
       -exit9(int i)
       -{
       -        char buf[32];
       -
       -        if(i == 0)
       -                exits(0);
       -        snprint(buf, sizeof(buf), "%d", i);
       -        exits(buf);
       -}
       -
       -static int
       -islikeatty(int fd)
       -{
       -        Dir *d;
       -        int rv;
       -
       -        d = dirfstat(fd);
       -        if(d == nil)
       -                return 0;
       -        rv = strcmp(d->name, "cons") == 0;
       -        free(d);
       -        return rv;
       -}
       -
       -#if 0
       -/* jpc */
       -static int
       -islikeatty(int fd)
       -{
       -        char buf[64];
       -
       -        if(fd2path(fd, buf, sizeof buf) != 0)
       -                return 0;
       -
       -        /* might be /mnt/term/dev/cons */
       -        return strlen(buf) >= 9 && strcmp(buf+strlen(buf)-9, "/dev/cons") == 0;
       -}
       -#endif
       -
        extern int
        holdon(void)
        {
       -        int fd;
       -
       -        if(!islikeatty(0))
       -                return -1;
       -
       -        fd = open("/dev/consctl", OWRITE);
       -        write(fd, "holdon", 6);
       -
       -        return fd;
       +        /* XXX talk to 9term? */
       +        return -1;
        }
        
        extern int
        sysopentty(void)
        {
       -        return open("/dev/cons", ORDWR);
       +        return open("/dev/tty", ORDWR);
        }
        
        extern void
       t@@ -786,11 +722,13 @@ sysfiles(void)
        extern String *
        mboxpath(char *path, char *user, String *to, int dot)
        {
       +        upasconfig();
       +
                if (dot || *path=='/' || strncmp(path, "./", 2) == 0
                                      || strncmp(path, "../", 3) == 0) {
                        to = s_append(to, path);
                } else {
       -                to = s_append(to, unsharp(MAILROOT));
       +                to = s_append(to, MAILROOT);
                        to = s_append(to, "/box/");
                        to = s_append(to, user);
                        to = s_append(to, "/");
       t@@ -885,35 +823,7 @@ username(String *from)
        char *
        remoteaddr(int fd, char *dir)
        {
       -        char buf[128], *p;
       -        int n;
       -
       -        if(dir == 0){
       -                fprint(2,"remoteaddr: called fd2path: fixme\n"); /* jpc
       -                if(fd2path(fd, buf, sizeof(buf)) != 0)
       -                        return ""; */
       -
       -                /* parse something of the form /net/tcp/nnnn/data */
       -                p = strrchr(buf, '/');
       -                if(p == 0)
       -                        return "";
       -                strncpy(p+1, "remote", sizeof(buf)-(p-buf)-2);
       -        } else
       -                snprint(buf, sizeof buf, "%s/remote", dir);
       -        buf[sizeof(buf)-1] = 0;
       -
       -        fd = open(buf, OREAD);
       -        if(fd < 0)
       -                return "";
       -        n = read(fd, buf, sizeof(buf)-1);
       -        close(fd);
       -        if(n > 0){
       -                buf[n] = 0;
       -                p = strchr(buf, '!');
       -                if(p)
       -                        *p = 0;
       -                return strdup(buf);
       -        }
       +        /* XXX should call netconninfo */
                return "";
        }
        
   DIR diff --git a/src/cmd/upas/common/mkfile b/src/cmd/upas/common/mkfile
       t@@ -2,19 +2,17 @@
        
        LIB=libcommon.a
        
       -OFILES=aux.$O\
       -        become.$O\
       +OFILES=\
       +        appendfiletombox.$O\
       +        aux.$O\
       +        config.$O\
       +        libsys.$O\
                mail.$O\
                process.$O\
       -        libsys.$O\
       -        config.$O\
       -        appendfiletombox.$O\
        
       -HFILES=common.h\
       +HFILES=\
       +        common.h\
                sys.h\
        
        <$PLAN9/src/mklib
        
       -nuke:V:
       -        mk clean
       -        rm -f libcommon.a
   DIR diff --git a/src/cmd/upas/common/process.c b/src/cmd/upas/common/process.c
       t@@ -93,10 +93,8 @@ noshell_proc_start(char **av, stream *inp, stream *outp, stream *errp, int newpg
                                        dup(pp->std[i]->fd, i);
                        for (n = sysfiles(); i < n; i++)
                                close(i);
       -                if(who) {
       -                        fprint(2,"process.c: trying to become(%s,%s)\n",av,who);
       -                        // jpc become(av, who);
       -                }
       +                if(who)
       +                        fprint(2, "warning: cannot run %s as %s\n", av[0], who);
                        exec(av[0], av);
                        perror("proc_start");
                        exits("proc_start");
       t@@ -116,7 +114,8 @@ proc_start(char *cmd, stream *inp, stream *outp, stream *errp, int newpg, char *
        {
                char *av[4];
        
       -        av[0] = unsharp(SHELL);
       +        upasconfig();
       +        av[0] = SHELL;
                av[1] = "-c";
                av[2] = cmd;
                av[3] = 0;
   DIR diff --git a/src/cmd/upas/common/sys.h b/src/cmd/upas/common/sys.h
       t@@ -6,7 +6,7 @@
        #include <libc.h>
        #include <regexp.h>
        #include <bio.h>
       -#include "libString.h"   /* jpc String.h -> libString.h */
       +#include <libString.h>
        
        /*
         *  for the lock routines in libsys.c
       t@@ -19,7 +19,7 @@ struct Mlock {
        };
        
        /*
       - *  from config.c
       + *  from config.c - call upasconfig() before using
         */
        extern char *MAILROOT;        /* root of mail system */
        extern char *UPASLOG;        /* log directory */
       t@@ -29,6 +29,7 @@ extern char *UPASTMP;        /* temporary directory */
        extern char *SHELL;        /* path name of shell */
        extern char *POST;        /* path name of post server addresses */
        extern int MBOXMODE;        /* default mailbox protection mode */
       +extern void upasconfig(void);
        
        /*
         *  files in libsys.c
       t@@ -58,7 +59,6 @@ extern int        syskill(int);
        extern int        syskillpg(int);
        extern int        syscreate(char*, int, ulong);
        extern Mlock        *trylock(char *);
       -extern void        exit9(int);
        extern void        pipesig(int*);
        extern void        pipesigoff(void);
        extern int        holdon(void);
   DIR diff --git a/src/cmd/upas/fs/pop3.c b/src/cmd/upas/fs/pop3.c
       t@@ -231,10 +231,8 @@ pop3login(Pop *pop)
                        if(pop->needtls && !pop->encrypted)
                                return "could not negotiate TLS";
        
       -                up = auth_getuserpasswd(auth_getkey, "role=client proto=pass service=pop dom=%q%s",
       +                up = auth_getuserpasswd(auth_getkey, "proto=pass role=client service=pop dom=%q%s",
                                pop->host, ubuf);
       -                /* up = auth_getuserpasswd(auth_getkey, "proto=pass service=pop dom=%q%s",
       -                        pop->host, ubuf); jpc */
                        if(up == nil)
                                return "no usable keys found";