From owner-freebsd-audit Sun Jun 9 17:59:46 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 98C9F37B400 for ; Sun, 9 Jun 2002 17:59:40 -0700 (PDT) Received: from hades.hell.gr (patr530-b143.otenet.gr [212.205.244.151]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g5A0xKZN020689 for ; Mon, 10 Jun 2002 03:59:29 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g5A0xDTp016916 for ; Mon, 10 Jun 2002 03:59:14 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g5A0fvGv010802 for audit@freebsd.org; Mon, 10 Jun 2002 03:41:58 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Date: Mon, 10 Jun 2002 03:41:56 +0300 From: Giorgos Keramidas To: audit@FreeBSD.org Subject: nested extern shuffle in makewhatis.c Message-ID: <20020610004156.GA10607@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG One of the warnings printed by WARNS=6 for makewhatis is about the declaration of optind and optarg as extern. Any objections to me removing these as shown below? - Giorgos %%% Index: makewhatis.c =================================================================== RCS file: /home/ncvs/src/usr.bin/makewhatis/makewhatis.c,v retrieving revision 1.5 diff -u -r1.5 makewhatis.c --- makewhatis.c 22 May 2002 11:08:41 -0000 1.5 +++ makewhatis.c 7 Jun 2002 01:23:18 -0000 @@ -960,8 +960,6 @@ main(int argc, char **argv) { int opt; - extern int optind; - extern char *optarg; FILE *fp = NULL; while ((opt = getopt(argc, argv, "ai:n:o:vL")) != -1) { %%% To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jun 9 18: 0: 1 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 98E5837B401 for ; Sun, 9 Jun 2002 17:59:40 -0700 (PDT) Received: from hades.hell.gr (patr530-b143.otenet.gr [212.205.244.151]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g5A0xKZN020690 for ; Mon, 10 Jun 2002 03:59:29 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g5A0xDTn016916 for ; Mon, 10 Jun 2002 03:59:14 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g5A0nFwh012024 for audit@freebsd.org; Mon, 10 Jun 2002 03:49:15 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Date: Mon, 10 Jun 2002 03:49:14 +0300 From: Giorgos Keramidas To: audit@FreeBSD.org Subject: Compiling bin/ed with WARNS=6 Message-ID: <20020610004914.GA10811@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG There are only two small changes that need to be done to ed(1) to make it compile cleanly with WARNS=6 in i386/CURRENT. I have tested the following changes by doing: $ cd src/bin/ed $ make WARNS=6 cleandir all $ ./ed -x /tmp/foo Enter key: foobar123 $ /bin/ed -x /tmp/foo Enter key: foobar123 How does it look? %%% Declare an array of bytes as `char[]' and not `unsigned char[]'. Move two `extern' declarations outside of a function body. This enables ed to build with WARNS=6. Index: ed/Makefile =================================================================== RCS file: /home/ncvs/src/bin/ed/Makefile,v retrieving revision 1.21 diff -u -r1.21 Makefile --- ed/Makefile 6 Dec 2001 10:50:23 -0000 1.21 +++ ed/Makefile 9 Jun 2002 04:53:26 -0000 @@ -2,6 +2,7 @@ PROG= ed SRCS= buf.c cbc.c glbl.c io.c main.c re.c sub.c undo.c +WARNS= 6 LINKS= ${BINDIR}/ed ${BINDIR}/red MLINKS= ed.1 red.1 Index: ed/cbc.c =================================================================== RCS file: /home/ncvs/src/bin/ed/cbc.c,v retrieving revision 1.15 diff -u -r1.15 cbc.c --- ed/cbc.c 2 Feb 2002 06:36:49 -0000 1.15 +++ ed/cbc.c 9 Jun 2002 04:51:14 -0000 @@ -95,7 +95,7 @@ }; int pflag; /* 1 to preserve parity bits */ -unsigned char des_buf[8]; /* shared buffer for get_des_char/put_des_char */ +char des_buf[8]; /* shared buffer for get_des_char/put_des_char */ int des_ct = 0; /* count for get_des_char/put_des_char */ int des_n = 0; /* index for put_des_char/get_des_char */ Index: ed/main.c =================================================================== RCS file: /home/ncvs/src/bin/ed/main.c,v retrieving revision 1.22 diff -u -r1.22 main.c --- ed/main.c 2 Feb 2002 06:36:49 -0000 1.22 +++ ed/main.c 9 Jun 2002 04:48:27 -0000 @@ -444,14 +444,14 @@ long rows = 22; /* scroll length: ws_row - 2 */ +extern long u_current_addr; +extern long u_addr_last; + /* exec_command: execute the next command in command buffer; return print request, if any */ int exec_command(void) { - extern long u_current_addr; - extern long u_addr_last; - static pattern_t *pat = NULL; static int sgflag = 0; static long sgnum = 0; %%% - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jun 9 18: 0:23 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id 9AE8737B403; Sun, 9 Jun 2002 17:59:42 -0700 (PDT) Received: from hades.hell.gr (patr530-b143.otenet.gr [212.205.244.151]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g5A0xKZN020687; Mon, 10 Jun 2002 03:59:29 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g5A0xDTl016916; Mon, 10 Jun 2002 03:59:13 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g5A0v96Y015782; Mon, 10 Jun 2002 03:57:09 +0300 (EEST) (envelope-from keramida@FreeBSD.org) Date: Mon, 10 Jun 2002 03:57:08 +0300 From: Giorgos Keramidas To: tjr@FreeBSD.org, audit@FreeBSD.org Subject: /bin/sh: Making it possible to use WARNS=6 Message-ID: <20020610005708.GA12544@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG These changes allowed me to build test(1) and sh(1) with WARNS=6 in CURRENT. What do you think? ;-) What do you all think? %%% - Remove a couple of unused vars from jobs.c - Add all necessary fields to struct initialized in init.c - Add const to mksyntax.c to fix last warnings. - Properly prototype functions to fix bulding with WARNS=6. Index: test/test.c =================================================================== RCS file: /home/ncvs/src/bin/test/test.c,v retrieving revision 1.47 diff -u -r1.47 test.c --- test/test.c 11 May 2002 01:25:54 -0000 1.47 +++ test/test.c 9 Jun 2002 22:37:21 -0000 @@ -181,6 +181,8 @@ static void syntax(const char *, const char *); static enum token t_lex(char *); +int main(int argc, char **argv); + int main(int argc, char **argv) { Index: sh/alias.c =================================================================== RCS file: /home/ncvs/src/bin/sh/alias.c,v retrieving revision 1.15 diff -u -r1.15 alias.c --- sh/alias.c 4 Jun 2002 12:59:12 -0000 1.15 +++ sh/alias.c 9 Jun 2002 22:54:11 -0000 @@ -148,7 +148,7 @@ } #ifdef mkinit -MKINIT void rmaliases(); +MKINIT void rmaliases(void); SHELLPROC { rmaliases(); Index: sh/arith.y =================================================================== RCS file: /home/ncvs/src/bin/sh/arith.y,v retrieving revision 1.13 diff -u -r1.13 arith.y --- sh/arith.y 2 Feb 2002 06:50:45 -0000 1.13 +++ sh/arith.y 9 Jun 2002 21:44:17 -0000 @@ -103,10 +103,13 @@ #include "memalloc.h" char *arith_buf, *arith_startbuf; -extern void arith_lex_reset(); +extern void arith_lex_reset(void); int yylex(void); int yyparse(void); +void yyerror(char *s); +int arith(char *s); +int expcmd(int argc, char **argv); int arith(char *s) Index: sh/arith_lex.l =================================================================== RCS file: /home/ncvs/src/bin/sh/arith_lex.l,v retrieving revision 1.17 diff -u -r1.17 arith_lex.l --- sh/arith_lex.l 2 Feb 2002 06:50:46 -0000 1.17 +++ sh/arith_lex.l 9 Jun 2002 22:04:20 -0000 @@ -52,6 +52,9 @@ #define YY_INPUT(buf,result,max) \ result = (*buf = *arith_buf++) ? 1 : YY_NULL; #define YY_NO_UNPUT + +int yylex(void); +void arith_lex_reset(void); %} %% @@ -83,7 +86,7 @@ %% void -arith_lex_reset() +arith_lex_reset(void) { YY_NEW_FILE; } Index: sh/exec.c =================================================================== RCS file: /home/ncvs/src/bin/sh/exec.c,v retrieving revision 1.17 diff -u -r1.17 exec.c --- sh/exec.c 15 Apr 2002 15:49:30 -0000 1.17 +++ sh/exec.c 9 Jun 2002 22:54:53 -0000 @@ -655,7 +655,7 @@ */ #ifdef mkinit -MKINIT void deletefuncs(); +MKINIT void deletefuncs(void); SHELLPROC { deletefuncs(); Index: sh/jobs.c =================================================================== RCS file: /home/ncvs/src/bin/sh/jobs.c,v retrieving revision 1.44 diff -u -r1.44 jobs.c --- sh/jobs.c 4 Jun 2002 15:26:00 -0000 1.44 +++ sh/jobs.c 9 Jun 2002 20:30:19 -0000 @@ -273,7 +273,6 @@ int jobscmd(int argc, char *argv[]) { - struct job *jp; char *id; int ch, sformat, lformat; @@ -926,7 +925,6 @@ struct job *thisjob; int done; int stopped; - int core; int sig; in_dowait++; Index: sh/mail.c =================================================================== RCS file: /home/ncvs/src/bin/sh/mail.c,v retrieving revision 1.11 diff -u -r1.11 mail.c --- sh/mail.c 2 Feb 2002 06:50:46 -0000 1.11 +++ sh/mail.c 9 Jun 2002 22:15:00 -0000 @@ -50,6 +50,7 @@ #include "exec.h" /* defines padvance() */ #include "var.h" #include "output.h" +#include "mail.h" #include "memalloc.h" #include "error.h" #include Index: sh/miscbltin.c =================================================================== RCS file: /home/ncvs/src/bin/sh/miscbltin.c,v retrieving revision 1.25 diff -u -r1.25 miscbltin.c --- sh/miscbltin.c 2 Feb 2002 06:50:46 -0000 1.25 +++ sh/miscbltin.c 9 Jun 2002 22:27:48 -0000 @@ -67,6 +67,10 @@ #undef eflag +int readcmd(int argc, char *argv[]); +int umaskcmd(int argc, char *argv[]); +int ulimitcmd(int argc, char *argv[]); + /* * The read builtin. The -r option causes backslashes to be treated like * ordinary characters. Index: sh/mkbuiltins =================================================================== RCS file: /home/ncvs/src/bin/sh/mkbuiltins,v retrieving revision 1.10 diff -u -r1.10 mkbuiltins --- sh/mkbuiltins 18 Feb 2002 06:08:23 -0000 1.10 +++ sh/mkbuiltins 9 Jun 2002 22:45:42 -0000 @@ -61,9 +61,9 @@ ! awk '/^[^#]/ {if(('$havejobs' || $2 != "-j") && ('$havehist' || $2 != "-h")) \ print $0}' builtins.def | sed 's/-j//' > $temp -awk '{ printf "int %s();\n", $1}' $temp +awk '{ printf "int %s(int argc, char **argv);\n", $1}' $temp echo ' -int (*const builtinfunc[])() = {' +int (*const builtinfunc[])(int, char **) = {' awk '/^[^#]/ { printf "\t%s,\n", $1}' $temp echo '}; @@ -90,6 +90,6 @@ int code; }; -extern int (*const builtinfunc[])(); +extern int (*const builtinfunc[])(int argc, char **argv); extern const struct builtincmd builtincmd[];' rm -f $temp Index: sh/mkinit.c =================================================================== RCS file: /home/ncvs/src/bin/sh/mkinit.c,v retrieving revision 1.15 diff -u -r1.15 mkinit.c --- sh/mkinit.c 2 Feb 2002 06:50:46 -0000 1.15 +++ sh/mkinit.c 9 Jun 2002 23:05:49 -0000 @@ -137,10 +137,10 @@ struct event event[] = { - {"INIT", "init", init}, - {"RESET", "reset", reset}, - {"SHELLPROC", "initshellproc", shellproc}, - {NULL, NULL} + {"INIT", "init", init, {NULL, 0, NULL, NULL}}, + {"RESET", "reset", reset, {NULL, 0, NULL, NULL}}, + {"SHELLPROC", "initshellproc", shellproc, {NULL, 0, NULL, NULL}}, + {NULL, NULL, NULL, {NULL, 0, NULL, NULL}} }; @@ -395,7 +395,8 @@ for (ep = event ; ep->name ; ep++) { fputs("\n\n\n", fp); fputs(ep->comment, fp); - fprintf(fp, "\nvoid\n%s() {\n", ep->routine); + fprintf(fp, "void %s(void);\n", ep->routine); + fprintf(fp, "\nvoid\n%s(void) {\n", ep->routine); writetext(&ep->code, fp); fprintf(fp, "}\n"); } Index: sh/mksyntax.c =================================================================== RCS file: /home/ncvs/src/bin/sh/mksyntax.c,v retrieving revision 1.18 diff -u -r1.18 mksyntax.c --- sh/mksyntax.c 2 Feb 2002 06:50:46 -0000 1.18 +++ sh/mksyntax.c 9 Jun 2002 20:55:44 -0000 @@ -59,8 +59,8 @@ struct synclass { - char *name; - char *comment; + const char *name; + const char *comment; }; /* Syntax classes */ Index: sh/var.c =================================================================== RCS file: /home/ncvs/src/bin/sh/var.c,v retrieving revision 1.20 diff -u -r1.20 var.c --- sh/var.c 6 Jun 2002 04:02:50 -0000 1.20 +++ sh/var.c 9 Jun 2002 22:55:32 -0000 @@ -462,7 +462,7 @@ */ #ifdef mkinit -MKINIT void shprocvar(); +MKINIT void shprocvar(void); SHELLPROC { shprocvar(); Index: sh/bltin/echo.c =================================================================== RCS file: /home/ncvs/src/bin/sh/bltin/echo.c,v retrieving revision 1.11 diff -u -r1.11 echo.c --- sh/bltin/echo.c 2 Feb 2002 06:50:55 -0000 1.11 +++ sh/bltin/echo.c 9 Jun 2002 22:21:31 -0000 @@ -45,6 +45,8 @@ #include "bltin.h" +int main(int argc, char *argv[]); + /* #define eflag 1 */ int %%% To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jun 9 18:33:24 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 61BB437B405 for ; Sun, 9 Jun 2002 18:33:19 -0700 (PDT) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g5A1X2x7096016; Sun, 9 Jun 2002 21:33:02 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Sun, 9 Jun 2002 21:33:01 -0400 To: freebsd-audit@FreeBSD.ORG From: Garance A Drosihn Subject: Re: Rewrite of much of lpc/cmds.c ... Cc: freebsd-print@bostonradio.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 5:52 PM -0400 6/8/02, Garance A Drosihn wrote: >I figure I better stop at this point, before I rewrite the >entire thing. Here is an update which basically rewrites > > abort disable enable restart > start stop up >I would like to commit this to current around June 15th. Actually, since this update will leave the previous versions of all the commands available, I'll probably commit it to current by Wednesday the 12th. I do have additional updates to lpc/cmds.c which will be available by the weekend. (they're already written, actually, but I'm still checking them over). >Here is the update: >Index: lpc/cmds.c >=================================================================== > /* >+ * kill an existing daemon and disable printing. >+ */ >+void >+abort_q(struct printer *pp) >+{ I am still making a few cosmetic changes to this update (such as rewording some comments), and in the process I did notice that the abort_q routine needs a: if (setres >= 0) { seteuid(euid); upstat(pp, "printing disabled\n"); seteuid(uid); } at the end of the routine, to completely reproduce the behavior of the previous implementation of abortpr. So, I've added it... -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jun 9 18:33:48 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id BF81137B403; Sun, 9 Jun 2002 18:33:44 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id LAA29436; Mon, 10 Jun 2002 11:33:37 +1000 Date: Mon, 10 Jun 2002 11:34:25 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Giorgos Keramidas Cc: audit@FreeBSD.ORG Subject: Re: Compiling bin/ed with WARNS=6 In-Reply-To: <20020610004914.GA10811@hades.hell.gr> Message-ID: <20020610112448.G1757-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 10 Jun 2002, Giorgos Keramidas wrote: > There are only two small changes that need to be done to ed(1) to make > it compile cleanly with WARNS=6 in i386/CURRENT. I have tested the > ... > Declare an array of bytes as `char[]' and not `unsigned char[]'. Er, this seems to break at least get_des_char() if the buffer contains negative chars. E.g., the signed char that has the value EOF (if any) would be indistinguishable from EOF. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Jun 9 19: 2:16 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mailsrv.otenet.gr (mailsrv.otenet.gr [195.170.0.5]) by hub.freebsd.org (Postfix) with ESMTP id A926937B405 for ; Sun, 9 Jun 2002 19:02:11 -0700 (PDT) Received: from hades.hell.gr (patr530-a071.otenet.gr [212.205.215.71]) by mailsrv.otenet.gr (8.12.3/8.12.3) with ESMTP id g5A225ZN000240; Mon, 10 Jun 2002 05:02:08 +0300 (EEST) Received: from hades.hell.gr (hades [127.0.0.1]) by hades.hell.gr (8.12.3/8.12.3) with ESMTP id g5A223sW010949; Mon, 10 Jun 2002 05:02:03 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from charon@localhost) by hades.hell.gr (8.12.3/8.12.3/Submit) id g5A21wlJ010915; Mon, 10 Jun 2002 05:01:58 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Date: Mon, 10 Jun 2002 05:01:52 +0300 From: Giorgos Keramidas To: Bruce Evans Cc: audit@FreeBSD.ORG Subject: Re: Compiling bin/ed with WARNS=6 Message-ID: <20020610020152.GA9808@hades.hell.gr> References: <20020610004914.GA10811@hades.hell.gr> <20020610112448.G1757-100000@gamplex.bde.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020610112448.G1757-100000@gamplex.bde.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 2002-06-10 11:34 +1000, Bruce Evans wrote: > On Mon, 10 Jun 2002, Giorgos Keramidas wrote: > > There are only two small changes that need to be done to ed(1) to make > > it compile cleanly with WARNS=6 in i386/CURRENT. I have tested the > > ... > > Declare an array of bytes as `char[]' and not `unsigned char[]'. > > Er, this seems to break at least get_des_char() if the buffer contains > negative chars. E.g., the signed char that has the value EOF (if any) > would be indistinguishable from EOF. Since ed can be used to edit 8-bit texts too, we should either use `char' everywhere, or `unsigned char'. We can't use both. I have verified that changing the type to `char' doesn't break editing of encrypted files. Using a program to generate input for ed, I inserted into an ed buffer all the characters from 128-255 (some codepages, like Greek that I'm customarily using use most of the 8-bit characters for their national part of the character-set). I am not sure if the resulting code of get_des_char() is broken. I saw the part of io.c that uses get_des_char(). It seems that this works because get_des_char() returns an int. So when get_des_char() returns EOF, it is different from ((char)-1). I might be wrong though. At least, it's nice to see that my worries and checks for 8-bit characters were steps in the right path :} - Giorgos To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Jun 10 19:38: 7 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id D680D37B403 for ; Mon, 10 Jun 2002 19:37:49 -0700 (PDT) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g5B2blPa043286; Mon, 10 Jun 2002 22:37:48 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: Date: Mon, 10 Jun 2002 22:37:46 -0400 To: freebsd-print@bostonradio.org From: Garance A Drosihn Subject: New 'setmsg' (or 'setstatus') command for lpc Cc: freebsd-audit@freebsd.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Here's the next update in the series. This one adds a new command to lpc which can be used to set the status message for one or more printers. It includes some changes to the upstat() routine, to make that handle seteuid() calls instead of assuming the caller handled them. You'll notice two places where I added seteuid() after a call to upstat(). That looks weird, but that's in the X-version of the abort command, and that whole routine will disappear soon anyway. When this was originally implemented at RPI, it was called 'setstatus'. I noticed lpc in LPRng has a 'msg' command which does about the same thing, but I don't quite like 'msg' as a command. So, I added 'setmsg' instead. As I look at this, I'm thinking that maybe I should just stick with 'setstatus' instead of having two commands that do the same thing. This patch assumes the previous patch has been applied. The latest version of *that* patch (which rewrote of much of lpc/cmds.c) is at http://people.freebsd.org/~gad/lpr/lpc-cmds.diff There are only a few cosmetic changes to that patch, but this new patch probably assumes those cosmetic changes are in place. This new patch is also at: http://people.freebsd.org/~gad/lpr/lpc-setmsg.diff This patch is in a slightly different format, because it is a 'diff' between two directories, instead of a 'cvs diff' from current. I'm not sure how usable that is, but at least it's readable. I would like to commit this to -current next weekend, but it can certainly wait a bit longer if people want more time to think about it. =================================================================== diff -u -r fbsd-rel5.orig/lpc/cmds.c fbsd-rel5/lpc/cmds.c --- fbsd-rel5.orig/lpc/cmds.c Sun Jun 9 18:56:53 2002 +++ fbsd-rel5/lpc/cmds.c Mon Jun 10 21:12:32 2002 @@ -79,6 +79,7 @@ #define KQT_KILLOK 1 static void abortpr(struct printer *_pp, int _dis); +static char *args2line(int argc, char **argv); static int doarg(char *_job); static int doselect(struct dirent *_d); static int kill_qtask(const char *lf); @@ -87,7 +88,7 @@ static void startpr(struct printer *_pp, int _chgenable); static int touch(struct jobqueue *_jq); static void unlinkf(char *_name); -static void upstat(struct printer *_pp, const char *_msg); +static void upstat(struct printer *_pp, const char *_msg, int _notify); static void wrapup_clean(int _laststatus); /* @@ -103,11 +104,12 @@ static enum qsel_val generic_qselect; /* indicates how ptr was selected */ static int generic_initerr; /* result of initrtn processing */ +static char *generic_msg; /* if a -msg was specified */ static char *generic_nullarg; static void (*generic_wrapup)(int _last_status); /* perform rtn wrap-up */ void -generic(void (*specificrtn)(struct printer *_pp), +generic(void (*specificrtn)(struct printer *_pp), int cmdopts, void (*initrtn)(int _argc, char *_argv[]), int argc, char *argv[]) { int cmdstatus, more, targc; @@ -115,7 +117,10 @@ char **targv; if (argc == 1) { - printf("usage: %s {all | printer ...}\n", argv[0]); + printf("usage: %s {all | printer ...}", argv[0]); + if (cmdopts & LPC_MSGOPT) + printf(" [-msg ...]"); + printf("\n"); return; } @@ -136,6 +141,21 @@ if (generic_nullarg == NULL) generic_nullarg = strdup(""); + /* Some commands accept a -msg argument */ + generic_msg = NULL; + if (cmdopts & LPC_MSGOPT) { + targc = argc; + targv = argv; + while (--targc) { + ++targv; + if (strcmp(*targv, "-msg") == 0) { + argc -= targc; + generic_msg = args2line(targc - 1, targv + 1); + break; + } + } + } + /* call initialization routine, if there is one for this cmd */ if (initrtn != NULL) { generic_initerr = 0; @@ -209,7 +229,34 @@ if (generic_wrapup) { (*generic_wrapup)(cmdstatus); } + if (generic_msg) + free(generic_msg); +} +/* + * Convert an argv-array of character strings into a single string. + */ +static char * +args2line(int argc, char **argv) +{ + char *cp1, *cend; + const char *cp2; + char buf[1024]; + + if (argc <= 0) + return strdup("\n"); + + cp1 = buf; + cend = buf + sizeof(buf); + while (--argc >= 0) { + cp2 = *argv++; + while ((cp1 < cend) && (*cp2 != '\0')) + *cp1++ = *cp2++; + *cp1++ = ' '; + } + cp1[-1] = '\n'; + *cp1 = '\0'; + return strdup(buf); } /* @@ -242,7 +289,9 @@ printf("\tcannot disable printing: %s\n", strerror(errno)); else { - upstat(pp, "printing disabled\n"); + upstat(pp, "printing disabled\n", 0); + /* ...new upstat() did a setuid(uid)... */ + seteuid(euid); printf("\tprinting disabled\n"); } } else if (errno == ENOENT) { @@ -252,7 +301,9 @@ strerror(errno)); else { (void) close(fd); - upstat(pp, "printing disabled\n"); + upstat(pp, "printing disabled\n", 0); + /* ...new upstat() did a setuid(uid)... */ + seteuid(euid); printf("\tprinting disabled\n"); printf("\tno daemon to abort\n"); } @@ -377,14 +428,16 @@ * Write a message into the status file. */ static void -upstat(struct printer *pp, const char *msg) +upstat(struct printer *pp, const char *msg, int notifyuser) { - register int fd; + int fd; char statfile[MAXPATHLEN]; status_file_name(pp, statfile, sizeof statfile); umask(0); + seteuid(euid); fd = open(statfile, O_WRONLY|O_CREAT|O_EXLOCK, STAT_FILE_MODE); + seteuid(uid); if (fd < 0) { printf("\tcannot create status file: %s\n", strerror(errno)); return; @@ -395,6 +448,12 @@ else (void) write(fd, msg, strlen(msg)); (void) close(fd); + if (notifyuser) { + if ((msg == (char *)NULL) || (strcmp(msg, "\n") == 0)) + printf("\tstatus message is now set to nothing.\n"); + else + printf("\tstatus message is now: %s", msg); + } } /* @@ -442,11 +501,8 @@ break; } - if (setres >= 0) { - seteuid(euid); - upstat(pp, "printing disabled\n"); - seteuid(uid); - } + if (setres >= 0) + upstat(pp, "printing disabled\n", 0); } /* @@ -1133,6 +1189,31 @@ } /* + * Set the status message of each queue listed. Requires a "-msg" + * parameter to indicate the end of the queue list and start of msg text. + */ +void +setmsg_gi(int argc __unused, char *argv[] __unused) +{ + + if (generic_msg == NULL) { + printf("You must specify '-msg' before the text of the new status message.\n"); + generic_initerr = 1; + } +} + +void +setmsg_q(struct printer *pp) +{ + char lf[MAXPATHLEN]; + + lock_file_name(pp, lf, sizeof lf); + printf("%s:\n", pp->printer); + + upstat(pp, generic_msg, 1); +} + +/* * Enable printing on the specified printer and startup the daemon. */ void @@ -1279,7 +1360,7 @@ printf("\tcannot disable printing: %s\n", strerror(errno)); else { - upstat(pp, "printing disabled\n"); + upstat(pp, "printing disabled\n", 0); printf("\tprinting disabled\n"); } } else if (errno == ENOENT) { @@ -1289,7 +1370,7 @@ strerror(errno)); else { (void) close(fd); - upstat(pp, "printing disabled\n"); + upstat(pp, "printing disabled\n", 0); printf("\tprinting disabled\n"); } } else @@ -1312,11 +1393,8 @@ setres = set_qstate(SQS_STOPP, lf); - if (setres >= 0) { - seteuid(euid); - upstat(pp, "printing disabled\n"); - seteuid(uid); - } + if (setres >= 0) + upstat(pp, "printing disabled\n", 0); } struct jobqueue **queue; =================================================================== diff -u -r fbsd-rel5.orig/lpc/cmdtab.c fbsd-rel5/lpc/cmdtab.c --- fbsd-rel5.orig/lpc/cmdtab.c Mon Jun 10 16:48:00 2002 +++ fbsd-rel5/lpc/cmdtab.c Mon Jun 10 20:02:18 2002 @@ -55,6 +55,7 @@ char helphelp[] = "get help on commands"; char quithelp[] = "exit lpc"; char restarthelp[] = "kill (if possible) and restart a spooling daemon"; +char setmsghelp[] = "set the status message, requires \"-msg\" before the msg"; char starthelp[] = "enable printing and start a spooling daemon"; char statushelp[] = "show status of daemon and queue"; char stophelp[] = "stop a spooling daemon after current job completes and disable printing"; @@ -62,7 +63,9 @@ char topqhelp[] = "put job at top of printer queue"; char uphelp[] = "enable everything and restart spooling daemon"; -#define PR 1 /* a privileged command */ +/* Use some abbreviations so entries won't need to wrap */ +#define PR LPC_PRIVCMD +#define M LPC_MSGOPT struct cmd cmdtab[] = { { "abort", aborthelp, PR, 0, abort_q }, @@ -74,6 +77,8 @@ { "help", helphelp, 0, help, 0 }, { "quit", quithelp, 0, quit, 0 }, { "restart", restarthelp, 0, 0, restart_q }, + { "setmsg", setmsghelp, PR|M, setmsg_gi, setmsg_q }, + { "setstatus", setmsghelp, PR|M, setmsg_gi, setmsg_q }, { "start", starthelp, PR, 0, start_q }, { "status", statushelp, 0, 0, status }, { "stop", stophelp, PR, 0, stop_q }, =================================================================== diff -u -r fbsd-rel5.orig/lpc/extern.h fbsd-rel5/lpc/extern.h --- fbsd-rel5.orig/lpc/extern.h Mon Jun 10 12:56:06 2002 +++ fbsd-rel5/lpc/extern.h Mon Jun 10 20:43:46 2002 @@ -47,7 +47,7 @@ void disable_q(struct printer *_pp); void down(int _argc, char *_argv[]); void enable_q(struct printer *_pp); -void generic(void (*_specificrtn)(struct printer *_pp), +void generic(void (*_specificrtn)(struct printer *_pp), int _cmdopts, void (*_initcmd)(int _argc, char *_argv[]), int _argc, char *_argv[]); void help(int _argc, char *_argv[]); @@ -55,6 +55,8 @@ void init_tclean(int _argc, char *_argv[]); void quit(int _argc, char *_argv[]); void restart_q(struct printer *_pp); +void setmsg_gi(int _argc, char *_argv[]); +void setmsg_q(struct printer *_pp); void start_q(struct printer *_pp); void status(struct printer *_pp); void stop_q(struct printer *_pp); =================================================================== diff -u -r fbsd-rel5.orig/lpc/extern_lpc.h fbsd-rel5/lpc/extern_lpc.h --- fbsd-rel5.orig/lpc/extern_lpc.h Mon Jun 10 12:56:06 2002 +++ fbsd-rel5/lpc/extern_lpc.h Mon Jun 10 20:43:46 2002 @@ -47,7 +47,7 @@ void disable_q(struct printer *_pp); void down(int _argc, char *_argv[]); void enable_q(struct printer *_pp); -void generic(void (*_specificrtn)(struct printer *_pp), +void generic(void (*_specificrtn)(struct printer *_pp), int _cmdopts, void (*_initcmd)(int _argc, char *_argv[]), int _argc, char *_argv[]); void help(int _argc, char *_argv[]); @@ -55,6 +55,8 @@ void init_tclean(int _argc, char *_argv[]); void quit(int _argc, char *_argv[]); void restart_q(struct printer *_pp); +void setmsg_gi(int _argc, char *_argv[]); +void setmsg_q(struct printer *_pp); void start_q(struct printer *_pp); void status(struct printer *_pp); void stop_q(struct printer *_pp); =================================================================== diff -u -r fbsd-rel5.orig/lpc/lpc.c fbsd-rel5/lpc/lpc.c --- fbsd-rel5.orig/lpc/lpc.c Mon Oct 1 04:46:45 2001 +++ fbsd-rel5/lpc/lpc.c Mon Jun 10 21:08:02 2002 @@ -110,12 +110,14 @@ printf("?Invalid command\n"); exit(1); } - if (c->c_priv && getuid() && ingroup(LPR_OPER) == 0) { + if ((c->c_opts & LPC_PRIVCMD) && getuid() && + ingroup(LPR_OPER) == 0) { printf("?Privileged command\n"); exit(1); } if (c->c_generic != 0) - generic(c->c_generic, c->c_handler, argc, argv); + generic(c->c_generic, c->c_opts, c->c_handler, + argc, argv); else (*c->c_handler)(argc, argv); exit(0); @@ -210,7 +212,8 @@ printf("?Invalid command\n"); continue; } - if (c->c_priv && getuid() && ingroup(LPR_OPER) == 0) { + if ((c->c_opts & LPC_PRIVCMD) && getuid() && + ingroup(LPR_OPER) == 0) { printf("?Privileged command\n"); continue; } @@ -223,7 +226,8 @@ * initial parameter processing. */ if (c->c_generic != 0) - generic(c->c_generic, c->c_handler, margc, margv); + generic(c->c_generic, c->c_opts, c->c_handler, + margc, margv); else (*c->c_handler)(margc, margv); } =================================================================== diff -u -r fbsd-rel5.orig/lpc/lpc.h fbsd-rel5/lpc/lpc.h --- fbsd-rel5.orig/lpc/lpc.h Sun Jun 24 22:05:03 2001 +++ fbsd-rel5/lpc/lpc.h Mon Jun 10 19:59:11 2002 @@ -40,10 +40,13 @@ */ struct printer; +#define LPC_PRIVCMD 0x0001 /* a privileged command */ +#define LPC_MSGOPT 0x0002 /* command recognizes -msg option */ + struct cmd { const char *c_name; /* command name */ const char *c_help; /* help message */ - const int c_priv; /* privileged command */ + const int c_opts; /* flags (eg: privileged command) */ /* routine to do all the work for plain cmds, or * initialization work for generic-printer cmds: */ void (*c_handler)(int, char *[]); -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Jun 13 20:35:17 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 4C26737B412 for ; Thu, 13 Jun 2002 20:35:15 -0700 (PDT) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g5E3XEtp082324; Thu, 13 Jun 2002 23:33:29 -0400 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Thu, 13 Jun 2002 23:33:12 -0400 To: freebsd-print@bostonradio.org From: Garance A Drosihn Subject: Re: New 'setstatus' command for lpc Cc: freebsd-audit@FreeBSD.org Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG There's a new version of the setstatus patch at: http://people.freebsd.org/~gad/lpr/lpc-setmsg.diff It's pretty much the same as what I posted on Monday, except that it fixes some buffer-overflow bugs in the args2line() routine that is added by the update. It also does NOT add a setmsg command, just the setstatus one, so some functions were renamed. The patch also now includes an update for lpc's man page. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message