ctime: avoid fd leak when /env/timezone is missing
[rsc] --rw-rw-r-- M 628694 glenda sys 4935 Apr 10 11:20 sys/src/libc/9sys/ctime.c
/n/sourcesdump/2006/0410/plan9/sys/src/libc/9sys/ctime.c:219,226 -
/n/sourcesdump/2006/0411/plan9/sys/src/libc/9sys/ctime.c:219,228
i = open("/env/timezone", 0);
if(i < 0)
goto error;
- if(read(i, buf, sizeof(buf)) >= sizeof(buf))
+ if(read(i, buf, sizeof(buf)) >= sizeof(buf)){
+ close(i);
goto error;
+ }
close(i);
p = buf;
if(rd_name(&p, timezone.stname))
upas cron: clean up after greylist
[rsc] --rw-rw-r-- M 628694 glenda sys 222 Apr 10 11:41 cron/upas/cron
/n/sourcesdump/2006/0410/plan9/cron/upas/cron:2,5 -
/n/sourcesdump/2006/0411/plan9/cron/upas/cron:2,5
0,10,20,30,40,50 * * * * mailserver /bin/upas/runq -a /mail/queue /mail/lib/remotemail
# clean up after grey list
- 47 4 * * * mailserver cd /mail/grey && rm -f [0-9]*.[0-9]*.[0-9]*.[0-9]*
+ 47 4 * * * mailserver rm -rf /mail/grey/tmp/*/*
upas/smtp: move greylist files into /mail/grey/tmp, /mail/grey/whitelist
change whitelist format to be more tool-friendly
[rsc] --rw-rw-r-- M 628694 presotto sys 6514 Apr 10 11:41 sys/src/cmd/upas/smtp/greylist.c
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:23,39 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:23,39
enum {
Nonspammax = 14*60*60, /* must call back within this time if real */
};
- static char whitelist[] = "/mail/lib/whitelist";
+ static char whitelist[] = "/mail/grey/whitelist";
/*
* matches ip addresses or subnets in whitelist against nci->rsys.
- * ignores comments and blank lines in /mail/lib/whitelist.
+ * ignores comments and blank lines in /mail/grey/whitelist.
*/
static int
onwhitelist(void)
{
int lnlen;
- char *line, *parse;
+ char *line, *parse, *p;
char input[128];
uchar ip[IPaddrlen], ipmasked[IPaddrlen];
uchar mask4[IPaddrlen], addr4[IPaddrlen];
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:52,66 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:52,70
if (wl == nil)
return 1;
while ((line = Brdline(wl, '\n')) != nil) {
- if (line[0] == '#' || line[0] == '\n')
- continue;
lnlen = Blinelen(wl);
line[lnlen-1] = '\0'; /* clobber newline */
+ p = strpbrk(line, " \t");
+ if (p)
+ *p = 0;
+ if (line[0] == '#' || line[0] == 0)
+ continue;
+
/* default mask is /32 (v4) or /128 (v6) for bare IP */
parse = line;
if (strchr(line, '/') == nil) {
- strncpy(input, line, sizeof input - 5);
+ strecpy(input, input+sizeof input-5, line);
if (strchr(line, '.') != nil)
strcat(input, "/32");
else
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:219,225 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:223,229
user++;
/* check & try to update the grey list entry */
- snprint(file, sizeof file, "/mail/grey/%s/%s/%s",
+ snprint(file, sizeof file, "/mail/grey/tmp/%s/%s/%s",
nci->lsys, nci->rsys, user);
memset(gsp, 0, sizeof *gsp);
addgreylist(file, gsp);
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/upas/smtp/greylist.c:259,267 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/upas/smtp/greylist.c:263,271
if (fd >= 0) {
seek(fd, 0, 2); /* paranoia */
if ((fqdn = csgetvalue(nil, "ip", nci->rsys, "dom", nil)) != nil)
- fprint(fd, "# %s\n%s\n\n", fqdn, nci->rsys);
+ fprint(fd, "%s %s\n", nci->rsys, fqdn);
else
- fprint(fd, "# unknown\n%s\n\n", nci->rsys);
+ fprint(fd, "%s\n", nci->rsys);
close(fd);
}
} else {
[rsc] --rw-rw-r-- M 628694 rsc sys 2813 Apr 10 11:35 dist/replica/plan9.proto
/n/sourcesdump/2006/0410/plan9/dist/replica/plan9.proto:14,20 -
/n/sourcesdump/2006/0411/plan9/dist/replica/plan9.proto:14,22
faxoutqueue d777 upas upas
faxqueue d777 upas upas
* - upas upas
- grey d777 upas upas
+ grey d775 upas upas
+ whitelist a666 upas upas
+ tmp d777 upas upas
fs - upas upas
lib - upas upas
+ - upas upas
9fs: use srv to retry dial when necessary
[rsc] --rwxrwxr-x M 628694 glenda sys 927 Apr 10 12:08 rc/bin/9fs
/n/sourcesdump/2006/0410/plan9/rc/bin/9fs:20,42 -
/n/sourcesdump/2006/0411/plan9/rc/bin/9fs:20,39
case juke
srv -q il!jukefs && mount /srv/il!jukefs /n/njuke && bind -c /n/njuke/juke /n/juke
case sources
- srv -q tcp!sources.cs.bell-labs.com sources
- mount -n /srv/sources /n/sources
+ srv -nq tcp!sources.cs.bell-labs.com sources /n/sources
case sourcesdump
9fs sources
- mount /srv/sources /n/sourcesdump main/archive
+ mount -n /srv/sources /n/sourcesdump main/archive
case sourcessnap
9fs sources
- mount /srv/sources /n/sourcessnap main/snapshot
+ mount -n /srv/sources /n/sourcessnap main/snapshot
case wiki
- srv 'net!plan9.bell-labs.com!wiki' wiki
- mount /srv/wiki /mnt/wiki
+ srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki
case *
switch($#*){
case 1
srv -m $1
case *
- srv $1
- mount -c /srv/$1 $2
+ srv -m $1 $1 $2
}
}
leak(1): add kmem to heading
[rsc] --rw-rw-r-- M 628694 glenda sys 3291 Apr 10 12:09 sys/man/1/leak
/n/sourcesdump/2006/0410/plan9/sys/man/1/leak:1,6 -
/n/sourcesdump/2006/0411/plan9/sys/man/1/leak:1,6
.TH LEAK 1
.SH NAME
- leak \- examine family of processes for memory leaks
+ leak, kmem \- help find memory leaks
.SH SYNOPSIS
.B leak
[
rc(1): document -m
[rsc] --rw-rw-r-- M 628694 glenda sys 20019 Apr 10 12:11 sys/man/1/rc
/n/sourcesdump/2006/0410/plan9/sys/man/1/rc:7,15 -
/n/sourcesdump/2006/0411/plan9/sys/man/1/rc:7,20
.B -srdiIlxepvV
]
[
- .B -c command
+ .B -c
+ .I command
]
[
+ .B -m
+ .I initial
+ ]
+ [
.I file
[
.I arg ...
/n/sourcesdump/2006/0410/plan9/sys/man/1/rc:937,942 -
/n/sourcesdump/2006/0411/plan9/sys/man/1/rc:942,955
reads commands from
.BR $home/lib/profile ,
if it exists, before reading its normal input.
+ .TP
+ .B -m
+ Read commands to initialize
+ .I rc
+ from
+ .I initial
+ instead of from
+ .BR /rc/lib/rcmain .
.TP
.B -p
A no-op.
webfs: use new content-type in redirects
[rsc] --rw-rw-r-- M 628694 glenda sys 9503 Apr 10 12:10 sys/src/cmd/webfs/http.c
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/webfs/http.c:37,44 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/webfs/http.c:37,45
static void
contenttype(HttpState *hs, char *value)
{
- if(hs->c->contenttype == nil)
- hs->c->contenttype = estrdup(value);
+ if(hs->c->contenttype != nil)
+ free(hs->c->contenttype);
+ hs->c->contenttype = estrdup(value);
}
static void
ps: add -r flag (sorry)
[rsc] --rw-rw-r-- M 628694 glenda sys 2783 Apr 10 12:31 sys/src/cmd/ps.c
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:9,14 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:9,15
Biobuf bout;
int pflag;
int aflag;
+ int rflag;
void
main(int argc, char *argv[])
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:24,29 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:25,33
case 'p':
pflag++;
break;
+ case 'r':
+ rflag++;
+ break;
} ARGEND;
Binit(&bout, 1, OWRITE);
if(chdir("/proc")==-1)
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:54,62 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:58,66
void
ps(char *s)
{
- ulong utime, stime, size;
+ ulong utime, stime, rtime, size;
int argc, basepri, fd, i, n, pri;
- char args[256], *argv[16], buf[64], pbuf[8], status[4096];
+ char args[256], *argv[16], buf[64], pbuf[8], rbuf[20], rbuf1[20], status[4096];
sprint(buf, "%s/status", s);
fd = open(buf, OREAD);
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:83,88 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:87,93
*/
utime = strtoul(argv[3], 0, 0)/1000;
stime = strtoul(argv[4], 0, 0)/1000;
+ rtime = strtoul(argv[5], 0, 0)/1000;
size = strtoul(argv[9], 0, 0);
if(pflag){
basepri = strtoul(argv[10], 0, 0);
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:90,98 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:95,116
sprint(pbuf, " %2d %2d", basepri, pri);
} else
pbuf[0] = 0;
- Bprint(&bout, "%-10s %8s %4lud:%.2lud %3lud:%.2lud%s %7ludK %-8.8s ",
+
+ if(rflag){
+ if(rtime >= 86400)
+ sprint(rbuf, " %lud:%02lud:%02lud:%02lud", rtime/86400, (rtime/3600)%24, (rtime/60)%60, rtime%60);
+ else if(rtime >= 3600)
+ sprint(rbuf, " %lud:%02lud:%02lud", rtime/3600, (rtime/60)%60, rtime%60);
+ else
+ sprint(rbuf, " %lud:%02lud", rtime/60, rtime%60);
+ sprint(rbuf1, "%12s", rbuf);
+ }else
+ rbuf1[0] = 0;
+
+ Bprint(&bout, "%-10s %8s%s %4lud:%.2lud %3lud:%.2lud %s %7ludK %-8.8s ",
argv[1],
s,
+ rbuf1,
utime/60, utime%60,
stime/60, stime%60,
pbuf,
[rsc] --rw-rw-r-- M 628694 glenda sys 1722 Apr 10 12:31 sys/man/1/ps
/n/sourcesdump/2006/0410/plan9/sys/man/1/ps:4,15 -
/n/sourcesdump/2006/0411/plan9/sys/man/1/ps:4,15
.SH SYNOPSIS
.B ps
[
- .B -pa
+ .B -apr
]
.PP
.B psu
[
- .B -pa
+ .B -apr
]
[
.I user
/n/sourcesdump/2006/0410/plan9/sys/man/1/ps:82,92 -
/n/sourcesdump/2006/0411/plan9/sys/man/1/ps:82,98
.IR resource .
.PD
.PP
- With the
+ The
+ .B -r
+ flag causes
+ .I ps
+ to print, before the user time, the elapsed real time for the process.
+ .PP
+ The
.B -p
- flag,
+ flag causes
.I ps
- also prints, after the system time, the baseline and current priorities of each process.
+ to print, after the system time, the baseline and current priorities of each process.
.PP
The
.B -a
srv: add -n flag like in mount
[rsc] --rw-rw-r-- M 628694 glenda sys 4003 Apr 10 12:07 sys/src/cmd/srv.c
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/srv.c:10,15 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/srv.c:10,16
void rpc(int, int);
void post(char*, int);
void mountfs(char*, int);
+ int doauth = 1;
void
usage(void)
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/srv.c:105,110 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/srv.c:106,114
domount = 1;
reallymount = 1;
break;
+ case 'n':
+ doauth = 0;
+ break;
case 'q':
domount = 1;
reallymount = 0;
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/srv.c:193,199 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/srv.c:197,204
if(domount == 0 || reallymount == 0)
exits(0);
- if(amount(fd, mtpt, mountflag, "") < 0){
+ if((!doauth && mount(fd, -1, mtpt, mountflag, "") < 0)
+ || (doauth && amount(fd, mtpt, mountflag, "") < 0)){
err[0] = 0;
errstr(err, sizeof err);
if(strstr(err, "Hangup") || strstr(err, "hungup") || strstr(err, "timed out")){
[rsc] --rw-rw-r-- M 628694 glenda sys 4672 Apr 10 13:32 sys/man/4/srv
/n/sourcesdump/2006/0410/plan9/sys/man/4/srv:4,10 -
/n/sourcesdump/2006/0411/plan9/sys/man/4/srv:4,10
.SH SYNOPSIS
.B srv
[
- .B -abceCmq
+ .B -abceCmnq
]
[
.B -s
/n/sourcesdump/2006/0410/plan9/sys/man/4/srv:107,116 -
/n/sourcesdump/2006/0411/plan9/sys/man/4/srv:107,119
.BR a ,
.BR b ,
.BR c ,
+ .BR C ,
and
- .B C
+ .B n
flags are used to control the mount flag as in
- .IR bind (1).
+ .I mount
+ (see
+ .IR bind (1)).
The
.B e
flag causes
cc: add C99 variadic macros
[rsc] --rw-rw-r-- M 628694 rsc sys 1302 Apr 10 13:27 sys/src/cmd/cc/c99
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cc/c99:14,19 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cc/c99:14,20
26. _Bool, float _Complex, double _Complex, long double _Complex
Done:
+ 7. __VA_ARGS__
11, 30, 31, 32. restrict, inline
12. Allow declarations anywhere.
15. for loop declarations
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cc/c99:40,46 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cc/c99:41,46
4. __STDC_VERSION__
5. __STDC_IEC_559__, __STDC_IEC_559_COMPLEX__,
__STDC_ISO_10646__
- 7. __VA_ARGS__
13. Digraph tokens
23. __func__ identifier
[rsc] --rw-rw-r-- M 628694 glenda sys 12205 Apr 10 13:26 sys/src/cmd/cc/macbody
[diffs elided - too long]
[diff -c /n/sourcesdump/2006/0410/plan9/sys/src/cmd/cc/macbody /n/sourcesdump/2006/0411/plan9/sys/src/cmd/cc/macbody]
cpp: add C99 variadic macros
[rsc] --rw-rw-r-- M 628694 glenda sys 4707 Apr 10 13:53 sys/src/cmd/cpp/cpp.h
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/cpp.h:27,32 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/cpp.h:27,33
#define ISKW 02 /* is PP keyword */
#define ISUNCHANGE 04 /* can't be #defined in PP */
#define ISMAC 010 /* builtin macro, e.g. __LINE__ */
+ #define ISVARMAC 020 /* variadic macro */
#define EOB 0xFE /* sentinel for end of input buffer */
#define EOFC 0xFD /* sentinel for end of input file */
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/cpp.h:110,116 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/cpp.h:111,117
void doif(Tokenrow *, enum kwtype);
void expand(Tokenrow *, Nlist *);
void builtin(Tokenrow *, int);
- int gatherargs(Tokenrow *, Tokenrow **, int *);
+ int gatherargs(Tokenrow *, Tokenrow **, int, int *);
void substargs(Nlist *, Tokenrow *, Tokenrow **);
void expandrow(Tokenrow *, char *);
void maketokenrow(int, Tokenrow *);
[rsc] --rw-rw-r-- M 628694 glenda sys 11287 Apr 10 13:53 sys/src/cmd/cpp/macro.c
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:12,18 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:12,20
Token *tp;
Nlist *np;
Tokenrow *def, *args;
+ int dots;
+ dots = 0;
tp = trp->tp+1;
if (tp>=trp->lp || tp->type!=NAME) {
error(ERROR, "#defined token is not a name");
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:36,42 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:38,46
int err = 0;
for (;;) {
Token *atp;
- if (tp->type!=NAME) {
+ if (tp->type == ELLIPS)
+ dots++;
+ else if (tp->type!=NAME) {
err++;
break;
}
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:51,56 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:55,62
tp += 1;
if (tp->type==RP)
break;
+ if (dots)
+ error(ERROR, "arguments after '...' in macro");
if (tp->type!=COMMA) {
err++;
break;
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:83,88 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:89,96
np->ap = args;
np->vp = def;
np->flag |= ISDEFINED;
+ if(dots)
+ np->flag |= ISVARMAC;
}
/*
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:188,194 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:196,202
if (np->ap==NULL) /* parameterless */
ntokc = 1;
else {
- ntokc = gatherargs(trp, atr, &narg);
+ ntokc = gatherargs(trp, atr, (np->flag&ISVARMAC) ? rowlen(np->ap) : 0, &narg);
if (narg<0) { /* not actually a call (no '(') */
/* error(WARNING, "%d %r\n", narg, trp); */
/* gatherargs has already pushed trp->tr to the next token */
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:229,235 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:237,243
* trp->tp is not changed relative to the tokenrow.
*/
int
- gatherargs(Tokenrow *trp, Tokenrow **atr, int *narg)
+ gatherargs(Tokenrow *trp, Tokenrow **atr, int dots, int *narg)
{
int parens = 1;
int ntok = 0;
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:304,310 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:312,320
parens--;
if (lp->type==DSHARP)
lp->type = DSHARP1; /* ## not special in arg */
- if (lp->type==COMMA && parens==0 || parens<0 && (lp-1)->type!=LP) {
+ if ((lp->type==COMMA && parens==0) || (parens<0 && (lp-1)->type!=LP)) {
+ if (lp->type == COMMA && dots && *narg == dots-1)
+ continue;
if (*narg>=NARG-1)
error(FATAL, "Sorry, too many macro arguments");
ttr.bp = ttr.tp = bp;
/n/sourcesdump/2006/0410/plan9/sys/src/cmd/cpp/macro.c:412,417 -
/n/sourcesdump/2006/0411/plan9/sys/src/cmd/cpp/macro.c:422,429
if (tp->type!=NAME || mac->ap==NULL)
return -1;
+ if((mac->flag & ISVARMAC) && strcmp((char*)tp->t, "__VA_ARGS__") == 0)
+ return rowlen(mac->ap) - 1;
for (ap=mac->ap->bp; ap<mac->ap->lp; ap++) {
if (ap->len==tp->len && strncmp((char*)ap->t,(char*)tp->t,ap->len)==0)
return ap - mac->ap->bp;
|