From d2aba719d3e2009b0557f8063286f3eafe16679e Mon Sep 17 00:00:00 2001 From: charnier Date: Fri, 12 Apr 2002 13:11:42 +0000 Subject: Document that only superuser can use -c option. Add FBSDID. Make use of uid_t to silent lint. fprintf -> err conversion. Add some FALLTHROUGH and NOTREACHED comment to silent lint. --- usr.bin/msgs/msgs.1 | 6 +++--- usr.bin/msgs/msgs.c | 26 ++++++++++++++++---------- 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/msgs/msgs.1 b/usr.bin/msgs/msgs.1 index b5d40d2..e2657bb 100644 --- a/usr.bin/msgs/msgs.1 +++ b/usr.bin/msgs/msgs.1 @@ -81,7 +81,7 @@ and go on to the next message. Redisplay the last message. .It Fl q Drop out of -.Nm ; +.Nm Ns ; the next time .Nm will pick up where it last left off. @@ -156,7 +156,7 @@ option should be placed in .Xr periodic 8 ) to run every night. This will remove all messages over 21 days old. A different expiration may be specified on the command line to override -the default. +the default. You must be the superuser to use this option. .Pp Options when reading messages include: .Bl -tag -width Fl @@ -172,7 +172,7 @@ The command ``msgs \-q'' is often used in login scripts. .It Fl h Print the first part of messages only. .It Fl l -Option causes only locally originated messages to be reported. +Cause only locally originated messages to be reported. .It Ar num A message number can be given on the command line, causing diff --git a/usr.bin/msgs/msgs.c b/usr.bin/msgs/msgs.c index eeda04f..5dee2b8 100644 --- a/usr.bin/msgs/msgs.c +++ b/usr.bin/msgs/msgs.c @@ -41,10 +41,11 @@ static const char copyright[] = #if 0 static char sccsid[] = "@(#)msgs.c 8.2 (Berkeley) 4/28/95"; #endif -static const char rcsid[] = - "$FreeBSD$"; #endif /* not lint */ +#include +__FBSDID("$FreeBSD$"); + /* * msgs - a user bulletin board program * @@ -130,7 +131,7 @@ bool mailing = NO; bool quitit = NO; bool sending = NO; bool intrpflg = NO; -int uid; +uid_t uid; int msg; int prevmsg; int lct; @@ -201,10 +202,9 @@ int argc; char *argv[]; break; case 'c': - if (uid != SUPERUSER && uid != DAEMON) { - fprintf(stderr, "Sorry\n"); - exit(1); - } + if (uid != SUPERUSER && uid != DAEMON) + errx(1, + "only the super-user can use the c flag"); clean = YES; break; @@ -540,26 +540,31 @@ cmnd: in = inbuf; switch (*in) { case 'x': + /* FALLTHROUGH */ case 'X': exit(0); - + /* NOTREACHED */ case 'q': + /* FALLTHROUGH */ case 'Q': quitit = YES; printf("--Postponed--\n"); exit(0); - /* intentional fall-thru */ + /* NOTREACHED */ case 'n': + /* FALLTHROUGH */ case 'N': if (msg >= nextmsg) sep = "Flushed"; prevmsg = msg; break; case 'p': + /* FALLTHROUGH */ case 'P': use_pager = (*in++ == 'p'); - /* intentional fallthru */ + /* FALLTHROUGH */ case '\n': + /* FALLTHROUGH */ case 'y': default: if (*in == '-') { @@ -613,6 +618,7 @@ cmnd: if (!(already || hush || qopt)) printf("No new messages.\n"); exit(0); + /* NOTREACHED */ } static void -- cgit v1.1