From owner-freebsd-audit Sun Apr 29 1:54:56 2001 Delivered-To: freebsd-audit@freebsd.org Received: from obsecurity.dyndns.org (adsl-63-207-60-27.dsl.lsan03.pacbell.net [63.207.60.27]) by hub.freebsd.org (Postfix) with ESMTP id 86ACA37B423 for ; Sun, 29 Apr 2001 01:54:49 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 0FA1066C9B; Sun, 29 Apr 2001 01:54:48 -0700 (PDT) Date: Sun, 29 Apr 2001 01:54:48 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: CTM fixes Message-ID: <20010429015448.A76638@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="XsQoSWH+UP9D9v3l" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Please review the following patch. It contains the following changes: * fix ctm(8) to use mkstemp() instead of tempnam() for tempfile creation. * Tag the internal err() function with __printflike to allow checking for non-constant format string arguments (none exist) * Use fmtcheck() to sanitize the tar command obtained via -t to make sure it doesn't contain extraneous format operators. Kris Index: ctm/ctm_pass2.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/usr.sbin/ctm/ctm/ctm_pass2.c,v retrieving revision 1.18 diff -u -r1.18 ctm_pass2.c --- ctm/ctm_pass2.c 2000/01/15 19:45:18 1.18 +++ ctm/ctm_pass2.c 2001/04/29 08:53:53 @@ -22,7 +22,7 @@ { u_char *p,*q,*md5=3D0; MD5_CTX ctx; - int i,j,sep,cnt; + int i,j,sep,cnt,fdesc; u_char *trash=3D0,*name=3D0; struct CTM_Syntax *sp; struct stat st; @@ -31,6 +31,7 @@ char md5_1[33]; struct CTM_Filter *filter; FILE *ed =3D NULL; + static char *template =3D NULL; =20 if(Verbose>3) printf("Pass2 -- Checking if CTM-patch will apply\n"); @@ -187,8 +188,37 @@ GETDATA(trash,cnt); if (!match) break; + if (!template) { + if (asprintf(&template, "%s/CTMclientXXXXXX", + TmpDir) =3D=3D -1) { + fprintf(stderr, " %s: malloc failed.\n", + sp->Key); + ret |=3D Exit_Mess; + return ret; + } + } if(!strcmp(sp->Key,"FN")) { - p =3D tempnam(TmpDir,"CTMclient"); + if ((p =3D strdup(template)) =3D=3D NULL) { + fprintf(stderr, " %s: malloc failed.\n", + sp->Key); + ret |=3D Exit_Mess; + return ret; + } + if ((fdesc =3D mkstemp(p)) =3D=3D -1) { + fprintf(stderr, " %s: mkstemp failed.\n", + sp->Key); + ret |=3D Exit_Mess; + Free(p); + return ret; + } + if (close(fdesc) =3D=3D -1) { + fprintf(stderr, " %s: close failed.\n", + sp->Key); + ret |=3D Exit_Mess; + unlink(p); + Free(p); + return ret; + } j =3D ctm_edit(trash,cnt,name,p); if(j) { fprintf(stderr," %s: %s edit returned %d.\n", @@ -208,7 +238,27 @@ unlink(p); Free(p); } else if (!strcmp(sp->Key,"FE")) { - p =3D tempnam(TmpDir,"CTMclient"); + if ((p =3D strdup(template)) =3D=3D NULL) { + fprintf(stderr, " %s: malloc failed.\n", + sp->Key); + ret |=3D Exit_Mess; + return ret; + } + if ((fdesc =3D mkstemp(p)) =3D=3D -1) { + fprintf(stderr, " %s: mkstemp failed.\n", + sp->Key); + ret |=3D Exit_Mess; + Free(p); + return ret; + } + if (close(fdesc) =3D=3D -1) { + fprintf(stderr, " %s: close failed.\n", + sp->Key); + ret |=3D Exit_Mess; + unlink(p); + Free(p); + return ret; + } ed =3D popen("ed","w"); if (!ed) { WRONG Index: ctm/ctm_passb.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/usr.sbin/ctm/ctm/ctm_passb.c,v retrieving revision 1.5 diff -u -r1.5 ctm_passb.c --- ctm/ctm_passb.c 1999/08/28 01:16:00 1.5 +++ ctm/ctm_passb.c 2001/04/29 08:47:31 @@ -36,7 +36,7 @@ printf("PassB -- Backing up files which would be changed.\n"); =20 MD5Init (&ctx); - sprintf(buf, TarCmd, BackupFile); + snprintf(buf, sizeof(buf), fmtcheck(TarCmd, TARCMD), BackupFile); b=3Dpopen(buf, "w"); if(!b) { warn("%s", buf); return Exit_Garbage; } =20 Index: ctm_rmail/error.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/usr.sbin/ctm/ctm_rmail/error.c,v retrieving revision 1.2 diff -u -r1.2 error.c --- ctm_rmail/error.c 1995/02/25 05:10:18 1.2 +++ ctm_rmail/error.c 2001/04/29 08:48:56 @@ -58,7 +58,7 @@ * decoded and appended. */ void -err(char *fmt, ...) +err(const char *fmt, ...) { va_list ap; time_t now; Index: ctm_rmail/error.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/usr.sbin/ctm/ctm_rmail/error.h,v retrieving revision 1.1 diff -u -r1.1 error.h --- ctm_rmail/error.h 1995/01/31 19:12:41 1.1 +++ ctm_rmail/error.h 2001/04/29 08:49:05 @@ -1,3 +1,3 @@ extern void err_set_log(char *log_file); extern void err_prog_name(char *name); -extern void err(char *fmt, ...); +extern void err(const char *fmt, ...) __printflike(1, 2); --XsQoSWH+UP9D9v3l Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE669bYWry0BWjoQKURAnYmAKDiOJKXlWHAKDECTz+Nl7NLVEP/BACdGzdW qCx0kd7roJGXYozVF78DWwM= =TtaU -----END PGP SIGNATURE----- --XsQoSWH+UP9D9v3l-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Apr 29 2: 1: 1 2001 Delivered-To: freebsd-audit@freebsd.org Received: from obsecurity.dyndns.org (adsl-63-207-60-27.dsl.lsan03.pacbell.net [63.207.60.27]) by hub.freebsd.org (Postfix) with ESMTP id DD28937B422 for ; Sun, 29 Apr 2001 02:00:58 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 885F366C9B; Sun, 29 Apr 2001 02:00:58 -0700 (PDT) Date: Sun, 29 Apr 2001 02:00:58 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: m4 mkstemp() fixes Message-ID: <20010429020057.A76909@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="n8g4imXOkfNTN/H1" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --n8g4imXOkfNTN/H1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This one is obtained from OpenBSD. Even though it contains the style bug of scoped variable definitions, since this patch reduces diffs to OpenBSD I think it should stay that way. Kris Index: eval.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/usr.bin/m4/eval.c,v retrieving revision 1.11 diff -u -r1.11 eval.c --- eval.c 2000/11/27 04:26:39 1.11 +++ eval.c 2001/04/29 08:58:55 @@ -295,8 +295,19 @@ /* * dotemp - create a temporary file */ - if (argc > 2) - pbstr(mktemp(argv[2])); + if (argc > 2) { + int fd; + char *temp; + + temp =3D xstrdup(argv[2]); + =09 + fd =3D mkstemp(temp); + if (fd =3D=3D -1) + err(1, "couldn't make temp file %s", argv[2]); + close(fd); + pbstr(temp); + free(temp); + } break; =20 case TRNLTYPE: --n8g4imXOkfNTN/H1 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE669hJWry0BWjoQKURAvRTAKDQWDeK3CadWzhP+mqlQauhMTqSggCgmJ2z uOASVp/SQsAY0gDZHtUz/q8= =dT1L -----END PGP SIGNATURE----- --n8g4imXOkfNTN/H1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Apr 29 2:36:12 2001 Delivered-To: freebsd-audit@freebsd.org Received: from obsecurity.dyndns.org (adsl-63-207-60-27.dsl.lsan03.pacbell.net [63.207.60.27]) by hub.freebsd.org (Postfix) with ESMTP id B0DD137B42C for ; Sun, 29 Apr 2001 02:36:08 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id D21A666C9B; Sun, 29 Apr 2001 02:36:07 -0700 (PDT) Date: Sun, 29 Apr 2001 02:36:07 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: rdist tempfile fixes Message-ID: <20010429023607.A77379@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This one's been moved from the src tree to the 44bsd-rdist port, but the patch can still be applied (apply it by hand for now after checking out the port; I have a rerolled version of the distfile with the patch checked into RCS) Kris Index: main.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/usr.bin/rdist/Attic/main.c,v retrieving revision 1.5 diff -u -r1.5 main.c --- main.c 1999/08/28 01:05:07 1.5 +++ main.c 2001/04/29 09:16:03 @@ -52,7 +52,7 @@ =20 char *distfile =3D NULL; #define _RDIST_TMP "/rdistXXXXXX" -char tempfile[sizeof _PATH_TMP + sizeof _RDIST_TMP + 1]; +char tempfile[PATH_MAX]; char *tempname; =20 int debug; /* debugging flag */ @@ -83,20 +84,21 @@ char *argv[]; { register char *arg; - int cmdargs =3D 0; - char *dhosts[NHOSTS], **hp =3D dhosts; + int cmdargs =3D 0, fd; + char *dhosts[NHOSTS], **hp =3D dhosts, *tmpdir; =20 pw =3D getpwuid(userid =3D getuid()); if (pw =3D=3D NULL) { fprintf(stderr, "%s: Who are you?\n", argv[0]); exit(1); } - strcpy(user, pw->pw_name); - strcpy(homedir, pw->pw_dir); + strlcpy(user, pw->pw_name, sizeof(user)); + strlcpy(homedir, pw->pw_dir, sizeof(homedir)); groupid =3D pw->pw_gid; gethostname(host, sizeof(host)); - strcpy(tempfile, _PATH_TMP); - strcat(tempfile, _RDIST_TMP); + if ((tmpdir =3D getenv("TMPDIR")) =3D=3D NULL) + tmpdir =3D _PATH_TMP; + snprintf(tempfile, sizeof(tempfile), "%s%s", tmpdir, _RDIST_TMP); if ((tempname =3D rindex(tempfile, '/')) !=3D 0) tempname++; else @@ -198,8 +200,16 @@ *hp =3D NULL; =20 seteuid(userid); - mktemp(tempfile); - + if ((fd =3D mkstemp(tempfile)) =3D=3D -1) { + fprintf(stderr, "rdist: mkstemp failed\n"); + exit(1); + } + if (close(fd) =3D=3D -1) { + unlink(tempfile); + fprintf(stderr, "rdist: mkstemp failed\n"); + exit(1); + } + =09 if (iamremote) { server(); exit(nerrs !=3D 0); --gBBFr7Ir9EOA20Yy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE66+CHWry0BWjoQKURAp23AKDWoJjRNxJ3NOLmAthlGrYs6aFjIACfdf+E n8m0ysnd+2up0+9hcmZkjhc= =4f4j -----END PGP SIGNATURE----- --gBBFr7Ir9EOA20Yy-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Apr 29 3: 1: 0 2001 Delivered-To: freebsd-audit@freebsd.org Received: from obsecurity.dyndns.org (adsl-63-207-60-27.dsl.lsan03.pacbell.net [63.207.60.27]) by hub.freebsd.org (Postfix) with ESMTP id D07A637B43C for ; Sun, 29 Apr 2001 03:00:53 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 5DD9B66DB9; Sun, 29 Apr 2001 03:00:53 -0700 (PDT) Date: Sun, 29 Apr 2001 03:00:53 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: RCS mkstemp fixes Message-ID: <20010429030053.A79687@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="xHFwDpU9dbj6ez1V" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --xHFwDpU9dbj6ez1V Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Another one obtained from OpenBSD. Please review. The #ifdef has_mktemp is misnamed, but since the RCS code seems to be unmaintained thesedays, there's probably not much point in making it into a separate has_mkstemp. Kris Index: rcsedit.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/gnu/usr.bin/rcs/lib/rcsedit.c,v retrieving revision 1.11 diff -u -r1.11 rcsedit.c --- rcsedit.c 2000/01/11 11:55:26 1.11 +++ rcsedit.c 2001/04/29 09:53:13 @@ -1507,6 +1507,9 @@ register size_t dl; register struct buf *bn; register char const *name =3D isworkfile ? workname : RCSname; +# if has_mktemp + int fd; +# endif =20 dl =3D basefilename(name) - name; bn =3D &dirtpname[newRCSdirtp_index + isworkfile]; @@ -1525,10 +1528,12 @@ catchints(); # if has_mktemp VOID strcpy(tp, "XXXXXX"); - if (!mktemp(np) || !*np) + fd =3D mkstemp(np); + if (fd < 0 || !*np) faterror("can't make temporary pathname `%.*s_%cXXXXXX'", (int)dl, name, '0'+isworkfile ); + close(fd); # else /* * Posix 1003.1-1990 has no reliable way Index: rcsfnms.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /mnt/ncvs/src/gnu/usr.bin/rcs/lib/rcsfnms.c,v retrieving revision 1.10 diff -u -r1.10 rcsfnms.c --- rcsfnms.c 1999/08/27 23:36:46 1.10 +++ rcsfnms.c 2001/04/29 09:56:04 @@ -284,6 +284,9 @@ { char *p; char const *t =3D tpnames[n]; +# if has_mktemp + int fd; +# endif =20 if (t) return t; @@ -295,10 +298,12 @@ size_t tplen =3D dir_useful_len(tp); p =3D testalloc(tplen + 10); VOID sprintf(p, "%.*s%cT%cXXXXXX", (int)tplen, tp, SLASH, '0'+n); - if (!mktemp(p) || !*p) + fd =3D mkstemp(p); + if (fd < 0 || !*p) faterror("can't make temporary pathname `%.*s%cT%cXXXXXX'", (int)tplen, tp, SLASH, '0'+n ); + close(fd); # else static char tpnamebuf[TEMPNAMES][L_tmpnam]; p =3D tpnamebuf[n]; --xHFwDpU9dbj6ez1V Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE66+ZUWry0BWjoQKURAlWQAKDrDaXYxvqVpFvptA8rNiBJXaiWSgCfQrRl ZDMvHkfbBd1bEHfKDeFet0A= =ZodA -----END PGP SIGNATURE----- --xHFwDpU9dbj6ez1V-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sun Apr 29 14:37:24 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 7E7C137B424 for ; Sun, 29 Apr 2001 14:37:15 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 06D613E0B for ; Sun, 29 Apr 2001 14:37:15 -0700 (PDT) To: audit@freebsd.org Subject: sha1 support in md5(1) Date: Sun, 29 Apr 2001 14:37:14 -0700 From: Dima Dorfman Message-Id: <20010429213715.06D613E0B@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Attached is a patch that adds SHA1 support to the md5(1) program. Please review. This patch makes sha1(1) a link to md5(1); the same program was chosen because much of the support code would be identical. This is also the way OpenBSD implemented it, and it makes sense, as well as making it easier to add other digest algorithms in the future (OpenBSD has rmd160, for example). Thanks, Dima Dorfman dima@unixfreak.org Index: Makefile =================================================================== RCS file: /st/src/FreeBSD/src/sbin/md5/Makefile,v retrieving revision 1.4 diff -u -r1.4 Makefile --- Makefile 2001/03/26 14:33:10 1.4 +++ Makefile 2001/04/29 21:27:14 @@ -5,5 +5,6 @@ LDADD+= -lmd DPADD+= ${LIBMD} +LINKS= ${BINDIR}/md5 ${BINDIR}/sha1 .include Index: md5.c =================================================================== RCS file: /st/src/FreeBSD/src/sbin/md5/md5.c,v retrieving revision 1.21 diff -u -r1.21 md5.c --- md5.c 2000/11/08 20:41:35 1.21 +++ md5.c 2001/04/29 21:27:14 @@ -28,25 +28,45 @@ #include #include #include +#include +#include #include #include "global.h" +extern const char *__progname; /*XXX*/ + /* * Length of test block, number of test blocks. */ #define TEST_BLOCK_LEN 10000 #define TEST_BLOCK_COUNT 100000 +/* Maximum length of digest. */ +#define MAX_DIGEST_LEN 41 + int qflag; int rflag; +static void MDSetAlgo PROTO_LIST((char *)); static void MDString PROTO_LIST((char *)); static void MDTimeTrial PROTO_LIST((void)); static void MDTestSuite PROTO_LIST((void)); static void MDFilter PROTO_LIST((int)); static void usage PROTO_LIST((void)); +/* + * Global pointers to procedures/info to/of the "real" message digest + * algorithm. + */ +void (*MDInit)(); +void (*MDUpdate)(); +char *(*MDEnd)(); +char *(*MDFile)(); +char *(*MDData)(); +char *MDName; +void *MDContext; + /* Main driver. Arguments (may be any combination): @@ -63,7 +83,9 @@ { int ch; char *p; - char buf[33]; + char buf[MAX_DIGEST_LEN]; + + MDSetAlgo(__progname); if (argc > 1) { while ((ch = getopt(argc, argv, "ps:qrtx")) != -1) { @@ -91,7 +113,7 @@ } } while (optind < argc) { - p = MD5File(argv[optind], buf); + p = MDFile(argv[optind], buf); if (!p) warn("%s", argv[optind]); else @@ -100,8 +122,8 @@ else if (rflag) printf("%s %s\n", p, argv[optind]); else - printf("MD5 (%s) = %s\n", argv[optind], - p); + printf("%s (%s) = %s\n", MDName, + argv[optind], p); optind++; } } else @@ -109,7 +131,36 @@ return (0); } + /* + * Set the algorithm based on the argument. + */ +static void +MDSetAlgo(name) + char *name; +{ + if (strcmp(name, "sha1") == 0) { + MDName = "SHA1"; + MDInit = SHA1_Init; + MDUpdate = SHA1_Update; + MDEnd = SHA1_End; + MDFile = SHA1_File; + MDData = SHA1_Data; + MDContext = malloc(sizeof(SHA1_CTX)); + } else { + MDName = "MD5"; + MDInit = MD5Init; + MDUpdate = MD5Update; + MDEnd = MD5End; + MDFile = MD5File; + MDData = MD5Data; + MDContext = malloc(sizeof(MD5_CTX)); + } + if (MDContext == NULL) + err(1, "malloc"); +} + +/* * Digests a string and prints the result. */ static void @@ -117,14 +168,15 @@ char *string; { size_t len = strlen(string); - char buf[33]; + char buf[MAX_DIGEST_LEN]; if (qflag) - printf("%s\n", MD5Data(string, len, buf)); + printf("%s\n", MDData(string, len, buf)); else if (rflag) - printf("%s \"%s\"\n", MD5Data(string, len, buf), string); + printf("%s \"%s\"\n", MDData(string, len, buf), string); else - printf("MD5 (\"%s\") = %s\n", string, MD5Data(string, len, buf)); + printf("%s (\"%s\") = %s\n", MDName, string, + MDData(string, len, buf)); } /* * Measures the time to digest TEST_BLOCK_COUNT TEST_BLOCK_LEN-byte blocks. @@ -132,14 +184,13 @@ static void MDTimeTrial() { - MD5_CTX context; time_t endTime, startTime; unsigned char block[TEST_BLOCK_LEN]; unsigned int i; - char *p, buf[33]; + char *p, buf[MAX_DIGEST_LEN]; printf - ("MD5 time trial. Digesting %d %d-byte blocks ...", + ("%s time trial. Digesting %d %d-byte blocks ...", MDName, TEST_BLOCK_COUNT, TEST_BLOCK_LEN); fflush(stdout); @@ -151,10 +202,10 @@ time(&startTime); /* Digest blocks */ - MD5Init(&context); + MDInit(MDContext); for (i = 0; i < TEST_BLOCK_COUNT; i++) - MD5Update(&context, block, TEST_BLOCK_LEN); - p = MD5End(&context,buf); + MDUpdate(MDContext, block, TEST_BLOCK_LEN); + p = MD5End(MDContext ,buf); /* Stop timer */ time(&endTime); @@ -175,7 +226,7 @@ MDTestSuite() { - printf("MD5 test suite:\n"); + printf("%s test suite:\n", MDName); MDString(""); MDString("a"); @@ -196,24 +247,23 @@ MDFilter(pipe) int pipe; { - MD5_CTX context; int len; unsigned char buffer[BUFSIZ]; - char buf[33]; + char buf[MAX_DIGEST_LEN]; - MD5Init(&context); + MDInit(MDContext); while ((len = fread(buffer, 1, BUFSIZ, stdin))) { if(pipe && (len != fwrite(buffer, 1, len, stdout))) err(1, "stdout"); - MD5Update(&context, buffer, len); + MDUpdate(MDContext, buffer, len); } - printf("%s\n", MD5End(&context,buf)); + printf("%s\n", MDEnd(MDContext,buf)); } static void usage() { - - fprintf(stderr, "usage: md5 [-pqrtx] [-s string] [files ...]\n"); + fprintf(stderr, "usage: %s [-pqrtx] [-s string] [files ...]\n", + __progname); exit(1); } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 14:48:27 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 4D08137B422 for ; Mon, 30 Apr 2001 14:48:23 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f3ULmMu172729; Mon, 30 Apr 2001 17:48:22 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCM00J9KKKLMJ@gkar.cc.vt.edu>; Mon, 30 Apr 2001 17:48:21 -0400 (EDT) Date: Mon, 30 Apr 2001 17:46:49 -0400 (EDT) From: Mike Heffner Subject: RE: du(1) -I option to ignore files/dirs In-reply-to: <20010428194259.J415@ringworld.oblivion.bg> To: Peter Pentchev Cc: audit@FreeBSD.org Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010430174649:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010430174649:439=_ Content-Type: text/plain; charset=us-ascii On 28-Apr-2001 Peter Pentchev wrote: | Hi, | | And just when -arch thought they'd gotten rid of me and my du(1) patches.. ;) | | Well, since no one had any real objections to adding the -I flag, other than | 'no one else is doing that' (so why can't we?), and as several people agreed | that there was no easy (or moderately hard) way to do this with other utils, | here's an updated patch that properly uses slist's instead of the constant- | sized arrays in the previous version. Looks good | | + | +int | +ignorep(ent) | + FTSENT *ent; | +{ | + struct ignentry *ign; | + | + if (SLIST_EMPTY(&ignores)) | + return 0; This isn't needed though because it's caught in the _FOREACH. Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010430174649:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67d1JFokZQs3sv5kRAo34AJ41LuY+BEGQkJk3P4Ksa5vSGCVejACeIhlP 8YrweHorBHoSNsTbFLIKpMM= =8HI2 -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010430174649:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 14:52:23 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 2A1EF37B422 for ; Mon, 30 Apr 2001 14:52:21 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f3ULqKu196287; Mon, 30 Apr 2001 17:52:20 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCM00JKGKR7MZ@gkar.cc.vt.edu>; Mon, 30 Apr 2001 17:52:19 -0400 (EDT) Date: Mon, 30 Apr 2001 17:50:48 -0400 (EDT) From: Mike Heffner Subject: RE: CTM fixes In-reply-to: <20010429015448.A76638@xor.obsecurity.org> To: Kris Kennaway Cc: audit@FreeBSD.org Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010430175048:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010430175048:439=_ Content-Type: text/plain; charset=us-ascii On 29-Apr-2001 Kris Kennaway wrote: | Please review the following patch. It contains the following changes: | | * fix ctm(8) to use mkstemp() instead of tempnam() for tempfile | creation. | | * Tag the internal err() function with __printflike to allow checking | for non-constant format string arguments (none exist) | | * Use fmtcheck() to sanitize the tar command obtained via -t to make | sure it doesn't contain extraneous format operators. Looks good! Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010430175048:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67d44FokZQs3sv5kRAriSAJ0f/8YZVKFGjKYUoZHPEzJbo3kyRQCfb1bE 1sRxFZoyhYzTM4wmVWYrIDA= =cbyR -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010430175048:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 14:59:45 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 72D8137B422 for ; Mon, 30 Apr 2001 14:59:39 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f3ULxcu199251; Mon, 30 Apr 2001 17:59:38 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCM00J0WL3DMJ@gkar.cc.vt.edu>; Mon, 30 Apr 2001 17:59:38 -0400 (EDT) Date: Mon, 30 Apr 2001 17:58:06 -0400 (EDT) From: Mike Heffner Subject: RE: m4 mkstemp() fixes In-reply-to: <20010429020057.A76909@xor.obsecurity.org> To: Kris Kennaway Cc: audit@FreeBSD.org Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010430175806:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010430175806:439=_ Content-Type: text/plain; charset=us-ascii On 29-Apr-2001 Kris Kennaway wrote: | This one is obtained from OpenBSD. Even though it contains the style | bug of scoped variable definitions, since this patch reduces diffs to | OpenBSD I think it should stay that way. Looks good! Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010430175806:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67d/uFokZQs3sv5kRAiZJAKCgEYeFua+59BQ1i5yOnzBF9cdVXACcDOO0 uzlmNUYeNVO0QfGBIubLLfs= =HbNg -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010430175806:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 16:30:33 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id B0B2A37B423 for ; Mon, 30 Apr 2001 16:30:30 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f3UNUTu213557; Mon, 30 Apr 2001 19:30:30 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCM008DUPATME@gkar.cc.vt.edu>; Mon, 30 Apr 2001 19:30:29 -0400 (EDT) Date: Mon, 30 Apr 2001 19:28:58 -0400 (EDT) From: Mike Heffner Subject: RE: rdist tempfile fixes In-reply-to: <20010429023607.A77379@xor.obsecurity.org> To: Kris Kennaway Cc: audit@FreeBSD.org Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010430192858:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010430192858:439=_ Content-Type: text/plain; charset=us-ascii On 29-Apr-2001 Kris Kennaway wrote: | This one's been moved from the src tree to the 44bsd-rdist port, but | the patch can still be applied (apply it by hand for now after | checking out the port; I have a rerolled version of the distfile with | the patch checked into RCS) Looks good. I haven't checked, but are there any issues with the tempfile not getting deleted properly? Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010430192858:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67fU6FokZQs3sv5kRArEkAJ9PK0n7oC37RlGAxEb6QKKSbjQWigCfW/gW wxNyRKY/wHhJDTJyyxNliwM= =AeB2 -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010430192858:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 16:41: 2 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 8529337B424 for ; Mon, 30 Apr 2001 16:40:59 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f3UNewu213879; Mon, 30 Apr 2001 19:40:58 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCM007WTPSAE4@gkar.cc.vt.edu>; Mon, 30 Apr 2001 19:40:58 -0400 (EDT) Date: Mon, 30 Apr 2001 19:39:27 -0400 (EDT) From: Mike Heffner Subject: RE: RCS mkstemp fixes In-reply-to: <20010429030053.A79687@xor.obsecurity.org> To: Kris Kennaway Cc: audit@FreeBSD.org Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010430193927:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010430193927:439=_ Content-Type: text/plain; charset=us-ascii On 29-Apr-2001 Kris Kennaway wrote: | Another one obtained from OpenBSD. Please review. The #ifdef | has_mktemp is misnamed, but since the RCS code seems to be | unmaintained thesedays, there's probably not much point in making it | into a separate has_mkstemp. Looks good. Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010430193927:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67fevFokZQs3sv5kRAjoEAJ9+HG3Y7LYamO8TThB1v3NC7GosdwCeO1T+ CpmLBk0uqWbK73thP5VC9lk= =bnX/ -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010430193927:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 20:46:19 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id E9BF837B423 for ; Mon, 30 Apr 2001 20:46:15 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f413kEu256214 for ; Mon, 30 Apr 2001 23:46:14 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCN00DTD152RQ@gkar.cc.vt.edu> for FreeBSD-audit@freebsd.org; Mon, 30 Apr 2001 23:46:14 -0400 (EDT) Date: Mon, 30 Apr 2001 23:44:42 -0400 (EDT) From: Mike Heffner Subject: Small patch to allow mail to read Eudora mailboxes To: FreeBSD-audit Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010430234442:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010430234442:439=_ Content-Type: text/plain; charset=us-ascii Found this in the OpenBSD tree, I'd like to commit it to our mail(1). Any objections to this? Index: fio.c =================================================================== RCS file: /home/ncvs/src/usr.bin/mail/fio.c,v retrieving revision 1.4 diff -u -r1.4 fio.c --- fio.c 2001/03/25 04:57:04 1.4 +++ fio.c 2001/05/01 03:41:37 @@ -94,6 +94,14 @@ return; } count = strlen(linebuf); + /* + * Transforms lines ending in to just . + * This allows mail to be able to read Eudora mailboxes. + */ + if (count >= 2 && linebuf[count-1] == '\n' && + linebuf[count - 2] == '\r') + linebuf[count - 2] = linebuf[--count]; + (void) fwrite(linebuf, sizeof *linebuf, count, otf); if (ferror(otf)) errx(1, "/tmp"); @@ -160,7 +168,7 @@ /* * Read up a line from the specified input into the line * buffer. Return the number of characters read. Do not - * include the newline at the end. + * include the newline (or carriage return) at the end. */ int readline(ibuf, linebuf, linesize) @@ -175,6 +183,8 @@ return -1; n = strlen(linebuf); if (n > 0 && linebuf[n - 1] == '\n') + linebuf[--n] = '\0'; + if (n > 0 && linebuf[n - 1] == '\r') linebuf[--n] = '\0'; return n; } Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010430234442:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67jEqFokZQs3sv5kRAh4bAJ49rsKOyR6nZt9AFhatCTgEu520iQCfYtPm oAWr89t5haKCYnBVfaK9mjE= =2yuk -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010430234442:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 20:50:28 2001 Delivered-To: freebsd-audit@freebsd.org Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id DBFF537B423 for ; Mon, 30 Apr 2001 20:50:25 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.11.3/8.11.1) with ESMTP id f413oOR56065; Mon, 30 Apr 2001 21:50:24 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200105010350.f413oOR56065@harmony.village.org> To: Mike Heffner Subject: Re: Small patch to allow mail to read Eudora mailboxes Cc: FreeBSD-audit In-reply-to: Your message of "Mon, 30 Apr 2001 23:44:42 EDT." References: Date: Mon, 30 Apr 2001 21:50:24 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message Mike Heffner writes: : + if (count >= 2 && linebuf[count-1] == '\n' && : + linebuf[count - 2] == '\r') : + linebuf[count - 2] = linebuf[--count]; Why not just if (count >= 2 && linebuf[count-1] == '\n' && linebuf[count - 2] == '\r') { count--; linebuf[count - 1] = '\n'; } which is clearer and you avoid a hard to understand (and maybe ill defined) side effect with the --count part of the statement. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 20:52:13 2001 Delivered-To: freebsd-audit@freebsd.org Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id 1141537B424 for ; Mon, 30 Apr 2001 20:52:11 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.11.3/8.11.1) with ESMTP id f413q6R56095; Mon, 30 Apr 2001 21:52:06 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200105010352.f413q6R56095@harmony.village.org> Subject: Re: Small patch to allow mail to read Eudora mailboxes Cc: Mike Heffner , FreeBSD-audit In-reply-to: Your message of "Mon, 30 Apr 2001 21:50:24 MDT." <200105010350.f413oOR56065@harmony.village.org> References: <200105010350.f413oOR56065@harmony.village.org> Date: Mon, 30 Apr 2001 21:52:06 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <200105010350.f413oOR56065@harmony.village.org> Warner Losh writes: : In message Mike Heffner writes: : : + if (count >= 2 && linebuf[count-1] == '\n' && : : + linebuf[count - 2] == '\r') : : + linebuf[count - 2] = linebuf[--count]; : : Why not just : : if (count >= 2 && linebuf[count-1] == '\n' && : linebuf[count - 2] == '\r') { : count--; : linebuf[count - 1] = '\n'; : } : : which is clearer and you avoid a hard to understand (and maybe ill : defined) side effect with the --count part of the statement. Also, make that 'count - 1' rather than 'count-1' Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 21: 1:49 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 1928937B423 for ; Mon, 30 Apr 2001 21:01:46 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f4141ju257994; Tue, 1 May 2001 00:01:45 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCN00I141UWF8@gkar.cc.vt.edu>; Tue, 1 May 2001 00:01:44 -0400 (EDT) Date: Tue, 01 May 2001 00:00:13 -0400 (EDT) From: Mike Heffner Subject: Re: Small patch to allow mail to read Eudora mailboxes In-reply-to: <200105010350.f413oOR56065@harmony.village.org> To: Warner Losh Cc: FreeBSD-audit Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010501000013:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010501000013:439=_ Content-Type: text/plain; charset=us-ascii On 01-May-2001 Warner Losh wrote: | In message Mike Heffner writes: |: + if (count >= 2 && linebuf[count-1] == '\n' && |: + linebuf[count - 2] == '\r') |: + linebuf[count - 2] = linebuf[--count]; | | Why not just | | if (count >= 2 && linebuf[count-1] == '\n' && | linebuf[count - 2] == '\r') { | count--; | linebuf[count - 1] = '\n'; | } | | which is clearer and you avoid a hard to understand (and maybe ill | defined) side effect with the --count part of the statement. Because I was syncing with OpenBSD, but yes it can be done this way instead. Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010501000013:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67jTNFokZQs3sv5kRAsyYAJ9uG55oGUJYIr7+P0Bw8iJj4FeaKwCgl5wO wY6dfbCyZxZyZnbq9DbImqQ= =1FXk -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010501000013:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 21:19:51 2001 Delivered-To: freebsd-audit@freebsd.org Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id 3B54D37B422 for ; Mon, 30 Apr 2001 21:19:49 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.11.3/8.11.1) with ESMTP id f414JlR56227; Mon, 30 Apr 2001 22:19:47 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200105010419.f414JlR56227@harmony.village.org> To: Mike Heffner Subject: Re: Small patch to allow mail to read Eudora mailboxes Cc: FreeBSD-audit In-reply-to: Your message of "Tue, 01 May 2001 00:00:13 EDT." References: Date: Mon, 30 Apr 2001 22:19:47 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message Mike Heffner writes: : Because I was syncing with OpenBSD, but yes it can be done this way instead. I think that OpenBSD might have a bug lurking because I don't think the order of operations is well defined enough. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 21:20:26 2001 Delivered-To: freebsd-audit@freebsd.org Received: from harmony.village.org (rover.bsdimp.com [204.144.255.66]) by hub.freebsd.org (Postfix) with ESMTP id B9DD537B423 for ; Mon, 30 Apr 2001 21:20:23 -0700 (PDT) (envelope-from imp@harmony.village.org) Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.11.3/8.11.1) with ESMTP id f414KLR56258; Mon, 30 Apr 2001 22:20:21 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200105010420.f414KLR56258@harmony.village.org> Subject: Re: Small patch to allow mail to read Eudora mailboxes Cc: Mike Heffner , FreeBSD-audit In-reply-to: Your message of "Mon, 30 Apr 2001 22:19:47 MDT." <200105010419.f414JlR56227@harmony.village.org> References: <200105010419.f414JlR56227@harmony.village.org> Date: Mon, 30 Apr 2001 22:20:21 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <200105010419.f414JlR56227@harmony.village.org> Warner Losh writes: : In message Mike Heffner writes: : : Because I was syncing with OpenBSD, but yes it can be done this way instead. : : I think that OpenBSD might have a bug lurking because I don't think : the order of operations is well defined enough. BTW, I still have OpenBSD commit privs, so I can minor changes like this. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Mon Apr 30 21:59:23 2001 Delivered-To: freebsd-audit@freebsd.org Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.161.193]) by hub.freebsd.org (Postfix) with ESMTP id 8B17237B43F for ; Mon, 30 Apr 2001 21:59:18 -0700 (PDT) (envelope-from mheffner@vt.edu) Received: from mail.vt.edu (gkar.cc.vt.edu [198.82.161.190]) by lennier.cc.vt.edu (8.11.0/8.11.0) with ESMTP id f414xHu270511; Tue, 1 May 2001 00:59:17 -0400 (EDT) Received: from enterprise.muriel.penguinpowered.com ([198.82.100.151]) by gkar.cc.vt.edu (Sun Internet Mail Server sims.3.5.2000.03.23.18.03.p10) with ESMTP id <0GCN00IJT4ITDS@gkar.cc.vt.edu>; Tue, 1 May 2001 00:59:17 -0400 (EDT) Date: Tue, 01 May 2001 00:57:46 -0400 (EDT) From: Mike Heffner Subject: Re: Small patch to allow mail to read Eudora mailboxes In-reply-to: <200105010419.f414JlR56227@harmony.village.org> To: Warner Losh Cc: FreeBSD-audit Message-id: MIME-version: 1.0 X-Mailer: XFMail 1.4.7 on FreeBSD Content-type: multipart/signed; boundary="_=XFMail.1.4.7.FreeBSD:20010501005746:439=_"; micalg=pgp-md5; protocol="application/pgp-signature" X-Priority: 3 (Normal) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format --_=XFMail.1.4.7.FreeBSD:20010501005746:439=_ Content-Type: text/plain; charset=us-ascii On 01-May-2001 Warner Losh wrote: | In message Mike Heffner writes: |: Because I was syncing with OpenBSD, but yes it can be done this way instead. | | I think that OpenBSD might have a bug lurking because I don't think | the order of operations is well defined enough. You're right, while it does work, it's relying on undefined behavior. Here's the updated patch. Index: fio.c =================================================================== RCS file: /home/ncvs/src/usr.bin/mail/fio.c,v retrieving revision 1.4 diff -u -r1.4 fio.c --- fio.c 2001/03/25 04:57:04 1.4 +++ fio.c 2001/05/01 04:53:50 @@ -94,6 +94,16 @@ return; } count = strlen(linebuf); + /* + * Transforms lines ending in to just . + * This allows mail to be able to read Eudora mailboxes. + */ + if (count >= 2 && linebuf[count - 1] == '\n' && + linebuf[count - 2] == '\r') { + count--; + linebuf[count - 1] = '\n'; + } + (void) fwrite(linebuf, sizeof *linebuf, count, otf); if (ferror(otf)) errx(1, "/tmp"); @@ -160,7 +170,7 @@ /* * Read up a line from the specified input into the line * buffer. Return the number of characters read. Do not - * include the newline at the end. + * include the newline (or carriage return) at the end. */ int readline(ibuf, linebuf, linesize) @@ -175,6 +185,8 @@ return -1; n = strlen(linebuf); if (n > 0 && linebuf[n - 1] == '\n') + linebuf[--n] = '\0'; + if (n > 0 && linebuf[n - 1] == '\r') linebuf[--n] = '\0'; return n; } Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010501005746:439=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE67kJKFokZQs3sv5kRAq+KAKCKR86aFfsToDkO36O2oJyBWdPvFgCfUpxK jBwhBxA92qbdHLslpZAYwBg= =LyBD -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010501005746:439=_-- End of MIME message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 19:53:28 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 7FC3A37B423 for ; Tue, 1 May 2001 19:53:22 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 114703E28 for ; Tue, 1 May 2001 19:53:22 -0700 (PDT) To: audit@freebsd.org Subject: {get,set}progname functions Date: Tue, 01 May 2001 19:53:21 -0700 From: Dima Dorfman Message-Id: <20010502025322.114703E28@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Some time ago, kris sent a message to -arch asking for comments on the inclusion of the getprogname and setprogname functions. These were recently added to NetBSD. Responses to kris' query were generally favorable. The message can be found here: http://docs.FreeBSD.org/cgi/getmsg.cgi?fetch=234758+0+archive/2001/freebsd-arch/20010225.freebsd-arch Attached is a patch to implement these in FreeBSD. Obviously, there's not much to implement since getprogname is a wrapper around a `return', and setprogname is a stub. Please review and, if acceptable, commit it. Thanks in advance, Dima Dorfman dima@unixfreak.org Index: include/stdlib.h =================================================================== RCS file: /st/src/FreeBSD/src/include/stdlib.h,v retrieving revision 1.20 diff -u -r1.20 stdlib.h --- include/stdlib.h 2001/04/23 09:32:06 1.20 +++ include/stdlib.h 2001/05/02 02:42:07 @@ -157,6 +157,7 @@ int daemon __P((int, int)); char *devname __P((int, int)); int getloadavg __P((double [], int)); +const char *getprogname __P((void)); char *group_from_gid __P((unsigned long, int)); int heapsort __P((void *, size_t, size_t, @@ -172,6 +173,7 @@ long random __P((void)); void *reallocf __P((void *, size_t)); char *realpath __P((const char *, char resolved_path[])); +void setprogname __P((const char *)); char *setstate __P((char *)); void srandom __P((unsigned long)); void sranddev __P((void)); Index: lib/libc/gen/Makefile.inc =================================================================== RCS file: /st/src/FreeBSD/src/lib/libc/gen/Makefile.inc,v retrieving revision 1.77 diff -u -r1.77 Makefile.inc --- lib/libc/gen/Makefile.inc 2001/04/17 07:59:50 1.77 +++ lib/libc/gen/Makefile.inc 2001/05/02 02:42:07 @@ -13,7 +13,7 @@ getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \ gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \ getobjformat.c getosreldate.c getpagesize.c \ - getpass.c getpwent.c getttyent.c \ + getpass.c getprogname.c getpwent.c getttyent.c \ getusershell.c getvfsbyname.c getvfsent.c glob.c \ initgroups.c isatty.c jrand48.c lcong48.c \ lockf.c lrand48.c mrand48.c msgctl.c \ @@ -22,7 +22,7 @@ pause.c popen.c psignal.c pw_scan.c pwcache.c raise.c readdir.c rewinddir.c \ posixshm.c \ scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ - setdomainname.c sethostname.c setjmperr.c setmode.c setproctitle.c \ + setdomainname.c sethostname.c setjmperr.c setmode.c setprogname.c setproctitle.c \ shmat.c shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \ sigsetops.c sleep.c srand48.c stringlist.c strtofflags.c \ sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \ @@ -43,7 +43,7 @@ getdiskbyname.3 getdomainname.3 getfsent.3 \ getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \ getmntinfo.3 getnetgrent.3 getobjformat.3 \ - getpagesize.3 getpass.3 getpwent.3 \ + getpagesize.3 getpass.3 getprogname.3 getpwent.3 \ getttyent.3 getusershell.3 getvfsbyname.3 getvfsent.3 \ glob.3 initgroups.3 isinf.3 \ ldexp.3 lockf.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ @@ -82,6 +82,7 @@ MLINKS+=gethostname.3 sethostname.3 MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \ getnetgrent.3 setnetgrent.3 +MLINKS+=getprogname.3 setprogname.3 MLINKS+=getpwent.3 endpwent.3 getpwent.3 getpwnam.3 getpwent.3 getpwuid.3 \ getpwent.3 setpassent.3 getpwent.3 setpwent.3 getpwent.3 setpwfile.3 MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ --- /dev/null Tue May 1 19:16:20 2001 +++ lib/libc/gen/getprogname.c Tue May 1 19:41:55 2001 @@ -0,0 +1,12 @@ +/* + * $FreeBSD$ + */ + +extern const char *__progname; /* Program name, from crt0 */ + +const char * +getprogname(void) +{ + + return (__progname); +} --- /dev/null Tue May 1 19:16:20 2001 +++ lib/libc/gen/setprogname.c Tue May 1 19:42:05 2001 @@ -0,0 +1,14 @@ +/* + * $FreeBSD$ + */ + +void +setprogname(const char *progname) +{ + + /* + * In FreeBSD, the program name is set in crt0. This is just + * a stub for programs that want to be more portable. + */ + return; +} --- /dev/null Tue May 1 19:16:20 2001 +++ lib/libc/gen/getprogname.3 Tue May 1 19:41:46 2001 @@ -0,0 +1,61 @@ +.\" +.\" $FreeBSD$ +.\" +.Dd April 27, 2001 +.Dt GETPROGNAME 3 +.Os +.Sh NAME +.Nm getprogname , +.Nm setprogname +.Nd get or set the program name +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Fd #include +.Ft const char * +.Fn getprogname "void" +.Ft void +.Fn setprogname "const char *progname" +.Sh DESCRIPTION +The +.Fn getprogname +and +.Fn setprogname +functions manipulate the name of the current program. +They are used by error-reporting routines to produce +consistent output. +.Pp +The +.Fn getprogname +function returns the name of the program. +If the name has not been set yet, it will return +.Dv NULL . +.Pp +The +.Fn setprogname +function sets the name of the program. +The name can only be set once. +Since a pointer to the given string is kept as the program name, +it should not be modified for the rest of the program's lifetime. +.Pp +In +.Fx , +the name of the program is set by the start-up code that is run before +.Fn main ; +thus, +.Fn setprogname +is just a stub for use by programs which desire portability: +on other operating systems, +these functions might be implemented in a portability library, +so a call to +.Fn setprogname +allows the aforementioned library to learn the program name without +modifications to the start-up code. +.Sh SEE ALSO +.Xr err 3 , +.Xr setproctitle 3 +.Sh HISTORY +These functions first appeared in +.Nx 1.6 , +and made their way into +.Fx 5.0 . To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 21: 2:12 2001 Delivered-To: freebsd-audit@freebsd.org Received: from casimir.physics.purdue.edu (casimir.physics.purdue.edu [128.210.146.111]) by hub.freebsd.org (Postfix) with ESMTP id 377BE37B423 for ; Tue, 1 May 2001 21:02:09 -0700 (PDT) (envelope-from will@physics.purdue.edu) Received: by casimir.physics.purdue.edu (Postfix, from userid 1000) id E30E61C0E3; Tue, 1 May 2001 22:57:58 -0500 (EST) Date: Tue, 1 May 2001 22:57:58 -0500 From: Will Andrews To: Dima Dorfman Cc: audit@FreeBSD.ORG Subject: Re: {get,set}progname functions Message-ID: <20010501225758.Q5017@casimir.physics.purdue.edu> Reply-To: Will Andrews Mail-Followup-To: Will Andrews , Dima Dorfman , audit@FreeBSD.ORG References: <20010502025322.114703E28@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lceilnkbg1rbzeIV" Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <20010502025322.114703E28@bazooka.unixfreak.org>; from dima@unixfreak.org on Tue, May 01, 2001 at 07:53:21PM -0700 X-Operating-System: Linux 2.2.18 sparc64 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --lceilnkbg1rbzeIV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 01, 2001 at 07:53:21PM -0700, Dima Dorfman wrote: > Please review and, if acceptable, commit it. style(9) says: Only use the __P macro from the include file if the sour= ce file in general is (to be) compilable with a K&R Old Testament compile= r. Use of the __P macro in new code is discouraged, although modifications to existing files should be consistent with that file's conventions. Nuke __P() while you're at it. --=20 wca --lceilnkbg1rbzeIV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE674XGF47idPgWcsURArI0AKCU6KWJWQcLdANQi79iNdfvnMqk8wCbBOHV Mpen/smpuact7o2zVdfg6wk= =Ky76 -----END PGP SIGNATURE----- --lceilnkbg1rbzeIV-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 21:38:11 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id C0E0937B424 for ; Tue, 1 May 2001 21:38:09 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from hornet.unixfreak.org (hornet [63.198.170.140]) by bazooka.unixfreak.org (Postfix) with ESMTP id 3B57D3E28; Tue, 1 May 2001 21:38:09 -0700 (PDT) To: Will Andrews , audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: <20010501225758.Q5017@casimir.physics.purdue.edu>; from will@physics.purdue.edu on "Tue, 1 May 2001 22:57:58 -0500" Date: Tue, 01 May 2001 21:38:08 -0700 From: Dima Dorfman Message-Id: <20010502043809.3B57D3E28@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Will Andrews writes: > On Tue, May 01, 2001 at 07:53:21PM -0700, Dima Dorfman wrote: > > Please review and, if acceptable, commit it. > > style(9) says: > > Only use the __P macro from the include file if the source > file in general is (to be) compilable with a K&R Old Testament compiler. > Use of the __P macro in new code is discouraged, although modifications > to existing files should be consistent with that file's conventions. > > Nuke __P() while you're at it. In the header file? Removing __P() in a standalone program is most likely harmless. Removing it from header files is probably a different story. Don't get me wrong; I have no use for __P(). I just think nuking it in header files will be met with more resistance than usual. For one, it makes the entire system (well, anything that uses that header file, which is a large chunck of programs) incompatible with a ``K&R Old Testament'' compiler. Dima Dorfman dima@unixfreak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 21:44:58 2001 Delivered-To: freebsd-audit@freebsd.org Received: from casimir.physics.purdue.edu (casimir.physics.purdue.edu [128.210.146.111]) by hub.freebsd.org (Postfix) with ESMTP id 36C7037B422 for ; Tue, 1 May 2001 21:44:56 -0700 (PDT) (envelope-from will@physics.purdue.edu) Received: by casimir.physics.purdue.edu (Postfix, from userid 1000) id A38D71C0E3; Tue, 1 May 2001 23:40:45 -0500 (EST) Date: Tue, 1 May 2001 23:40:45 -0500 From: Will Andrews To: Dima Dorfman Cc: audit@FreeBSD.org Subject: Re: {get,set}progname functions Message-ID: <20010501234045.S5017@casimir.physics.purdue.edu> Reply-To: Will Andrews Mail-Followup-To: Will Andrews , Dima Dorfman , audit@FreeBSD.org References: <20010501225758.Q5017@casimir.physics.purdue.edu> <20010502043809.3B57D3E28@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jkMgqvdIizy+Ntqv" Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <20010502043809.3B57D3E28@bazooka.unixfreak.org>; from dima@unixfreak.org on Tue, May 01, 2001 at 09:38:08PM -0700 X-Operating-System: Linux 2.2.18 sparc64 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --jkMgqvdIizy+Ntqv Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 01, 2001 at 09:38:08PM -0700, Dima Dorfman wrote: > In the header file? Removing __P() in a standalone program is most __P() is just syntactic sugar. It won't make a difference as far as compiling goes. I just tried it myself. > likely harmless. Removing it from header files is probably a > different story. Don't get me wrong; I have no use for __P(). I just > think nuking it in header files will be met with more resistance than > usual. For one, it makes the entire system (well, anything that uses > that header file, which is a large chunck of programs) incompatible > with a ``K&R Old Testament'' compiler. Exactly the point. --=20 wca --jkMgqvdIizy+Ntqv Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE674/NF47idPgWcsURAiXbAJ9qq2rLozMbl7KWxbXhisR//0XpGwCgmHBT Swtoljjkg+lhl6IaCjhYl30= =J0Nj -----END PGP SIGNATURE----- --jkMgqvdIizy+Ntqv-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 22: 1: 4 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id EA2A437B423 for ; Tue, 1 May 2001 22:01:01 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 8A6E03E28; Tue, 1 May 2001 22:01:01 -0700 (PDT) To: Will Andrews , audit@FreeBSD.org Subject: Re: {get,set}progname functions In-Reply-To: <20010501234045.S5017@casimir.physics.purdue.edu>; from will@physics.purdue.edu on "Tue, 1 May 2001 23:40:45 -0500" Date: Tue, 01 May 2001 22:01:01 -0700 From: Dima Dorfman Message-Id: <20010502050101.8A6E03E28@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Will Andrews writes: > On Tue, May 01, 2001 at 09:38:08PM -0700, Dima Dorfman wrote: > > In the header file? Removing __P() in a standalone program is most > > __P() is just syntactic sugar. It won't make a difference as far as > compiling goes. I just tried it myself. I meant ``harmless'' as in ``nobody will really care''; I know it won't make a difference as far as compiling goes. > > likely harmless. Removing it from header files is probably a > > different story. Don't get me wrong; I have no use for __P(). I just > > think nuking it in header files will be met with more resistance than > > usual. For one, it makes the entire system (well, anything that uses > > that header file, which is a large chunck of programs) incompatible > > with a ``K&R Old Testament'' compiler. > > Exactly the point. Fair enough. As I said, I personally don't care. I do, however, think it shouldn't be done as part of adding {get,set}progname. Removing __P() in header files is another discussion for another day. Thanks, Dima Dorfman dima@unixfreak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 22:12: 4 2001 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 D882E37B43F for ; Tue, 1 May 2001 22:11:58 -0700 (PDT) (envelope-from bde@zeta.org.au) 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 PAA17617; Wed, 2 May 2001 15:11:53 +1000 Date: Wed, 2 May 2001 15:10:45 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Dima Dorfman Cc: audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: <20010502025322.114703E28@bazooka.unixfreak.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 1 May 2001, Dima Dorfman wrote: > Some time ago, kris sent a message to -arch asking for comments on the > inclusion of the getprogname and setprogname functions. These were > recently added to NetBSD. Responses to kris' query were generally > favorable. The message can be found here: > http://docs.FreeBSD.org/cgi/getmsg.cgi?fetch=234758+0+archive/2001/freebsd-arch/20010225.freebsd-arch > > Attached is a patch to implement these in FreeBSD. Obviously, there's > not much to implement since getprogname is a wrapper around a > `return', and setprogname is a stub. I think setprogname() should not be a stub. setproctitle() can be used to change the process's name, so why should setprogname() be weaker? Perhaps setproctitle() should affect __progname (or at least the result returned by getprogname()), and setprogname() shouldn't exist. > Please review and, if acceptable, commit it. > Index: include/stdlib.h > =================================================================== > RCS file: /st/src/FreeBSD/src/include/stdlib.h,v > retrieving revision 1.20 > diff -u -r1.20 stdlib.h > --- include/stdlib.h 2001/04/23 09:32:06 1.20 > +++ include/stdlib.h 2001/05/02 02:42:07 > @@ -157,6 +157,7 @@ > int daemon __P((int, int)); > char *devname __P((int, int)); > int getloadavg __P((double [], int)); > +const char *getprogname __P((void)); KNF strictly requires a tab after the first word. This is not very useful, but it is much easier for formatting programs to implement than putting a tab after the type, since it only requires lexical analysis. I think this prototype should be formatted as: const char * getprogname __P((void)); like all the other prototypes for all the other functions whose return type (name) is longer than 7. > Index: lib/libc/gen/Makefile.inc > =================================================================== > RCS file: /st/src/FreeBSD/src/lib/libc/gen/Makefile.inc,v > retrieving revision 1.77 > diff -u -r1.77 Makefile.inc > --- lib/libc/gen/Makefile.inc 2001/04/17 07:59:50 1.77 > +++ lib/libc/gen/Makefile.inc 2001/05/02 02:42:07 > @@ -22,7 +22,7 @@ > pause.c popen.c psignal.c pw_scan.c pwcache.c raise.c readdir.c rewinddir.c \ > posixshm.c \ > scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ > - setdomainname.c sethostname.c setjmperr.c setmode.c setproctitle.c \ > + setdomainname.c sethostname.c setjmperr.c setmode.c setprogname.c setproctitle.c \ Line too long. > --- /dev/null Tue May 1 19:16:20 2001 > +++ lib/libc/gen/getprogname.c Tue May 1 19:41:55 2001 > @@ -0,0 +1,12 @@ > +/* > + * $FreeBSD$ > + */ Never put $FreeBSD$ in the copyright comment in *.c except in the kernel. It goes in an rcsid string. > + > +extern const char *__progname; /* Program name, from crt0 */ Similar formatting problems for the variable type and linkage. Wrong comment. The location of the instantiation of __progname is machine- dependent. It is in crt0 for i386-aout but is in crt1 for i386-elf. Missing punctuation in comment. > --- /dev/null Tue May 1 19:16:20 2001 > +++ lib/libc/gen/setprogname.c Tue May 1 19:42:05 2001 > @@ -0,0 +1,14 @@ > +/* > + * $FreeBSD$ > + */ As above. > + > +void > +setprogname(const char *progname) > +{ > + > + /* > + * In FreeBSD, the program name is set in crt0. This is just > + * a stub for programs that want to be more portable. > + */ See above. > + return; > +} Return before the closing brace in a function that returns void is redundant. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 22:15:35 2001 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 0FC4E37B43C for ; Tue, 1 May 2001 22:15:33 -0700 (PDT) (envelope-from bde@zeta.org.au) 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 PAA17986; Wed, 2 May 2001 15:15:09 +1000 Date: Wed, 2 May 2001 15:14:00 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Will Andrews Cc: Dima Dorfman , audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: <20010501225758.Q5017@casimir.physics.purdue.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 1 May 2001, Will Andrews wrote: > On Tue, May 01, 2001 at 07:53:21PM -0700, Dima Dorfman wrote: > > Please review and, if acceptable, commit it. > > style(9) says: > > Only use the __P macro from the include file if the source > file in general is (to be) compilable with a K&R Old Testament compiler. > Use of the __P macro in new code is discouraged, although modifications > to existing files should be consistent with that file's conventions. is to be compilable with a K&R Old Testament compiler, and follows the convention of using __P(()) for all functions, so this rule says (twice) that additions to must use __P(()). > Nuke __P() while you're at it. Nothing to nuke. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue May 1 23: 9:57 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 9138237B422 for ; Tue, 1 May 2001 23:09:49 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 23EFC3E28; Tue, 1 May 2001 23:09:49 -0700 (PDT) To: Bruce Evans Cc: audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: ; from bde@zeta.org.au on "Wed, 2 May 2001 15:10:45 +1000 (EST)" Date: Tue, 01 May 2001 23:09:48 -0700 From: Dima Dorfman Message-Id: <20010502060949.23EFC3E28@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Bruce Evans writes: > On Tue, 1 May 2001, Dima Dorfman wrote: > > Attached is a patch to implement these in FreeBSD. Obviously, there's > > not much to implement since getprogname is a wrapper around a > > `return', and setprogname is a stub. > > I think setprogname() should not be a stub. setproctitle() can be > used to change the process's name, so why should setprogname() be > weaker? Perhaps setproctitle() should affect __progname (or at least > the result returned by getprogname()), and setprogname() shouldn't > exist. setproctitle() and setprogname() are supposed to change different things. setproctitle() sets the name of the program as it should show up in ps(1). Things like sendmail use it to show their status (e.g., "sendmail: accepting connections"). Conversely, setprogname() sets the program name as should be reported by err(3) and friends. I don't think the authors of sendmail have output like sendmail: accepting connections: some random error in mind when they write warn("some random error"); That said, you're right that setprogname() shouldn't be a stub. In the corrected path (below), it simply sets __progname. The fact that the pointer passed to it is kept for the duration of the program's life cycle is documented, so I think it's okay. > > --- include/stdlib.h 2001/04/23 09:32:06 1.20 > > +++ include/stdlib.h 2001/05/02 02:42:07 > > @@ -157,6 +157,7 @@ > > int daemon __P((int, int)); > > char *devname __P((int, int)); > > int getloadavg __P((double [], int)); > > +const char *getprogname __P((void)); > > KNF strictly requires a tab after the first word. This is not very useful, > but it is much easier for formatting programs to implement than putting > a tab after the type, since it only requires lexical analysis. > > I think this prototype should be formatted as: > > const char * > getprogname __P((void)); > > like all the other prototypes for all the other functions whose return > type (name) is longer than 7. All the rest of the prototypes aren't formatted quite like that. E.g.: unsigned short *seed48 __P((unsigned short[3])); The placement of the '*' differs. Personally, I think the way you suggest looks better, so that's the way I wrote it in the new patch. But which one's right? As mentioned before, a corrected patch is attached. Thanks, Dima Dorfman dima@unixfreak.org Index: include/stdlib.h =================================================================== RCS file: /st/src/FreeBSD/src/include/stdlib.h,v retrieving revision 1.20 diff -u -r1.20 stdlib.h --- include/stdlib.h 2001/04/23 09:32:06 1.20 +++ include/stdlib.h 2001/05/02 05:58:55 @@ -157,6 +157,8 @@ int daemon __P((int, int)); char *devname __P((int, int)); int getloadavg __P((double [], int)); +const char * + getprogname __P((void)); char *group_from_gid __P((unsigned long, int)); int heapsort __P((void *, size_t, size_t, @@ -172,6 +174,7 @@ long random __P((void)); void *reallocf __P((void *, size_t)); char *realpath __P((const char *, char resolved_path[])); +void setprogname __P((const char *)); char *setstate __P((char *)); void srandom __P((unsigned long)); void sranddev __P((void)); Index: lib/libc/gen/Makefile.inc =================================================================== RCS file: /st/src/FreeBSD/src/lib/libc/gen/Makefile.inc,v retrieving revision 1.77 diff -u -r1.77 Makefile.inc --- lib/libc/gen/Makefile.inc 2001/04/17 07:59:50 1.77 +++ lib/libc/gen/Makefile.inc 2001/05/02 05:58:55 @@ -13,7 +13,7 @@ getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \ gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \ getobjformat.c getosreldate.c getpagesize.c \ - getpass.c getpwent.c getttyent.c \ + getpass.c getprogname.c getpwent.c getttyent.c \ getusershell.c getvfsbyname.c getvfsent.c glob.c \ initgroups.c isatty.c jrand48.c lcong48.c \ lockf.c lrand48.c mrand48.c msgctl.c \ @@ -22,7 +22,8 @@ pause.c popen.c psignal.c pw_scan.c pwcache.c raise.c readdir.c rewinddir.c \ posixshm.c \ scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ - setdomainname.c sethostname.c setjmperr.c setmode.c setproctitle.c \ + setdomainname.c sethostname.c setjmperr.c setmode.c setprogname.c \ + setproctitle.c \ shmat.c shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \ sigsetops.c sleep.c srand48.c stringlist.c strtofflags.c \ sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \ @@ -43,7 +44,7 @@ getdiskbyname.3 getdomainname.3 getfsent.3 \ getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \ getmntinfo.3 getnetgrent.3 getobjformat.3 \ - getpagesize.3 getpass.3 getpwent.3 \ + getpagesize.3 getpass.3 getprogname.3 getpwent.3 \ getttyent.3 getusershell.3 getvfsbyname.3 getvfsent.3 \ glob.3 initgroups.3 isinf.3 \ ldexp.3 lockf.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ @@ -82,6 +83,7 @@ MLINKS+=gethostname.3 sethostname.3 MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \ getnetgrent.3 setnetgrent.3 +MLINKS+=getprogname.3 setprogname.3 MLINKS+=getpwent.3 endpwent.3 getpwent.3 getpwnam.3 getpwent.3 getpwuid.3 \ getpwent.3 setpassent.3 getpwent.3 setpwent.3 getpwent.3 setpwfile.3 MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ --- /dev/null Tue May 1 20:04:30 2001 +++ lib/libc/gen/getprogname.c Tue May 1 22:58:10 2001 @@ -0,0 +1,14 @@ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + +extern const char * + __progname; + +const char * +getprogname(void) +{ + + return (__progname); +} --- /dev/null Tue May 1 20:04:30 2001 +++ lib/libc/gen/setprogname.c Tue May 1 22:58:16 2001 @@ -0,0 +1,14 @@ +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + +extern const char * + __progname; + +void +setprogname(const char *progname) +{ + + __progname = progname; +} --- /dev/null Tue May 1 20:04:30 2001 +++ lib/libc/gen/getprogname.3 Tue May 1 22:41:23 2001 @@ -0,0 +1,62 @@ +.\" +.\" $FreeBSD$ +.\" +.Dd May 1, 2001 +.Dt GETPROGNAME 3 +.Os +.Sh NAME +.Nm getprogname , +.Nm setprogname +.Nd get or set the program name +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Fd #include +.Ft const char * +.Fn getprogname "void" +.Ft void +.Fn setprogname "const char *progname" +.Sh DESCRIPTION +The +.Fn getprogname +and +.Fn setprogname +functions manipulate the name of the current program. +They are used by error-reporting routines to produce +consistent output. +.Pp +The +.Fn getprogname +function returns the name of the program. +If the name has not been set yet, it will return +.Dv NULL . +.Pp +The +.Fn setprogname +function sets the name of the program. +Since a pointer to the given string is kept as the program name, +it should not be modified for the rest of the program's lifetime. +.Pp +In +.Fx , +the name of the program is set by the start-up code that is run before +.Fn main ; +thus, +running +.Fn setprogname +is not necessary. +Programs that desire maximum portability should still call it; +on another operating system, +these functions may be implemented in a portability library. +Calling +.Fn setprogname +allows the aforementioned library to learn the program name without +modifications to the start-up code. +.Sh SEE ALSO +.Xr err 3 , +.Xr setproctitle 3 +.Sh HISTORY +These functions first appeared in +.Nx 1.6 , +and made their way into +.Fx 5.0 . To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 14:37:32 2001 Delivered-To: freebsd-audit@freebsd.org Received: from flood.ping.uio.no (flood.ping.uio.no [129.240.78.31]) by hub.freebsd.org (Postfix) with ESMTP id 5949137B43C for ; Wed, 2 May 2001 14:37:27 -0700 (PDT) (envelope-from des@ofug.org) Received: (from des@localhost) by flood.ping.uio.no (8.9.3/8.9.3) id XAA25955; Wed, 2 May 2001 23:37:19 +0200 (CEST) (envelope-from des@ofug.org) X-URL: http://www.ofug.org/~des/ X-Disclaimer: The views expressed in this message do not necessarily coincide with those of any organisation or company with which I am or have been affiliated. To: Dima Dorfman Cc: audit@FreeBSD.ORG Subject: Re: sha1 support in md5(1) References: <20010429213715.06D613E0B@bazooka.unixfreak.org> From: Dag-Erling Smorgrav Date: 02 May 2001 23:37:19 +0200 In-Reply-To: <20010429213715.06D613E0B@bazooka.unixfreak.org> Message-ID: Lines: 29 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Dima Dorfman writes: > Attached is a patch that adds SHA1 support to the md5(1) program. > Please review. This patch makes sha1(1) a link to md5(1); the same > program was chosen because much of the support code would be > identical. This is also the way OpenBSD implemented it, and it makes > sense, as well as making it easier to add other digest algorithms in > the future (OpenBSD has rmd160, for example). What do we need this for? des@des ~% md5 /boot/kernel/kernel MD5 (/boot/kernel/kernel) = 7092b5c593a287da5d6222ebb9db5d92 des@des ~% which openssl /usr/bin/openssl des@des ~% ln -s $(which openssl) md5 des@des ~% ./md5 /boot/kernel/kernel MD5(/boot/kernel/kernel)= 7092b5c593a287da5d6222ebb9db5d92 des@des ~% ln -s $(which openssl) sha1 des@des ~% ./sha1 /boot/kernel/kernel SHA1(/boot/kernel/kernel)= b584001c125c364c5958efb647d5b56915aa09c9 des@des ~% ln -s $(which openssl) rmd160 des@des ~% ./rmd160 /boot/kernel/kernel RIPEMD160(/boot/kernel/kernel)= eab7dceb96a2492faee5cd3984affc05fe2afc63 The only possible issue is the lack of a space before the equal sign. DES -- Dag-Erling Smorgrav - des@ofug.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 16: 9:20 2001 Delivered-To: freebsd-audit@freebsd.org Received: from casimir.physics.purdue.edu (casimir.physics.purdue.edu [128.210.146.111]) by hub.freebsd.org (Postfix) with ESMTP id 9200437B422 for ; Wed, 2 May 2001 16:09:17 -0700 (PDT) (envelope-from will@physics.purdue.edu) Received: by casimir.physics.purdue.edu (Postfix, from userid 1000) id 1E2AE1C0E3; Wed, 2 May 2001 18:04:45 -0500 (EST) Date: Wed, 2 May 2001 18:04:44 -0500 From: Will Andrews To: Dag-Erling Smorgrav Cc: Dima Dorfman , audit@FreeBSD.ORG Subject: Re: sha1 support in md5(1) Message-ID: <20010502180444.D5017@casimir.physics.purdue.edu> Reply-To: Will Andrews Mail-Followup-To: Will Andrews , Dag-Erling Smorgrav , Dima Dorfman , audit@FreeBSD.ORG References: <20010429213715.06D613E0B@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tpzKoWRsyBhPHUC8" Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: ; from des@ofug.org on Wed, May 02, 2001 at 11:37:19PM +0200 X-Operating-System: Linux 2.2.18 sparc64 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --tpzKoWRsyBhPHUC8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 02, 2001 at 11:37:19PM +0200, Dag-Erling Smorgrav wrote: [..] > des@des ~% ln -s $(which openssl) rmd160 > des@des ~% ./rmd160 /boot/kernel/kernel > RIPEMD160(/boot/kernel/kernel)=3D eab7dceb96a2492faee5cd3984affc05fe2afc63 Wow, that's cool stuff. > The only possible issue is the lack of a space before the equal sign. And the crypto algorithm specified, but really these are non-issues. If someone is looking for a particular part of this, there are plenty of ways to write an awk, sed, or python/ruby/perl script to extract the data desired. Anyway, in light of this, I'll have to lean with DES. If anything, you could just add a couple LINKS to openssl. In fact, it seems the md5(1) program could be obsoleted entirely, although there is a slight issue because Mk/bsd.port.mk would almost certainly be broken, and there are probably other scripts of sorts that make assumptions based on the spaces. Hence, I think it's a good idea, but it needs to be carefully considered and carried out (of course, if others agree :-). --=20 wca --tpzKoWRsyBhPHUC8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE68JKMF47idPgWcsURAlOpAJ4yMN5ZwsI1f7sVBJVEQTd0c/sf+wCgjzbc JPwFdhyTMhEFBzlOFtmoJco= =8aLF -----END PGP SIGNATURE----- --tpzKoWRsyBhPHUC8-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 16:12:25 2001 Delivered-To: freebsd-audit@freebsd.org Received: from obsecurity.dyndns.org (adsl-63-207-60-26.dsl.lsan03.pacbell.net [63.207.60.26]) by hub.freebsd.org (Postfix) with ESMTP id A0C0437B423 for ; Wed, 2 May 2001 16:12:22 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 1CDA867B84; Wed, 2 May 2001 16:12:22 -0700 (PDT) Date: Wed, 2 May 2001 16:12:21 -0700 From: Kris Kennaway To: Will Andrews Cc: Dag-Erling Smorgrav , Dima Dorfman , audit@FreeBSD.ORG Subject: Re: sha1 support in md5(1) Message-ID: <20010502161221.A47371@xor.obsecurity.org> References: <20010429213715.06D613E0B@bazooka.unixfreak.org> <20010502180444.D5017@casimir.physics.purdue.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="BXVAT5kNtrzKuDFl" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010502180444.D5017@casimir.physics.purdue.edu>; from will@physics.purdue.edu on Wed, May 02, 2001 at 06:04:44PM -0500 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --BXVAT5kNtrzKuDFl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 02, 2001 at 06:04:44PM -0500, Will Andrews wrote: > On Wed, May 02, 2001 at 11:37:19PM +0200, Dag-Erling Smorgrav wrote: > [..] > > des@des ~% ln -s $(which openssl) rmd160 > > des@des ~% ./rmd160 /boot/kernel/kernel > > RIPEMD160(/boot/kernel/kernel)=3D eab7dceb96a2492faee5cd3984affc05fe2af= c63 >=20 > Wow, that's cool stuff. Check into 'openssl help' sometime..most of those commands work the same way. They can also (I believe) be built as standalone single-task binaries. Kris --BXVAT5kNtrzKuDFl Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.5 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE68JRVWry0BWjoQKURAuXWAJ9OAiOWvM5jijMwYKRkEhF7xDLEywCgqwp0 0vd5anQ1vQvmXVAiSGXVngE= =MSPP -----END PGP SIGNATURE----- --BXVAT5kNtrzKuDFl-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 18:11:45 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 4AA2B37B423 for ; Wed, 2 May 2001 18:11:43 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 1C8E73E28; Wed, 2 May 2001 18:11:38 -0700 (PDT) To: Will Andrews , Dag-Erling Smorgrav , audit@FreeBSD.ORG Subject: Re: sha1 support in md5(1) In-Reply-To: <20010502180444.D5017@casimir.physics.purdue.edu>; from will@physics.purdue.edu on "Wed, 2 May 2001 18:04:44 -0500" Date: Wed, 02 May 2001 18:11:38 -0700 From: Dima Dorfman Message-Id: <20010503011138.1C8E73E28@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Will Andrews writes: > On Wed, May 02, 2001 at 11:37:19PM +0200, Dag-Erling Smorgrav wrote: > [..] > > des@des ~% ln -s $(which openssl) rmd160 > > des@des ~% ./rmd160 /boot/kernel/kernel > > RIPEMD160(/boot/kernel/kernel)= eab7dceb96a2492faee5cd3984affc05fe2afc63 > > Anyway, in light of this, I'll have to lean with DES. If anything, you Me too. When I wrote the patch I had functionality in mind, not the reinvention of the wheel. Since we apparently already have this functionality, that's fine with me. > could just add a couple LINKS to openssl. In fact, it seems the md5(1) Not really necessary. It's not that hard to do `openssl md5` or `openssl sha1`. No need to pollute [/usr]/[s]bin with gratuitous links. Thanks, Dima Dorfman dima@unixfreak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 18:13:51 2001 Delivered-To: freebsd-audit@freebsd.org Received: from casimir.physics.purdue.edu (casimir.physics.purdue.edu [128.210.146.111]) by hub.freebsd.org (Postfix) with ESMTP id BBBC337B423 for ; Wed, 2 May 2001 18:13:48 -0700 (PDT) (envelope-from will@physics.purdue.edu) Received: by casimir.physics.purdue.edu (Postfix, from userid 1000) id 05FCD1C0E3; Wed, 2 May 2001 20:09:30 -0500 (EST) Date: Wed, 2 May 2001 20:09:30 -0500 From: Will Andrews To: Dima Dorfman Cc: Will Andrews , Dag-Erling Smorgrav , audit@FreeBSD.ORG Subject: Re: sha1 support in md5(1) Message-ID: <20010502200930.F5017@casimir.physics.purdue.edu> Reply-To: Will Andrews Mail-Followup-To: Will Andrews , Dima Dorfman , Dag-Erling Smorgrav , audit@FreeBSD.ORG References: <20010502180444.D5017@casimir.physics.purdue.edu> <20010503011138.1C8E73E28@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="erduzcCmvXha3phN" Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <20010503011138.1C8E73E28@bazooka.unixfreak.org>; from dima@unixfreak.org on Wed, May 02, 2001 at 06:11:38PM -0700 X-Operating-System: Linux 2.2.18 sparc64 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --erduzcCmvXha3phN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 02, 2001 at 06:11:38PM -0700, Dima Dorfman wrote: > Not really necessary. It's not that hard to do `openssl md5` or > `openssl sha1`. No need to pollute [/usr]/[s]bin with gratuitous > links. OK, but what about potentially getting rid of md5(1)? --=20 wca --erduzcCmvXha3phN Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE68K/KF47idPgWcsURAo+zAJ9iyDhqBq8l1BpTrTy+uTqlS+refgCgjKsj 3fUxPalgZkDU3BzQeimP1eE= =CvOD -----END PGP SIGNATURE----- --erduzcCmvXha3phN-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 18:20:25 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 00CE137B422 for ; Wed, 2 May 2001 18:20:24 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id A8BA03E2B; Wed, 2 May 2001 18:20:23 -0700 (PDT) To: Will Andrews , Dag-Erling Smorgrav , audit@FreeBSD.ORG Subject: Re: sha1 support in md5(1) In-Reply-To: <20010502200930.F5017@casimir.physics.purdue.edu>; from will@physics.purdue.edu on "Wed, 2 May 2001 20:09:30 -0500" Date: Wed, 02 May 2001 18:20:23 -0700 From: Dima Dorfman Message-Id: <20010503012023.A8BA03E2B@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Will Andrews writes: > On Wed, May 02, 2001 at 06:11:38PM -0700, Dima Dorfman wrote: > > Not really necessary. It's not that hard to do `openssl md5` or > > `openssl sha1`. No need to pollute [/usr]/[s]bin with gratuitous > > links. > > OK, but what about potentially getting rid of md5(1)? If we can get the OpenSSL folks to stick those spaces in there for us that'd be the best. Then, we just add links for 'md5', 'sha1', etc. to openssl in /usr/bin (I've always thought /sbin was a bad place for md5(1), anyway). Failing that, we find a way to run the output through something like: sed -E 's/^(.+)\((.+)\)= (.+)$/\1 (\2) = \3/g' and make links to that. Dima Dorfman dima@unixfreak.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed May 2 18:33:11 2001 Delivered-To: freebsd-audit@freebsd.org Received: from casimir.physics.purdue.edu (casimir.physics.purdue.edu [128.210.146.111]) by hub.freebsd.org (Postfix) with ESMTP id C5E6737B424; Wed, 2 May 2001 18:33:08 -0700 (PDT) (envelope-from will@physics.purdue.edu) Received: by casimir.physics.purdue.edu (Postfix, from userid 1000) id 2784B1C0E3; Wed, 2 May 2001 20:28:51 -0500 (EST) Date: Wed, 2 May 2001 20:28:51 -0500 From: Will Andrews To: Dima Dorfman Cc: Poul-Henning Kamp , audit@FreeBSD.org Subject: Re: sha1 support in md5(1) Message-ID: <20010502202850.G5017@casimir.physics.purdue.edu> Reply-To: Will Andrews Mail-Followup-To: Will Andrews , Dima Dorfman , Poul-Henning Kamp , audit@FreeBSD.org References: <20010502200930.F5017@casimir.physics.purdue.edu> <20010503012023.A8BA03E2B@bazooka.unixfreak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Obg6o3IqMqKlkF6F" Content-Disposition: inline User-Agent: Mutt/1.3.15i In-Reply-To: <20010503012023.A8BA03E2B@bazooka.unixfreak.org>; from dima@unixfreak.org on Wed, May 02, 2001 at 06:20:23PM -0700 X-Operating-System: Linux 2.2.18 sparc64 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Obg6o3IqMqKlkF6F Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 02, 2001 at 06:20:23PM -0700, Dima Dorfman wrote: > If we can get the OpenSSL folks to stick those spaces in there for us > that'd be the best. Then, we just add links for 'md5', 'sha1', > etc. to openssl in /usr/bin (I've always thought /sbin was a bad place > for md5(1), anyway). Failing that, we find a way to run the output > through something like: >=20 > sed -E 's/^(.+)\((.+)\)=3D (.+)$/\1 (\2) =3D \3/g' >=20 > and make links to that. I agree that /sbin seems like a bad place for a tool like md5(1). Does anyone have any idea why it is? I'm kinda iffy on the idea of making a hack like you suggest. IMO, perhaps for the sake of standardization we should simply drop md5(1) and provide links for OpenSSL. I think that the scripts that would break would only gain from the standardization by not needing any "special" code for FreeBSD anymore (of course this is mainly for people who do crossplatform scripts, though I guess OpenSSL is a bit of a new thing). Ports can easily make the transition since all supported versions of FreeBSD already have OpenSSL. Perhaps Poul-Henning would like to comment on this. --=20 wca --Obg6o3IqMqKlkF6F Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE68LRSF47idPgWcsURAoxxAJ4/jvW9wC5SgSJIrydQqx0nU9JfFQCfQbYB N7tBCehaYX9Ljx4RpNz7R34= =OMVH -----END PGP SIGNATURE----- --Obg6o3IqMqKlkF6F-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 3 0:30: 7 2001 Delivered-To: freebsd-audit@freebsd.org Received: from heorot.stanford.edu (heorot.Stanford.EDU [128.12.44.92]) by hub.freebsd.org (Postfix) with ESMTP id D067C37B422 for ; Thu, 3 May 2001 00:30:00 -0700 (PDT) (envelope-from grendel@heorot.stanford.edu) Received: from localhost (tedu@localhost) by heorot.stanford.edu (8.11.3/8.11.3) with ESMTP id f437WSD00877; Thu, 3 May 2001 00:32:28 -0700 (PDT) X-Authentication-Warning: heorot.stanford.edu: tedu owned process doing -bs Date: Thu, 3 May 2001 00:32:28 -0700 (PDT) From: Ted U X-X-Sender: To: , , , Subject: patch for memory leak Message-ID: Organization: Mead Halls Inc. X-Yourmom: Mighty fine MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG following is a patch that fixes 3 occurences of realloc in BSD kernels that could result in a memory leak. if realloc returns null, then the previously held memory is not freed. the affected areas are ipfilter and usb audio. ted -- Ted Unangst -- grendel@heorot.stanford.edu -- http://heorot.stanford.edu/ Keep your vogue code that all have. / Tomorrow's world we've all seen. Keep your modern ways and keep your bugs. / The metal man is here to stay. - Theatre of Tragedy, "Machine" PATCH: Fixes memory leaks in BSD. This patch applies clean against OpenBSD -current. NetBSD and FreeBSD should also be patchable like this, though the offsets and file locations may differ. --- sys/netient/ip_fil.c.orig Sun Apr 29 20:07:08 2001 +++ sys/netinet/ip_fil.c Sun Apr 29 20:30:34 2001 @@ -1638,8 +1638,9 @@ char *name; int v; { struct ifnet *ifp, **ifa; + struct ifnet **old_ifneta; # if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199606)) || \ (defined(OpenBSD) && (OpenBSD >= 199603)) for (ifa = ifneta; ifa && (ifp = *ifa); ifa++) { if (!strcmp(name, ifp->if_xname)) @@ -1667,11 +1668,13 @@ } nifs = 1; } else { nifs++; + old_ifneta = ifneta; ifneta = (struct ifnet **)realloc(ifneta, (nifs + 1) * sizeof(*ifa)); if (!ifneta) { + free(old_ifneta); nifs = 0; return NULL; } ifneta[nifs] = NULL; --- sys/dev/usb/uaudio.c.orig Sun Apr 29 20:07:18 2001 +++ sys/dev/usb/uaudio.c Sun Apr 29 20:22:25 2001 @@ -534,16 +534,21 @@ void uaudio_mixer_add_ctl(struct uaudio_softc *sc, struct mixerctl *mc) { int res; + struct mixerctl *old_ctls = NULL; if (sc->sc_nctls == 0) sc->sc_ctls = malloc(sizeof *mc, M_USBDEV, M_NOWAIT); - else + else { + old_ctls = sc->sc_ctls; sc->sc_ctls = realloc(sc->sc_ctls, (sc->sc_nctls+1) * sizeof *mc, M_USBDEV, M_NOWAIT); + } if (sc->sc_ctls == NULL) { + if (old_ctls) + free(old_ctls, M_USBDEV); printf("uaudio_mixer_add_ctl: no memory\n"); return; } @@ -1015,15 +1020,21 @@ void uaudio_add_alt(struct uaudio_softc *sc, struct as_info *ai) { + struct as_info *old_alts = NULL; + if (sc->sc_nalts == 0) sc->sc_alts = malloc(sizeof *ai, M_USBDEV, M_NOWAIT); - else + else { + old_alts = sc->sc_alts; sc->sc_alts = realloc(sc->sc_alts, (sc->sc_nalts+1) * sizeof *ai, M_USBDEV, M_NOWAIT); + } if (sc->sc_alts == NULL) { + if(old_alts) + free(old_alts, M_USBDEV); printf("uaudio_add_alt: no memory\n"); return; } DPRINTFN(2,("uaudio_add_alt: adding alt=%d, enc=%d\n", To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu May 3 23:52:35 2001 Delivered-To: freebsd-audit@freebsd.org Received: from ringworld.nanolink.com (ringworld.nanolink.com [195.24.48.13]) by hub.freebsd.org (Postfix) with SMTP id 0136837B43C for ; Thu, 3 May 2001 23:52:32 -0700 (PDT) (envelope-from roam@orbitel.bg) Received: (qmail 16563 invoked by uid 1000); 4 May 2001 06:50:41 -0000 Date: Fri, 4 May 2001 09:50:41 +0300 From: Peter Pentchev To: audit@FreeBSD.org Subject: Re: du(1) -I option to ignore files/dirs Message-ID: <20010504095041.C13382@ringworld.oblivion.bg> Mail-Followup-To: audit@FreeBSD.org References: <20010428194259.J415@ringworld.oblivion.bg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from mheffner@vt.edu on Mon, Apr 30, 2001 at 05:46:49PM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ..and a resounding silence on the list.. Does this mean that I can go ahead and commit the patch, with an Approved by: mikeh & silence on -audit? :) Guess not :) G'luck, Peter -- I am the meaning of this sentence. On Mon, Apr 30, 2001 at 05:46:49PM -0400, Mike Heffner wrote: > > On 28-Apr-2001 Peter Pentchev wrote: > | Hi, > | > | And just when -arch thought they'd gotten rid of me and my du(1) patches.. ;) > | > | Well, since no one had any real objections to adding the -I flag, other than > | 'no one else is doing that' (so why can't we?), and as several people agreed > | that there was no easy (or moderately hard) way to do this with other utils, > | here's an updated patch that properly uses slist's instead of the constant- > | sized arrays in the previous version. > > Looks good > > | > | + > | +int > | +ignorep(ent) > | + FTSENT *ent; > | +{ > | + struct ignentry *ign; > | + > | + if (SLIST_EMPTY(&ignores)) > | + return 0; > > This isn't needed though because it's caught in the _FOREACH. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri May 4 4:45:22 2001 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 D882E37B43C for ; Fri, 4 May 2001 04:45:17 -0700 (PDT) (envelope-from bde@zeta.org.au) 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 VAA04691; Fri, 4 May 2001 21:45:09 +1000 Date: Fri, 4 May 2001 21:42:37 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Dima Dorfman Cc: audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: <20010502060949.23EFC3E28@bazooka.unixfreak.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, 1 May 2001, Dima Dorfman wrote: > Bruce Evans writes: > > I think setprogname() should not be a stub. setproctitle() can be > > used to change the process's name, so why should setprogname() be > > weaker? Perhaps setproctitle() should affect __progname (or at least > > the result returned by getprogname()), and setprogname() shouldn't > > exist. > > setproctitle() and setprogname() are supposed to change different > things. setproctitle() sets the name of the program as it should show > up in ps(1). Things like sendmail use it to show their status (e.g., > "sendmail: accepting connections"). Conversely, setprogname() sets > the program name as should be reported by err(3) and friends. I don't > think the authors of sendmail have output like > > sendmail: accepting connections: some random error > > in mind when they write > > warn("some random error"); OK. They are logically separate, so it is simpler for them to have no interactions. > That said, you're right that setprogname() shouldn't be a stub. In > the corrected path (below), it simply sets __progname. The fact that > the pointer passed to it is kept for the duration of the program's > life cycle is documented, so I think it's okay. OK. > > > +const char *getprogname __P((void)); > > I think this prototype should be formatted as: > > > > const char * > > getprogname __P((void)); > > > > like all the other prototypes for all the other functions whose return > > type (name) is longer than 7. > > All the rest of the prototypes aren't formatted quite like that. E.g.: > > unsigned short > *seed48 __P((unsigned short[3])); > > The placement of the '*' differs. Personally, I think the way you > suggest looks better, so that's the way I wrote it in the new patch. > But which one's right? The others also have a 9-char indent if they don't have a '*'. The '*' looks better when it's in the same column (before the function name) for all cases, although it logically doesn't really belong there. > As mentioned before, a corrected patch is attached. OK... > --- /dev/null Tue May 1 20:04:30 2001 > +++ lib/libc/gen/getprogname.c Tue May 1 22:58:10 2001 > @@ -0,0 +1,14 @@ > +#ifndef lint > +static const char rcsid[] = > + "$FreeBSD$"; > +#endif /* not lint */ Use LIBC_RCS as well as "lint" here (see libc/gen/err.c; other files mostly use LIBC_SCCS but I think we plan to change them, at least if the id is not an sccsid). > + > +extern const char * > + __progname; The line break for indenting the variable name is a bit much. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat May 5 0:33:22 2001 Delivered-To: freebsd-audit@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 5115537B422 for ; Sat, 5 May 2001 00:33:08 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: from spike.unixfreak.org (spike [63.198.170.139]) by bazooka.unixfreak.org (Postfix) with ESMTP id 81D613E0B; Sat, 5 May 2001 00:33:06 -0700 (PDT) To: Bruce Evans Cc: audit@FreeBSD.ORG Subject: Re: {get,set}progname functions In-Reply-To: ; from bde@zeta.org.au on "Fri, 4 May 2001 21:42:37 +1000 (EST)" Date: Sat, 05 May 2001 00:33:05 -0700 From: Dima Dorfman Message-Id: <20010505073306.81D613E0B@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Bruce Evans writes: > On Tue, 1 May 2001, Dima Dorfman wrote: > > --- /dev/null Tue May 1 20:04:30 2001 > > +++ lib/libc/gen/getprogname.c Tue May 1 22:58:10 2001 > > @@ -0,0 +1,14 @@ > > +#ifndef lint > > +static const char rcsid[] = > > + "$FreeBSD$"; > > +#endif /* not lint */ > > Use LIBC_RCS as well as "lint" here (see libc/gen/err.c; other files > mostly use LIBC_SCCS but I think we plan to change them, at least if > the id is not an sccsid). Fixed in patch below. > > + > > +extern const char * > > + __progname; > > The line break for indenting the variable name is a bit much. This too. Thanks, Dima Dorfman dima@unixfreak.org Index: include/stdlib.h =================================================================== RCS file: /st/src/FreeBSD/src/include/stdlib.h,v retrieving revision 1.20 diff -u -r1.20 stdlib.h --- include/stdlib.h 2001/04/23 09:32:06 1.20 +++ include/stdlib.h 2001/05/05 07:18:38 @@ -157,6 +157,8 @@ int daemon __P((int, int)); char *devname __P((int, int)); int getloadavg __P((double [], int)); +const char * + getprogname __P((void)); char *group_from_gid __P((unsigned long, int)); int heapsort __P((void *, size_t, size_t, @@ -172,6 +174,7 @@ long random __P((void)); void *reallocf __P((void *, size_t)); char *realpath __P((const char *, char resolved_path[])); +void setprogname __P((const char *)); char *setstate __P((char *)); void srandom __P((unsigned long)); void sranddev __P((void)); Index: lib/libc/gen/Makefile.inc =================================================================== RCS file: /st/src/FreeBSD/src/lib/libc/gen/Makefile.inc,v retrieving revision 1.77 diff -u -r1.77 Makefile.inc --- lib/libc/gen/Makefile.inc 2001/04/17 07:59:50 1.77 +++ lib/libc/gen/Makefile.inc 2001/05/05 07:18:38 @@ -13,7 +13,7 @@ getcap.c getcwd.c getdomainname.c getgrent.c getgrouplist.c \ gethostname.c getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \ getobjformat.c getosreldate.c getpagesize.c \ - getpass.c getpwent.c getttyent.c \ + getpass.c getprogname.c getpwent.c getttyent.c \ getusershell.c getvfsbyname.c getvfsent.c glob.c \ initgroups.c isatty.c jrand48.c lcong48.c \ lockf.c lrand48.c mrand48.c msgctl.c \ @@ -22,7 +22,8 @@ pause.c popen.c psignal.c pw_scan.c pwcache.c raise.c readdir.c rewinddir.c \ posixshm.c \ scandir.c seed48.c seekdir.c semconfig.c semctl.c semget.c semop.c \ - setdomainname.c sethostname.c setjmperr.c setmode.c setproctitle.c \ + setdomainname.c sethostname.c setjmperr.c setmode.c setprogname.c \ + setproctitle.c \ shmat.c shmctl.c shmdt.c shmget.c siginterrupt.c siglist.c signal.c \ sigsetops.c sleep.c srand48.c stringlist.c strtofflags.c \ sysconf.c sysctl.c sysctlbyname.c sysctlnametomib.c \ @@ -43,7 +44,7 @@ getdiskbyname.3 getdomainname.3 getfsent.3 \ getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \ getmntinfo.3 getnetgrent.3 getobjformat.3 \ - getpagesize.3 getpass.3 getpwent.3 \ + getpagesize.3 getpass.3 getprogname.3 getpwent.3 \ getttyent.3 getusershell.3 getvfsbyname.3 getvfsent.3 \ glob.3 initgroups.3 isinf.3 \ ldexp.3 lockf.3 modf.3 msgctl.3 msgget.3 msgrcv.3 msgsnd.3 \ @@ -82,6 +83,7 @@ MLINKS+=gethostname.3 sethostname.3 MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \ getnetgrent.3 setnetgrent.3 +MLINKS+=getprogname.3 setprogname.3 MLINKS+=getpwent.3 endpwent.3 getpwent.3 getpwnam.3 getpwent.3 getpwuid.3 \ getpwent.3 setpassent.3 getpwent.3 setpwent.3 getpwent.3 setpwfile.3 MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ --- /dev/null Sat May 5 00:17:13 2001 +++ lib/libc/gen/getprogname.c Fri May 4 20:24:43 2001 @@ -0,0 +1,13 @@ +#if defined(LIBC_RCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD$"; +#endif /* LIBC_RCS and not lint */ + +extern const char *__progname; + +const char * +getprogname(void) +{ + + return (__progname); +} --- /dev/null Sat May 5 00:17:13 2001 +++ lib/libc/gen/setprogname.c Fri May 4 20:23:51 2001 @@ -0,0 +1,13 @@ +#if defined(LIBC_RCS) && !defined(lint) +static const char rcsid[] = + "$FreeBSD$"; +#endif /* LIBC_RCS and not lint */ + +extern const char *__progname; + +void +setprogname(const char *progname) +{ + + __progname = progname; +} --- /dev/null Sat May 5 00:17:13 2001 +++ lib/libc/gen/getprogname.3 Tue May 1 22:41:23 2001 @@ -0,0 +1,62 @@ +.\" +.\" $FreeBSD$ +.\" +.Dd May 1, 2001 +.Dt GETPROGNAME 3 +.Os +.Sh NAME +.Nm getprogname , +.Nm setprogname +.Nd get or set the program name +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.Fd #include +.Ft const char * +.Fn getprogname "void" +.Ft void +.Fn setprogname "const char *progname" +.Sh DESCRIPTION +The +.Fn getprogname +and +.Fn setprogname +functions manipulate the name of the current program. +They are used by error-reporting routines to produce +consistent output. +.Pp +The +.Fn getprogname +function returns the name of the program. +If the name has not been set yet, it will return +.Dv NULL . +.Pp +The +.Fn setprogname +function sets the name of the program. +Since a pointer to the given string is kept as the program name, +it should not be modified for the rest of the program's lifetime. +.Pp +In +.Fx , +the name of the program is set by the start-up code that is run before +.Fn main ; +thus, +running +.Fn setprogname +is not necessary. +Programs that desire maximum portability should still call it; +on another operating system, +these functions may be implemented in a portability library. +Calling +.Fn setprogname +allows the aforementioned library to learn the program name without +modifications to the start-up code. +.Sh SEE ALSO +.Xr err 3 , +.Xr setproctitle 3 +.Sh HISTORY +These functions first appeared in +.Nx 1.6 , +and made their way into +.Fx 5.0 . To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message