Deleted Added
sdiff udiff text old ( 96216 ) new ( 96701 )
full compact
1/*
2 * at.c : Put file into atrun queue
3 * Copyright (C) 1993, 1994 Thomas Koenig
4 *
5 * Atrun & Atq modifications
6 * Copyright (C) 1993 David Parsons
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 13 unchanged lines hidden (view full) ---

22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/usr.bin/at/at.c 96216 2002-05-08 11:23:45Z kuriyama $");
31
32#define _USE_BSD 1
33
34/* System Headers */
35
36#include <sys/param.h>
37#include <sys/stat.h>
38#include <sys/time.h>

--- 76 unchanged lines hidden (view full) ---

115char *namep;
116
117/* Function declarations */
118
119static void sigc(int signo);
120static void alarmc(int signo);
121static char *cwdname(void);
122static void writefile(time_t runtimer, char queue);
123static void list_jobs(void);
124static long nextjob(void);
125static time_t ttime(const char *arg);
126
127/* Signal catching functions */
128
129static void sigc(int signo __unused)
130{
131/* If the user presses ^C, remove the spool file and exit
132 */
133 if (fcreated)

--- 306 unchanged lines hidden (view full) ---

440
441 if (fchmod(fd2, S_IRUSR | S_IWUSR | S_IXUSR) < 0)
442 perr("cannot give away file");
443
444 close(fd2);
445 fprintf(stderr, "Job %ld will be executed using /bin/sh\n", jobno);
446}
447
448static void
449list_jobs()
450{
451 /* List all a user's jobs in the queue, by looping through ATJOB_DIR,
452 * or everybody's if we are root
453 */
454 struct passwd *pw;
455 DIR *spool;
456 struct dirent *dirent;
457 struct stat buf;

--- 29 unchanged lines hidden (view full) ---

487 if (!S_ISREG(buf.st_mode)
488 || ((buf.st_uid != real_uid) && ! (real_uid == 0))
489 || !(S_IXUSR & buf.st_mode || atverify))
490 continue;
491
492 if(sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm)!=3)
493 continue;
494
495 if (atqueue && (queue != atqueue))
496 continue;
497
498 runtimer = 60*(time_t) ctm;
499 runtime = *localtime(&runtimer);
500 strftime(timestr, TIMESIZE, "%+", &runtime);
501 if (first) {
502 printf("Date\t\t\t\tOwner\t\tQueue\tJob#\n");

--- 157 unchanged lines hidden (view full) ---

660 if (tv[0].tv_sec != -1)
661 return tv[0].tv_sec;
662 else
663terr:
664 panic(
665 "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]");
666}
667
668int
669main(int argc, char **argv)
670{
671 int c;
672 char queue = DEFAULT_AT_QUEUE;
673 char queue_set = 0;
674 char *pgm;
675
676 int program = AT; /* our default program */
677 const char *options = "q:f:t:rmvldbc"; /* default options for at */
678 time_t timer;
679
680 timer = -1;
681 RELINQUISH_PRIVS
682
683 /* Eat any leading paths
684 */
685 if ((pgm = strrchr(argv[0], '/')) == NULL)
686 pgm = argv[0];
687 else

--- 62 unchanged lines hidden (view full) ---

750 timer = ttime(optarg);
751 break;
752
753 case 'l':
754 if (program != AT)
755 usage();
756
757 program = ATQ;
758 options = "q:v";
759 break;
760
761 case 'b':
762 if (program != AT)
763 usage();
764
765 program = BATCH;
766 options = "f:q:mv";

--- 15 unchanged lines hidden (view full) ---

782 */
783 if(!check_permission())
784 errx(EXIT_FAILURE, "you do not have permission to use this program");
785 switch (program) {
786 case ATQ:
787
788 REDUCE_PRIV(DAEMON_UID, DAEMON_GID)
789
790 list_jobs();
791 break;
792
793 case ATRM:
794
795 REDUCE_PRIV(DAEMON_UID, DAEMON_GID)
796
797 process_jobs(argc, argv, ATRM);
798 break;

--- 48 unchanged lines hidden ---