projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4 release
[unix-history]
/
usr
/
src
/
cmd
/
atrun.c
diff --git
a/usr/src/cmd/atrun.c
b/usr/src/cmd/atrun.c
index
8b01bef
..
7e8c225
100644
(file)
--- a/
usr/src/cmd/atrun.c
+++ b/
usr/src/cmd/atrun.c
@@
-1,3
+1,4
@@
+static char *sccsid = "@(#)atrun.c 4.2 (Berkeley) 10/21/80";
/*
* Run programs submitted by at.
*/
/*
* Run programs submitted by at.
*/
@@
-21,6
+22,7
@@
char **argv;
int tt, day, year, uniq;
struct direct dirent;
FILE *dirf;
int tt, day, year, uniq;
struct direct dirent;
FILE *dirf;
+ char file[DIRSIZ+1];
chdir(DIR);
makenowtime();
chdir(DIR);
makenowtime();
@@
-31,7
+33,9
@@
char **argv;
while (fread((char *)&dirent, sizeof(dirent), 1, dirf) == 1) {
if (dirent.d_ino==0)
continue;
while (fread((char *)&dirent, sizeof(dirent), 1, dirf) == 1) {
if (dirent.d_ino==0)
continue;
- if (sscanf(dirent.d_name, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4)
+ strcpyn(file, dirent.d_name, DIRSIZ);
+ file[DIRSIZ] = '\0';
+ if (sscanf(file, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4)
continue;
if (nowyear < year)
continue;
continue;
if (nowyear < year)
continue;
@@
-39,7
+43,7
@@
char **argv;
continue;
if (nowyear==year && nowdate==day && nowtime < tt)
continue;
continue;
if (nowyear==year && nowdate==day && nowtime < tt)
continue;
- run(
dirent.d_nam
e);
+ run(
fil
e);
}
fclose(dirf);
updatetime(nowtime);
}
fclose(dirf);
updatetime(nowtime);
@@
-78,18
+82,18
@@
char *file;
register pid, i;
char sbuf[64];
register pid, i;
char sbuf[64];
+ /* printf("running %s\n", file); */
if (fork()!=0)
return;
for (i=0; i<15; i++)
close(i);
dup(dup(open("/dev/null", 0)));
if (fork()!=0)
return;
for (i=0; i<15; i++)
close(i);
dup(dup(open("/dev/null", 0)));
- sprintf(sbuf, "/bin/mv %.14s %s", file, PDIR);
- system(sbuf);
+ sprintf(sbuf, "%s/%s", PDIR, file);
+ link(file, sbuf);
+ unlink(file);
chdir(PDIR);
if (stat(file, &stbuf) == -1)
exit(1);
chdir(PDIR);
if (stat(file, &stbuf) == -1)
exit(1);
- setgid(stbuf.st_gid);
- setuid(stbuf.st_uid);
if (pid = fork()) {
if (pid == -1)
exit(1);
if (pid = fork()) {
if (pid == -1)
exit(1);
@@
-97,7
+101,8
@@
char *file;
unlink(file);
exit(0);
}
unlink(file);
exit(0);
}
- nice(3);
+ setgid(stbuf.st_gid);
+ setuid(stbuf.st_uid);
execl("/bin/sh", "sh", file, 0);
execl("/usr/bin/sh", "sh", file, 0);
fprintf(stderr, "Can't execl shell\n");
execl("/bin/sh", "sh", file, 0);
execl("/usr/bin/sh", "sh", file, 0);
fprintf(stderr, "Can't execl shell\n");