X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/a68924a6e07d69bc4b8d6106b3af0ac5a7490905..31cef89cb428866f787983e68246030321893df4:/usr/src/cmd/atrun.c diff --git a/usr/src/cmd/atrun.c b/usr/src/cmd/atrun.c index e997fad983..7e8c225a6c 100644 --- 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. */ @@ -20,8 +21,8 @@ char **argv; { int tt, day, year, uniq; struct direct dirent; - char file[DIRSIZ+1]; FILE *dirf; + char file[DIRSIZ+1]; chdir(DIR); makenowtime(); @@ -32,7 +33,7 @@ char **argv; while (fread((char *)&dirent, sizeof(dirent), 1, dirf) == 1) { if (dirent.d_ino==0) continue; - strncpy(file, dirent.d_name, DIRSIZ); + strcpyn(file, dirent.d_name, DIRSIZ); file[DIRSIZ] = '\0'; if (sscanf(file, "%2d.%3d.%4d.%2d", &year, &day, &tt, &uniq) != 4) continue; @@ -81,18 +82,18 @@ char *file; 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))); - 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); - setgid(stbuf.st_gid); - setuid(stbuf.st_uid); if (pid = fork()) { if (pid == -1) exit(1); @@ -100,7 +101,8 @@ char *file; 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");