diff options
author | rsc <devnull@localhost> | 2006-02-08 22:39:54 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-02-08 22:39:54 +0000 |
commit | 605c0ea102e334b6c05d635ca0e5b93bad0031ec (patch) | |
tree | 47733670b8c009cd358046ad7b6cdefc7096644a /src/cmd/upas/common | |
parent | 5a1e9de7b160033e85a77ad4c60193186364a2fb (diff) | |
download | plan9port-605c0ea102e334b6c05d635ca0e5b93bad0031ec.tar.gz plan9port-605c0ea102e334b6c05d635ca0e5b93bad0031ec.tar.bz2 plan9port-605c0ea102e334b6c05d635ca0e5b93bad0031ec.zip |
cleanup
Diffstat (limited to 'src/cmd/upas/common')
-rw-r--r-- | src/cmd/upas/common/aux.c | 6 | ||||
-rw-r--r-- | src/cmd/upas/common/config.c | 16 | ||||
-rw-r--r-- | src/cmd/upas/common/libcommon.a | bin | 251056 -> 67236 bytes | |||
-rw-r--r-- | src/cmd/upas/common/libsys.c | 104 | ||||
-rw-r--r-- | src/cmd/upas/common/mkfile | 16 | ||||
-rw-r--r-- | src/cmd/upas/common/process.c | 9 | ||||
-rw-r--r-- | src/cmd/upas/common/sys.h | 6 |
7 files changed, 40 insertions, 117 deletions
diff --git a/src/cmd/upas/common/aux.c b/src/cmd/upas/common/aux.c index 7577acae..6e8001ca 100644 --- a/src/cmd/upas/common/aux.c +++ b/src/cmd/upas/common/aux.c @@ -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); @@ -53,7 +53,7 @@ shellchars(char *cp) return 0; } -static char *specialchars = " ()<>{};=\\'\`^&|"; +static char *specialchars = " ()<>{};=\\'`^&|"; static char *escape = "%%"; int diff --git a/src/cmd/upas/common/config.c b/src/cmd/upas/common/config.c index 4bbaff83..21b34a12 100644 --- a/src/cmd/upas/common/config.c +++ b/src/cmd/upas/common/config.c @@ -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); +} diff --git a/src/cmd/upas/common/libcommon.a b/src/cmd/upas/common/libcommon.a Binary files differindex 7266859d..c767d7ce 100644 --- a/src/cmd/upas/common/libcommon.a +++ b/src/cmd/upas/common/libcommon.a diff --git a/src/cmd/upas/common/libsys.c b/src/cmd/upas/common/libsys.c index 67f36798..a9d4f0f8 100644 --- a/src/cmd/upas/common/libsys.c +++ b/src/cmd/upas/common/libsys.c @@ -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) */ @@ -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 @@ -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, "/"); @@ -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 ""; } diff --git a/src/cmd/upas/common/mkfile b/src/cmd/upas/common/mkfile index 8cfaf267..5cd01233 100644 --- a/src/cmd/upas/common/mkfile +++ b/src/cmd/upas/common/mkfile @@ -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 diff --git a/src/cmd/upas/common/process.c b/src/cmd/upas/common/process.c index 16b21aef..56725a88 100644 --- a/src/cmd/upas/common/process.c +++ b/src/cmd/upas/common/process.c @@ -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"); @@ -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; diff --git a/src/cmd/upas/common/sys.h b/src/cmd/upas/common/sys.h index 960aebb3..50691558 100644 --- a/src/cmd/upas/common/sys.h +++ b/src/cmd/upas/common/sys.h @@ -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 @@ -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 */ @@ -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 @@ -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); |