cleanup
This commit is contained in:
parent
5a1e9de7b1
commit
605c0ea102
11 changed files with 132 additions and 386 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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 "";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue