summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/at/at.c63
-rw-r--r--usr.bin/at/at.h3
-rw-r--r--usr.bin/at/panic.c21
-rw-r--r--usr.bin/at/panic.h8
-rw-r--r--usr.bin/at/parsetime.c42
-rw-r--r--usr.bin/at/pathnames.h4
-rw-r--r--usr.bin/at/perm.c18
-rw-r--r--usr.bin/at/privs.h52
8 files changed, 91 insertions, 120 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c
index f5f3db26dfd..2ecbbb21eb7 100644
--- a/usr.bin/at/at.c
+++ b/usr.bin/at/at.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: at.c,v 1.25 2002/05/11 23:02:33 millert Exp $ */
+/* $OpenBSD: at.c,v 1.26 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: at.c,v 1.4 1995/03/25 18:13:31 glass Exp $ */
/*
@@ -73,7 +73,7 @@ enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
/* File scope variables */
#ifndef lint
-static char rcsid[] = "$OpenBSD: at.c,v 1.25 2002/05/11 23:02:33 millert Exp $";
+static const char rcsid[] = "$OpenBSD: at.c,v 1.26 2002/05/11 23:16:44 millert Exp $";
#endif
char *no_export[] =
@@ -104,22 +104,20 @@ static time_t ttime(const char *);
/* Signal catching functions */
static void
-sigc(signo)
- int signo;
+sigc(int signo)
{
/* If the user presses ^C, remove the spool file and exit. */
if (fcreated) {
- PRIV_START
+ PRIV_START;
(void)unlink(atfile);
- PRIV_END
+ PRIV_END;
}
_exit(EXIT_FAILURE);
}
static void
-alarmc(signo)
- int signo;
+alarmc(int signo)
{
char buf[1024];
@@ -128,9 +126,9 @@ alarmc(signo)
strlcat(buf, ": File locking timed out\n", sizeof(buf));
write(STDERR_FILENO, buf, strlen(buf));
if (fcreated) {
- PRIV_START
+ PRIV_START;
unlink(atfile);
- PRIV_END
+ PRIV_END;
}
_exit(EXIT_FAILURE);
}
@@ -138,7 +136,7 @@ alarmc(signo)
/* Local functions */
static char *
-cwdname()
+cwdname(void)
{
/*
* Read in the current directory; the name will be overwritten on
@@ -150,7 +148,7 @@ cwdname()
}
static int
-nextjob()
+nextjob(void)
{
int jobno;
FILE *fid;
@@ -171,9 +169,7 @@ nextjob()
}
static void
-writefile(runtimer, queue)
- time_t runtimer;
- char queue;
+writefile(time_t runtimer, char queue)
{
/*
* This does most of the work if at or batch are invoked for
@@ -214,7 +210,7 @@ writefile(runtimer, queue)
* to make sure we're alone when doing this.
*/
- PRIV_START
+ PRIV_START;
/*
* Set an alarm so we don't sleep forever waiting on the lock.
@@ -261,7 +257,7 @@ writefile(runtimer, queue)
if (fchown(fd2, real_uid, real_gid) != 0)
perr("Cannot give away file");
- PRIV_END
+ PRIV_END;
/*
* We've successfully created the file; let's set the flag so it
@@ -408,7 +404,7 @@ writefile(runtimer, queue)
}
static void
-list_jobs()
+list_jobs(void)
{
/*
* List all a user's jobs in the queue, by looping through
@@ -426,7 +422,7 @@ list_jobs()
char timestr[TIMESIZE];
int first = 1;
- PRIV_START
+ PRIV_START;
if (chdir(_PATH_ATJOBS) != 0)
perr2("Cannot change to ", _PATH_ATJOBS);
@@ -470,14 +466,11 @@ list_jobs()
(S_IXUSR & buf.st_mode) ? "" : "(done)",
jobno);
}
- PRIV_END
+ PRIV_END;
}
static void
-process_jobs(argc, argv, what)
- int argc;
- char **argv;
- int what;
+process_jobs(int argc, char **argv, int what)
{
/* Delete every argument (job - ID) given */
int i;
@@ -488,7 +481,7 @@ process_jobs(argc, argv, what)
char queue;
int jobno;
- PRIV_START
+ PRIV_START;
if (chdir(_PATH_ATJOBS) != 0)
perr2("Cannot change to ", _PATH_ATJOBS);
@@ -496,15 +489,15 @@ process_jobs(argc, argv, what)
if ((spool = opendir(".")) == NULL)
perr2("Cannot open ", _PATH_ATJOBS);
- PRIV_END
+ PRIV_END;
/* Loop over every file in the directory */
while((dirent = readdir(spool)) != NULL) {
- PRIV_START
+ PRIV_START;
if (stat(dirent->d_name, &buf) != 0)
perr2("Cannot stat in ", _PATH_ATJOBS);
- PRIV_END
+ PRIV_END;
if (sscanf(dirent->d_name, "%c%5x%8lx", &queue, &jobno, &ctm) !=3)
continue;
@@ -516,12 +509,12 @@ process_jobs(argc, argv, what)
"%s: Not owner\n", argv[i]);
switch (what) {
case ATRM:
- PRIV_START
+ PRIV_START;
if (unlink(dirent->d_name) != 0)
perr(dirent->d_name);
- PRIV_END
+ PRIV_END;
break;
@@ -530,11 +523,11 @@ process_jobs(argc, argv, what)
FILE *fp;
int ch;
- PRIV_START
+ PRIV_START;
fp = fopen(dirent->d_name, "r");
- PRIV_END
+ PRIV_END;
if (!fp)
perr("Cannot open file");
@@ -629,9 +622,7 @@ ttime(const char *arg)
/* Global functions */
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
int c;
char queue = DEFAULT_AT_QUEUE;
@@ -641,7 +632,7 @@ main(argc, argv)
time_t timer;
int tflag = 0;
- RELINQUISH_PRIVS
+ RELINQUISH_PRIVS;
/* find out what this program is supposed to do */
if (strcmp(__progname, "atq") == 0) {
diff --git a/usr.bin/at/at.h b/usr.bin/at/at.h
index 057fd15e7a9..59ba634cf99 100644
--- a/usr.bin/at/at.h
+++ b/usr.bin/at/at.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: at.h,v 1.4 2002/05/11 23:02:33 millert Exp $ */
+/* $OpenBSD: at.h,v 1.5 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: at.h,v 1.2 1995/03/25 18:13:32 glass Exp $ */
/*
@@ -32,7 +32,6 @@ extern char atfile[];
extern char atverify;
#define AT_MAXJOBS 255 /* max jobs outstanding per user */
-#define AT_VERSION 2.9 /* our version number */
#define DEFAULT_BATCH_QUEUE 'E'
#define DEFAULT_AT_QUEUE 'c'
diff --git a/usr.bin/at/panic.c b/usr.bin/at/panic.c
index 87f55e90977..731c2561c6f 100644
--- a/usr.bin/at/panic.c
+++ b/usr.bin/at/panic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: panic.c,v 1.7 2002/05/11 23:02:33 millert Exp $ */
+/* $OpenBSD: panic.c,v 1.8 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: panic.c,v 1.2 1995/03/25 18:13:33 glass Exp $ */
/*
@@ -42,7 +42,7 @@
/* File scope variables */
#ifndef lint
-static char rcsid[] = "$OpenBSD: panic.c,v 1.7 2002/05/11 23:02:33 millert Exp $";
+static const char rcsid[] = "$OpenBSD: panic.c,v 1.8 2002/05/11 23:16:44 millert Exp $";
#endif
/* External variables */
@@ -50,42 +50,39 @@ static char rcsid[] = "$OpenBSD: panic.c,v 1.7 2002/05/11 23:02:33 millert Exp $
/* Global functions */
__dead void
-panic(a)
- char *a;
+panic(const char *a)
{
/*
* Something fatal has happened, print error message and exit.
*/
(void)fprintf(stderr, "%s: %s\n", __progname, a);
if (fcreated) {
- PRIV_START
+ PRIV_START;
unlink(atfile);
- PRIV_END
+ PRIV_END;
}
exit(EXIT_FAILURE);
}
__dead void
-perr(a)
- char *a;
+perr(const char *a)
{
/*
* Some operating system error; print error message and exit.
*/
perror(a);
if (fcreated) {
- PRIV_START
+ PRIV_START;
unlink(atfile);
- PRIV_END
+ PRIV_END;
}
exit(EXIT_FAILURE);
}
__dead void
-perr2(a, b)
- char *a, *b;
+perr2(const char *a, const char *b)
{
(void)fputs(a, stderr);
perr(b);
diff --git a/usr.bin/at/panic.h b/usr.bin/at/panic.h
index 3126fd9c06f..725f0feaea5 100644
--- a/usr.bin/at/panic.h
+++ b/usr.bin/at/panic.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: panic.h,v 1.5 2002/05/11 23:02:33 millert Exp $ */
+/* $OpenBSD: panic.h,v 1.6 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: panic.h,v 1.2 1995/03/25 18:13:35 glass Exp $ */
/*
@@ -26,7 +26,7 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-__dead void panic(char *);
-__dead void perr(char *);
-__dead void perr2(char *, char *);
+__dead void panic(const char *);
+__dead void perr(const char *);
+__dead void perr2(const char *, const char *);
__dead void usage(void);
diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c
index 7a902b13fe4..1c4b7b6a5f5 100644
--- a/usr.bin/at/parsetime.c
+++ b/usr.bin/at/parsetime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: parsetime.c,v 1.9 2000/01/05 08:06:25 millert Exp $ */
+/* $OpenBSD: parsetime.c,v 1.10 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: parsetime.c,v 1.3 1995/03/25 18:13:36 glass Exp $ */
/*
@@ -151,7 +151,7 @@ static int sc_tokid; /* scanner - token id */
static int sc_tokplur; /* scanner - is token plural? */
#ifndef lint
-static char rcsid[] = "$OpenBSD: parsetime.c,v 1.9 2000/01/05 08:06:25 millert Exp $";
+static const char rcsid[] = "$OpenBSD: parsetime.c,v 1.10 2002/05/11 23:16:44 millert Exp $";
#endif
/* Local functions */
@@ -160,8 +160,7 @@ static char rcsid[] = "$OpenBSD: parsetime.c,v 1.9 2000/01/05 08:06:25 millert E
* parse a token, checking if it's something special to us
*/
static int
-parse_token(arg)
- char *arg;
+parse_token(char *arg)
{
int i;
@@ -181,9 +180,7 @@ parse_token(arg)
* init_scanner() sets up the scanner to eat arguments
*/
static void
-init_scanner(argc, argv)
- int argc;
- char **argv;
+init_scanner(int argc, char **argv)
{
scp = argv;
scc = argc;
@@ -200,11 +197,11 @@ init_scanner(argc, argv)
* token() fetches a token from the input stream
*/
static int
-token()
+token(void)
{
int idx;
- while (1) {
+ for (;;) {
(void)memset(sc_token, 0, sc_len);
sc_tokid = EOF;
sc_tokplur = 0;
@@ -270,8 +267,7 @@ token()
* plonk() gives an appropriate error message if a token is incorrect
*/
static void
-plonk(tok)
- int tok;
+plonk(int tok)
{
panic((tok == EOF) ? "incomplete time" : "garbled time");
} /* plonk */
@@ -281,8 +277,7 @@ plonk(tok)
* expect() gets a token and dies most horribly if it's not the token we want
*/
static void
-expect(desired)
- int desired;
+expect(int desired)
{
if (token() != desired)
plonk(sc_tokid); /* and we die here... */
@@ -295,9 +290,7 @@ expect(desired)
* work properly
*/
static void
-dateadd(minutes, tm)
- int minutes;
- struct tm *tm;
+dateadd(int minutes, struct tm *tm)
{
/* increment days */
@@ -338,8 +331,7 @@ dateadd(minutes, tm)
*
*/
static void
-plus(tm)
- struct tm *tm;
+plus(struct tm *tm)
{
int delay;
int expectplur;
@@ -372,8 +364,7 @@ plus(tm)
* [NUMBER [DOT NUMBER] [AM|PM]]
*/
static void
-tod(tm)
- struct tm *tm;
+tod(struct tm *tm)
{
int hour, minute = 0;
size_t tlen;
@@ -439,9 +430,7 @@ tod(tm)
* assign_date() assigns a date, wrapping to next year if needed
*/
static void
-assign_date(tm, mday, mon, year)
- struct tm *tm;
- int mday, mon, year;
+assign_date(struct tm *tm, int mday, int mon, int year)
{
/*
@@ -484,8 +473,7 @@ assign_date(tm, mday, mon, year)
* \PLUS NUMBER MINUTES|HOURS|DAYS|WEEKS/
*/
static void
-month(tm)
- struct tm *tm;
+month(struct tm *tm)
{
int year = (-1);
int mday, wday, mon;
@@ -593,9 +581,7 @@ month(tm)
/* Global functions */
time_t
-parsetime(argc, argv)
- int argc;
- char **argv;
+parsetime(int argc, char **argv)
{
/*
* Do the argument parsing, die if necessary, and return the
diff --git a/usr.bin/at/pathnames.h b/usr.bin/at/pathnames.h
index eafcec28199..88bc5f03ee3 100644
--- a/usr.bin/at/pathnames.h
+++ b/usr.bin/at/pathnames.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pathnames.h,v 1.4 2002/05/11 18:41:20 millert Exp $ */
+/* $OpenBSD: pathnames.h,v 1.5 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: pathnames.h,v 1.3 1995/03/25 18:13:38 glass Exp $ */
/*
@@ -43,4 +43,4 @@
#define _PATH_AT_ALLOW "/var/at/at.allow"
#define _PATH_AT_DENY "/var/at/at.deny"
-#endif /* !_PATHNAMES_H_ */
+#endif /* _PATHNAMES_H_ */
diff --git a/usr.bin/at/perm.c b/usr.bin/at/perm.c
index 10c263da320..38031ed7b76 100644
--- a/usr.bin/at/perm.c
+++ b/usr.bin/at/perm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: perm.c,v 1.2 2002/02/16 21:27:44 millert Exp $ */
+/* $OpenBSD: perm.c,v 1.3 2002/05/11 23:16:44 millert Exp $ */
/*
* perm.c - check user permission for at(1)
@@ -46,7 +46,7 @@
/* File scope variables */
#ifndef lint
-static char rcsid[] = "$OpenBSD: perm.c,v 1.2 2002/02/16 21:27:44 millert Exp $";
+static const char rcsid[] = "$OpenBSD: perm.c,v 1.3 2002/05/11 23:16:44 millert Exp $";
#endif
/* Function declarations */
@@ -56,9 +56,7 @@ static int check_for_user(FILE *, const char *);
/* Local functions */
static int
-check_for_user(fp, name)
- FILE *fp;
- const char *name;
+check_for_user(FILE *fp, const char *name)
{
char *buffer;
size_t len;
@@ -83,7 +81,7 @@ check_for_user(fp, name)
/* Global functions */
int
-check_permission()
+check_permission(void)
{
FILE *fp;
uid_t uid = geteuid();
@@ -97,20 +95,20 @@ check_permission()
exit(EXIT_FAILURE);
}
- PRIV_START
+ PRIV_START;
fp = fopen(_PATH_AT_ALLOW, "r");
- PRIV_END
+ PRIV_END;
if (fp != NULL) {
return (check_for_user(fp, pentry->pw_name));
} else {
- PRIV_START
+ PRIV_START;
fp = fopen(_PATH_AT_DENY, "r");
- PRIV_END
+ PRIV_END;
if (fp != NULL)
return (!check_for_user(fp, pentry->pw_name));
diff --git a/usr.bin/at/privs.h b/usr.bin/at/privs.h
index 8f0542994a0..a28c76889c9 100644
--- a/usr.bin/at/privs.h
+++ b/usr.bin/at/privs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: privs.h,v 1.4 1997/03/01 23:40:12 millert Exp $ */
+/* $OpenBSD: privs.h,v 1.5 2002/05/11 23:16:44 millert Exp $ */
/* $NetBSD: privs.h,v 1.3 1995/03/25 18:13:41 glass Exp $ */
/*
@@ -66,32 +66,32 @@ extern
#endif
gid_t real_gid, effective_gid;
-#define RELINQUISH_PRIVS { \
- real_uid = getuid(); \
- effective_uid = geteuid(); \
- real_gid = getgid(); \
- effective_gid = getegid(); \
- setegid(real_gid); \
- seteuid(real_uid); \
-}
+#define RELINQUISH_PRIVS do { \
+ real_uid = getuid(); \
+ effective_uid = geteuid(); \
+ real_gid = getgid(); \
+ effective_gid = getegid(); \
+ setegid(real_gid); \
+ seteuid(real_uid); \
+} while (0)
-#define RELINQUISH_PRIVS_ROOT(a, b) { \
- real_uid = (a); \
- effective_uid = geteuid(); \
- real_gid = (b); \
- effective_gid = getegid(); \
- setegid(real_gid); \
- seteuid(real_uid); \
-}
+#define RELINQUISH_PRIVS_ROOT(a, b) do { \
+ real_uid = (a); \
+ effective_uid = geteuid(); \
+ real_gid = (b); \
+ effective_gid = getegid(); \
+ setegid(real_gid); \
+ seteuid(real_uid); \
+} while (0)
-#define PRIV_START { \
- seteuid(effective_uid); \
- setegid(effective_gid); \
-}
+#define PRIV_START do { \
+ seteuid(effective_uid); \
+ setegid(effective_gid); \
+} while (0)
-#define PRIV_END { \
- setegid(real_gid); \
- seteuid(real_uid); \
-}
+#define PRIV_END do { \
+ setegid(real_gid); \
+ seteuid(real_uid); \
+} while (0)
-#endif
+#endif /* _PRIVS_H */