diff options
author | charnier <charnier@FreeBSD.org> | 1999-12-05 19:57:14 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1999-12-05 19:57:14 +0000 |
commit | 345f916537662d077177ceb1c7c10258d69143c0 (patch) | |
tree | 688e50df63e8fd20ecde66d5157337b9c8e1e0b6 | |
parent | 8b03354e3023710aa24c33cc8203969bc0d9de54 (diff) | |
download | FreeBSD-src-345f916537662d077177ceb1c7c10258d69143c0.zip FreeBSD-src-345f916537662d077177ceb1c7c10258d69143c0.tar.gz |
Correct use of .Nm, .Em, .Ev
Add rcsid. Use errx instead of fprintf + exit.
Various spelling fixes.
-rw-r--r-- | usr.bin/at/at.c | 78 | ||||
-rw-r--r-- | usr.bin/at/at.man | 102 | ||||
-rw-r--r-- | usr.bin/at/panic.c | 20 | ||||
-rw-r--r-- | usr.bin/at/parsetime.c | 21 | ||||
-rw-r--r-- | usr.bin/at/perm.c | 20 | ||||
-rw-r--r-- | usr.bin/at/privs.h | 6 |
6 files changed, 120 insertions, 127 deletions
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c index 017bfdc..909207a 100644 --- a/usr.bin/at/at.c +++ b/usr.bin/at/at.c @@ -26,6 +26,11 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + #define _USE_BSD 1 /* System Headers */ @@ -36,6 +41,7 @@ #include <sys/param.h> #include <ctype.h> #include <dirent.h> +#include <err.h> #include <errno.h> #include <fcntl.h> #include <pwd.h> @@ -92,7 +98,6 @@ enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */ /* File scope variables */ -static const char rcsid[] = "$FreeBSD$"; char *no_export[] = { "TERM", "TERMCAP", "DISPLAY", "_" @@ -103,7 +108,6 @@ static int send_mail = 0; extern char **environ; int fcreated; -char *namep; char atfile[] = ATJOB_DIR "12345678901234"; char *atinput = (char*)0; /* where to get input from */ @@ -138,7 +142,7 @@ static void alarmc(int signo) { /* Time out after some seconds */ - panic("File locking timed out"); + panic("file locking timed out"); } /* Local functions */ @@ -157,13 +161,13 @@ static char *cwdname(void) while (1) { if (ptr == NULL) - panic("Out of memory"); + panic("out of memory"); if (getcwd(ptr, size-1) != NULL) return ptr; if (errno != ERANGE) - perr("Cannot get directory"); + perr("cannot get directory"); free (ptr); size += SIZE; @@ -237,7 +241,7 @@ writefile(time_t runtimer, char queue) PRIV_START if ((lockdes = open(LFILE, O_WRONLY | O_CREAT, S_IWUSR | S_IRUSR)) < 0) - perr("Cannot open lockfile " LFILE); + perr("cannot open lockfile " LFILE); lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; lock.l_start = 0; lock.l_len = 0; @@ -255,7 +259,7 @@ writefile(time_t runtimer, char queue) alarm(0); if ((jobno = nextjob()) == EOF) - perr("Cannot generate job number"); + perr("cannot generate job number"); sprintf(ppos, "%c%5lx%8lx", queue, jobno, (unsigned long) (runtimer/60)); @@ -266,7 +270,7 @@ writefile(time_t runtimer, char queue) if (stat(atfile, &statbuf) != 0) if (errno != ENOENT) - perr("Cannot access " ATJOB_DIR); + perr("cannot access " ATJOB_DIR); /* Create the file. The x bit is only going to be set after it has * been completely written out, to make sure it is not executed in the @@ -275,13 +279,13 @@ writefile(time_t runtimer, char queue) */ cmask = umask(S_IRUSR | S_IWUSR | S_IXUSR); if ((fdes = creat(atfile, O_WRONLY)) == -1) - perr("Cannot create atjob file"); + perr("cannot create atjob file"); if ((fd2 = dup(fdes)) <0) - perr("Error in dup() of job file"); + perr("error in dup() of job file"); if(fchown(fd2, real_uid, real_gid) != 0) - perr("Cannot give away file"); + perr("cannot give away file"); PRIV_END @@ -304,7 +308,7 @@ writefile(time_t runtimer, char queue) close(lockdes); if((fp = fdopen(fdes, "w")) == NULL) - panic("Cannot reopen atjob file"); + panic("cannot reopen atjob file"); /* Get the userid to mail to, first by trying getlogin(), which reads * /etc/utmp, then from LOGNAME, finally from getpwuid(). @@ -325,7 +329,7 @@ writefile(time_t runtimer, char queue) { fpin = freopen(atinput, "r", stdin); if (fpin == NULL) - perr("Cannot open input file"); + perr("cannot open input file"); } fprintf(fp, "#!/bin/sh\n# atrun uid=%ld gid=%ld\n# mail %*s %d\n", (long) real_uid, (long) real_gid, LOGNAMESIZE, mailname, send_mail); @@ -336,7 +340,7 @@ writefile(time_t runtimer, char queue) /* Write out the environment. Anything that may look like a * special character to the shell is quoted, except for \n, which is - * done with a pair of "'s. Dont't export the no_export list (such + * done with a pair of "'s. Don't export the no_export list (such * as TERM or DISPLAY) because we don't want these. */ for (atenv= environ; *atenv != NULL; atenv++) @@ -416,10 +420,10 @@ writefile(time_t runtimer, char queue) fprintf(fp, "\n"); if (ferror(fp)) - panic("Output error"); + panic("output error"); if (ferror(stdin)) - panic("Input error"); + panic("input error"); fclose(fp); @@ -427,7 +431,7 @@ writefile(time_t runtimer, char queue) */ if (fchmod(fd2, S_IRUSR | S_IWUSR | S_IXUSR) < 0) - perr("Cannot give away file"); + perr("cannot give away file"); close(fd2); fprintf(stderr, "Job %ld will be executed using /bin/sh\n", jobno); @@ -458,16 +462,16 @@ list_jobs() PRIV_START if (chdir(ATJOB_DIR) != 0) - perr("Cannot change to " ATJOB_DIR); + perr("cannot change to " ATJOB_DIR); if ((spool = opendir(".")) == NULL) - perr("Cannot open " ATJOB_DIR); + perr("cannot open " ATJOB_DIR); /* Loop over every file in the directory */ while((dirent = readdir(spool)) != NULL) { if (stat(dirent->d_name, &buf) != 0) - perr("Cannot stat in " ATJOB_DIR); + perr("cannot stat in " ATJOB_DIR); /* See it's a regular file and has its x bit turned on and * is the user's @@ -518,10 +522,10 @@ process_jobs(int argc, char **argv, int what) PRIV_START if (chdir(ATJOB_DIR) != 0) - perr("Cannot change to " ATJOB_DIR); + perr("cannot change to " ATJOB_DIR); if ((spool = opendir(".")) == NULL) - perr("Cannot open " ATJOB_DIR); + perr("cannot open " ATJOB_DIR); PRIV_END @@ -531,7 +535,7 @@ process_jobs(int argc, char **argv, int what) PRIV_START if (stat(dirent->d_name, &buf) != 0) - perr("Cannot stat in " ATJOB_DIR); + perr("cannot stat in " ATJOB_DIR); PRIV_END if(sscanf(dirent->d_name, "%c%5lx%8lx", &queue, &jobno, &ctm)!=3) @@ -539,10 +543,8 @@ process_jobs(int argc, char **argv, int what) for (i=optind; i < argc; i++) { if (atoi(argv[i]) == jobno) { - if ((buf.st_uid != real_uid) && !(real_uid == 0)) { - fprintf(stderr, "%s: Not owner\n", argv[i]); - exit(EXIT_FAILURE); - } + if ((buf.st_uid != real_uid) && !(real_uid == 0)) + errx(EXIT_FAILURE, "%s: not owner", argv[i]); switch (what) { case ATRM: @@ -567,7 +569,7 @@ process_jobs(int argc, char **argv, int what) PRIV_END if (!fp) { - perr("Cannot open file"); + perr("cannot open file"); } while((ch = getc(fp)) != EOF) { putchar(ch); @@ -576,10 +578,8 @@ process_jobs(int argc, char **argv, int what) break; default: - fprintf(stderr, - "Internal error, process_jobs = %d\n",what); - exit(EXIT_FAILURE); - break; + errx(EXIT_FAILURE, "internal error, process_jobs = %d", + what); } } } @@ -593,10 +593,7 @@ mymalloc(size_t n) { void *p; if ((p=malloc(n))==(void *)0) - { - fprintf(stderr,"Virtual memory exhausted\n"); - exit(EXIT_FAILURE); - } + errx(EXIT_FAILURE, "virtual memory exhausted"); return p; } @@ -623,8 +620,6 @@ main(int argc, char **argv) else pgm++; - namep = pgm; - /* find out what this program is supposed to do */ if (strcmp(pgm, "atq") == 0) { @@ -715,10 +710,7 @@ main(int argc, char **argv) /* select our program */ if(!check_permission()) - { - fprintf(stderr, "You do not have permission to use %s.\n",namep); - exit(EXIT_FAILURE); - } + errx(EXIT_FAILURE, "you do not have permission to use this program"); switch (program) { case ATQ: @@ -770,7 +762,7 @@ main(int argc, char **argv) break; default: - panic("Internal error"); + panic("internal error"); break; } exit(EXIT_SUCCESS); diff --git a/usr.bin/at/at.man b/usr.bin/at/at.man index b6dd828..3cf878f 100644 --- a/usr.bin/at/at.man +++ b/usr.bin/at/at.man @@ -3,7 +3,7 @@ .Dt "AT" 1 .Os FreeBSD 2.1 .Sh NAME -.Nm at, batch, atq, atrm +.Nm at , batch , atq , atrm .Nd queue, examine or delete jobs for later execution .Sh SYNOPSIS .Nm at @@ -12,7 +12,6 @@ .Op Fl f Ar file .Op Fl mldbv .Ar time -.Pp .Nm at .Op Fl V .Fl c Ar job Op Ar job ... @@ -64,15 +63,15 @@ or to run a job at a specific time of day. (If that time is already past, the next day is assumed.) You may also specify -.Nm midnight , -.Nm noon , +.Em midnight , +.Em noon , or -.Nm teatime +.Em teatime (4pm) and you can have a time-of-day suffixed with -.Nm AM +.Em AM or -.Nm PM +.Em PM for running in the morning or the evening. You can also say what day the job will be run, by giving a date in the form @@ -88,22 +87,22 @@ or The specification of a date must follow the specification of the time of day. You can also give times like -.Op Nm now -.Nm + Ar count \%time-units , +.Op Em now +.Em + Ar count \%time-units , where the time-units can be -.Nm minutes , -.Nm hours , -.Nm days , -.Nm weeks , -.Nm months +.Em minutes , +.Em hours , +.Em days , +.Em weeks , +.Em months or -.Nm years +.Em years and you can tell -.Nm at +.Nm to run the job today by suffixing the time with -.Nm today +.Em today and to run the job tomorrow by suffixing the time with -.Nm tomorrow. +.Em tomorrow . .Pp For example, to run a job at 4pm three days from now, you would do .Nm at 4pm + 3 days , @@ -113,7 +112,7 @@ and to run a job at 1am tomorrow, you would do .Nm at 1am tomorrow. .Pp For both -.Nm at +.Nm and .Nm batch , commands are read from standard input or the file specified @@ -121,16 +120,16 @@ with the .Fl f option and executed. The working directory, the environment (except for the variables -.Nm TERM , -.Nm TERMCAP , -.Nm DISPLAY +.Ev TERM , +.Ev TERMCAP , +.Ev DISPLAY and -.Nm _ ) +.Em _ ) and the .Ar umask are retained from the time of invocation. An -.Nm at +.Nm or .Nm batch command invoked from a @@ -140,7 +139,7 @@ The user will be mailed standard error and standard output from his commands, if any. Mail will be sent using the command .Xr sendmail 8 . If -.Nm at +.Nm is executed from a .Xr su 1 shell, the owner of the login shell will receive the mail. @@ -154,7 +153,7 @@ and If the file .Pa _PERM_PATH/at.allow exists, only usernames mentioned in it are allowed to use -.Nm at . +.Nm Ns . .Pp If .Pa _PERM_PATH/at.allow @@ -162,10 +161,10 @@ does not exist, .Pa _PERM_PATH/at.deny is checked, every username not mentioned in it is then allowed to use -.Nm at . +.Nm Ns . .Pp If neither exists, only the superuser is allowed use of -.Nm at . +.Nm Ns . This is the default configuration. .Pp An empty @@ -174,24 +173,24 @@ means that every user is allowed use these commands. .Sh OPTIONS .Bl -tag -width indent .It Fl V -prints the version number to standard error. +Print the version number to standard error. .It Fl q Ar queue -uses the specified queue. +Use the specified queue. A queue designation consists of a single letter; valid queue designations range from -.Nm a +.Ar a to -.Nm z . +.Ar z . and -.Nm A +.Ar A to -.Nm Z . +.Ar Z . The -.Nm _DEFAULT_AT_QUEUE +.Ar _DEFAULT_AT_QUEUE queue is the default for -.Nm at +.Nm and the -.Nm _DEFAULT_BATCH_QUEUE +.Ar _DEFAULT_BATCH_QUEUE queue for .Nm batch . Queues with higher letters run with increased niceness. @@ -204,39 +203,39 @@ is given a specific queue, it will only show jobs pending in that queue. Send mail to the user when the job has completed even if there was no output. .It Fl f Ar file -Reads the job from +Read the job from .Ar file rather than standard input. .It Fl l Is an alias for -.Nm atq. +.Nm atq . .It Fl d Is an alias for -.Nm atrm. +.Nm atrm . .It Fl b Is an alias for -.Nm batch. +.Nm batch . .It Fl v For .Nm atq , shows completed but not yet deleted jobs in the queue; otherwise shows the time the job will be executed. .It Fl c -Cats the jobs listed on the command line to standard output. +Cat the jobs listed on the command line to standard output. .Sh FILES .Bl -tag -width _ATJOB_DIR/_LOCKFILE -compact .It Pa _ATJOB_DIR -Directory containing job files +directory containing job files .It Pa _ATSPOOL_DIR -Directory containing output spool files +directory containing output spool files .It Pa /var/run/utmp -Login records +login records .It Pa _PERM_PATH/at.allow -Allow permission control +allow permission control .It Pa _PERM_PATH/at.deny -Deny permission control +deny permission control .It Pa _ATJOB_DIR/_LOCKFILE -Job-creation lock file. +job-creation lock file .El .Sh SEE ALSO .Xr nice 1 , @@ -246,15 +245,14 @@ Job-creation lock file. .Xr cron 8 , .Xr sendmail 8 .Sh BUGS -.Pp If the file .Pa /var/run/utmp is not available or corrupted, or if the user is not logged on at the time -.Nm at +.Nm is invoked, the mail is sent to the userid found in the environment variable -.Nm LOGNAME . +.Ev LOGNAME . If that is undefined or empty, the current userid is assumed. .Pp .Nm At @@ -264,7 +262,7 @@ as presently implemented are not suitable when users are competing for resources. If this is the case for your site, you might want to consider another batch system, such as -.Nm nqs . +.Em nqs . .Sh AUTHORS At was mostly written by .An Thomas Koenig Aq ig25@rz.uni-karlsruhe.de . diff --git a/usr.bin/at/panic.c b/usr.bin/at/panic.c index 6098c95..9cabc1d 100644 --- a/usr.bin/at/panic.c +++ b/usr.bin/at/panic.c @@ -23,8 +23,14 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + /* System Headers */ +#include <err.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> @@ -35,11 +41,6 @@ #include "panic.h" #include "at.h" -/* File scope variables */ - -static const char rcsid[] = - "$FreeBSD$"; - /* External variables */ /* Global functions */ @@ -49,11 +50,10 @@ panic(char *a) { /* Something fatal has happened, print error message and exit. */ - fprintf(stderr,"%s: %s\n",namep,a); if (fcreated) unlink(atfile); - exit (EXIT_FAILURE); + errx(EXIT_FAILURE, "%s", a); } void @@ -61,11 +61,13 @@ perr(char *a) { /* Some operating system error; print error message and exit. */ - perror(a); + int serrno = errno; + if (fcreated) unlink(atfile); - exit(EXIT_FAILURE); + errno = serrno; + err(EXIT_FAILURE, "%s", a); } void diff --git a/usr.bin/at/parsetime.c b/usr.bin/at/parsetime.c index df7fe30..bc8f899 100644 --- a/usr.bin/at/parsetime.c +++ b/usr.bin/at/parsetime.c @@ -2,7 +2,7 @@ * parsetime.c - parse time for at(1) * Copyright (C) 1993, 1994 Thomas Koenig * - * modifications for english-language times + * modifications for English-language times * Copyright (C) 1993 David Parsons * * Redistribution and use in source and binary forms, with or without @@ -33,10 +33,15 @@ * \PLUS NUMBER MINUTES|HOURS|DAYS|WEEKS/ */ -/* System Headers */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ +/* System Headers */ #include <sys/types.h> +#include <ctype.h> #include <err.h> #include <errno.h> #include <stdio.h> @@ -44,7 +49,6 @@ #include <string.h> #include <time.h> #include <unistd.h> -#include <ctype.h> #ifndef __FreeBSD__ #include <getopt.h> #endif @@ -143,13 +147,10 @@ static char *sct; /* scanner - next char pointer in current argument */ static int need; /* scanner - need to advance to next argument */ static char *sc_token; /* scanner - token buffer */ -static size_t sc_len; /* scanner - lenght of token buffer */ +static size_t sc_len; /* scanner - length of token buffer */ static int sc_tokid; /* scanner - token id */ static int sc_tokplur; /* scanner - is token plural? */ -static const char rcsid[] = - "$FreeBSD$"; - /* Local functions */ /* @@ -516,7 +517,7 @@ month(struct tm *tm) token(); } - /* flip months and days for european timing + /* flip months and days for European timing */ if (sep == DOT) { int x = mday; @@ -605,7 +606,7 @@ parsetime(int argc, char **argv) runtime.tm_hour = hr; runtime.tm_min = 0; token(); - /* fall through to month setting */ + /* FALLTHROUGH to month setting */ default: month(&runtime); break; @@ -625,7 +626,7 @@ parsetime(int argc, char **argv) panic("garbled time"); if (nowtimer > runtimer) - panic("Trying to travel back in time"); + panic("trying to travel back in time"); return runtimer; } /* parsetime */ diff --git a/usr.bin/at/perm.c b/usr.bin/at/perm.c index 9c17863..e7bb9b1 100644 --- a/usr.bin/at/perm.c +++ b/usr.bin/at/perm.c @@ -23,9 +23,15 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + /* System Headers */ #include <sys/types.h> +#include <err.h> #include <errno.h> #include <pwd.h> #include <stddef.h> @@ -45,11 +51,6 @@ /* Structures and unions */ - -/* File scope variables */ - -static const char rcsid[] = "$FreeBSD$"; - /* Function declarations */ static int check_for_user(FILE *fp,const char *name); @@ -89,10 +90,7 @@ int check_permission() return 1; if ((pentry = getpwuid(uid)) == NULL) - { - perror("Cannot access user database"); - exit(EXIT_FAILURE); - } + err(EXIT_FAILURE, "cannot access user database"); PRIV_START @@ -118,9 +116,9 @@ int check_permission() return !check_for_user(fp, pentry->pw_name); } else if (errno != ENOENT) - perror("at.deny"); + warn("at.deny"); } else - perror("at.allow"); + warn("at.allow"); return 0; } diff --git a/usr.bin/at/privs.h b/usr.bin/at/privs.h index 2108efb..2fce5c0 100644 --- a/usr.bin/at/privs.h +++ b/usr.bin/at/privs.h @@ -21,6 +21,8 @@ * THEORY OF LIABILITY, WETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ */ #ifndef _PRIVS_H @@ -37,7 +39,7 @@ /* Relinquish privileges temporarily for a setuid or setgid program * with the option of getting them back later. This is done by swapping * the real and effective userid BSD style. Call RELINQUISH_PRIVS once - * at the beginning of the main program. This will cause all operatons + * at the beginning of the main program. This will cause all operations * to be executed with the real userid. When you need the privileges * of the setuid/setgid invocation, call PRIV_START; when you no longer * need it, call PRIV_END. Note that it is an error to call PRIV_START @@ -59,7 +61,7 @@ * It is NOT safe to call exec(), system() or popen() with a user- * supplied program (i.e. without carefully checking PATH and any * library load paths) with relinquished privileges; the called program - * can aquire them just as easily. Set both effective and real userid + * can acquire them just as easily. Set both effective and real userid * to the real userid before calling any of them. */ |