From owner-freebsd-audit Sun Apr 22 4:32:24 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 D017237B424 for ; Sun, 22 Apr 2001 04:32:20 -0700 (PDT) (envelope-from roam@orbitel.bg) Received: (qmail 90697 invoked by uid 1000); 22 Apr 2001 11:30:43 -0000 Date: Sun, 22 Apr 2001 14:30:43 +0300 From: Peter Pentchev To: Sue Blake Cc: Joachim Strombergson , FreeBSD-Audit , Brooks Davis Subject: Re: New du functionality by newbie - audit and comments? Message-ID: <20010422143043.C90395@ringworld.oblivion.bg> Mail-Followup-To: Sue Blake , Joachim Strombergson , FreeBSD-Audit , Brooks Davis References: <3AE065DD.D8FEF0B@ludd.luth.se> <20010421160440.C47557@ringworld.oblivion.bg> <3AE20464.7DA961BE@ludd.luth.se> <20010422100209.D4964@welearn.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010422100209.D4964@welearn.com.au>; from sue@welearn.com.au on Sun, Apr 22, 2001 at 10:02:11AM +1000 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Apr 22, 2001 at 10:02:11AM +1000, Sue Blake wrote: > On Sun, Apr 22, 2001 at 12:06:28AM +0200, Joachim Strombergson wrote: > > Aloha! > > > > Ahem... oops! > > > > It looks like I made a pretty nice fool out of myslf with my posting. > > The "newbie" label was obviously correct though. > > But you (all) achieved more than you realise. > > Nobody knew I was here. I saw you make a big mistake, I saw you > corrected politely, I saw you say OK and look at other ways to help. > Next time I'm afraid to offer something, I will remember your story > and I will be encouraged to go ahead and try my best. > > There could be hundreds of others, silent like me, who are encouraged > by your story. Some of them will become the people who take FreeBSD > into tomorrow. Thank you for helping others to feel comfortable. I wouldn't exactly call this a 'big mistake' - it seemed like a sincere desire to help, and more than that, putting in some actual effort to help. Other than that, yes, the polite correction and the encouragement for future contributions is just what was intended. G'luck, Peter -- This would easier understand fewer had omitted. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 3: 8:24 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 39FE137B424; Tue, 24 Apr 2001 03:08:12 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id BBAB566E07; Tue, 24 Apr 2001 03:08:08 -0700 (PDT) Date: Tue, 24 Apr 2001 03:08:08 -0700 From: Kris Kennaway To: audit@FreeBSD.org, pst@FreeBSD.org, bug-gnats@gnu.org Subject: GNATS tempfile patch Message-ID: <20010424030808.A79902@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I got pissed off with the GNATS port creating all sorts of stupid tempfiles; here's part 1 of the fix (part 2 is to fix the .c files to use mkstemp() instead of mktemp()). Please review. Kris --- gnats/gnats-edit-pr.sh.orig Tue Apr 20 14:17:07 1999 +++ gnats/gnats-edit-pr.sh Tue Apr 24 02:42:11 2001 @@ -247,7 +247,7 @@ -e '/^X-GNATS-Notify:/,$b' \ $new.old`" =20 -change_msg=3D/tmp/ed_pr_ch$$ +change_msg=3D`mktemp -t ed_pr_ch` || exit 1 =20 # the following could stand to be cleaned up... if [ "$old_state" !=3D "$new_state" ]; then diff -ruN ../work/gnats-3.113/contrib/prmon ./contrib/prmon --- ../work/gnats-3.113/contrib/prmon Thu Nov 5 11:54:11 1998 +++ ./contrib/prmon Tue Apr 24 02:52:09 2001 @@ -103,15 +103,10 @@ =20 hostname=3D$(hostname) =20 - tmpdir=3D"/tmp/${progname}$$" - while [ -e "${tmpdir}" ]; do - tmpdir=3D"/tmp${progname}${RANDOM}" - done + tmpdir=3D`mktemp -d -t ${progname}` || exit 1 =20 TRAP_SIGNALS=3D"EXIT SIGHUP SIGINT SIGQUIT SIGTERM" trap 'cleanup_and_exit' ${TRAP_SIGNALS} - - mkdir ${tmpdir} || exit 1 } =20 function parse_command_args () @@ -145,7 +140,7 @@ =20 # Redirect all of stderr to a tmp file which we can mail # later.=20 - stderr_file=3D"/tmp/${progname}.stderr$$" + stderr_file=3D`mktemp -t ${progname}.stderr` || exit 1 exec 2> "${stderr_file}" ;; z-h* | z--help | z--h* ) diff -ruN ../work/gnats-3.113/gnats/check-db.sh ./gnats/check-db.sh --- ../work/gnats-3.113/gnats/check-db.sh Fri Feb 26 09:16:55 1999 +++ ./gnats/check-db.sh Tue Apr 24 02:54:53 2001 @@ -40,8 +40,8 @@ MAIL_AGENT=3D"xMAIL_AGENTx" =20 PATH=3D${LIBEXECDIR}:/usr/local/bin:/bin:/usr/bin; export PATH -TMPDIR=3D${TMPDIR-/tmp} -TMPFILE=3D$TMPDIR/gnats-check-db-$$ +TMPFILE=3D`mktemp -t gnats-check-db` || exit 1 +trap "rm -f $TMPFILE; exit 1" 1 2 3 5 10 13 15 =20 #=20 # First, try to lock the database diff -ruN ../work/gnats-3.113/gnats/delete-pr.sh ./gnats/delete-pr.sh --- ../work/gnats-3.113/gnats/delete-pr.sh Fri Feb 26 09:16:55 1999 +++ ./gnats/delete-pr.sh Tue Apr 24 02:56:33 2001 @@ -68,13 +68,13 @@ do =20 =20 - -trap 'rm -f /tmp/user$$ $INDEX.$$; exit 0' 0 +userfile=3D`mktemp -t user` || exit 1 +trap 'rm -f $userfile $INDEX.$$; exit 0' 0 trap 'if [ "$locked" !=3D "" ]; then \ $PR_EDIT --unlock $full_id ; \ locked=3D ; \ fi ; \ - rm -f /tmp/user$$ $INDEX.$$; exit 1' 1 2 3 13 15 + rm -f $userfile $INDEX.$$; exit 1' 1 2 3 13 15 =20 # check $full_id pr=3D$GNATS_ROOT/$full_id # pr =3D full path of editee @@ -116,16 +116,16 @@ # now we have a valid $full_id.. use its full path =20 # lock the pr -$PR_EDIT --lock $me $full_id 2> /tmp/user$$ +$PR_EDIT --lock $me $full_id 2> $userfile locked=3Dt =20 -if [ -s /tmp/user$$ ]; then - if [ "`grep exists /tmp/user$$`" =3D "" ]; then - echo "edit-pr: PR $full_id is locked by `sed 's/.*by //g' /tmp/user$$`" +if [ -s $userfile ]; then + if [ "`grep exists $userfile`" =3D "" ]; then + echo "edit-pr: PR $full_id is locked by `sed 's/.*by //g' $userfile`" else echo "edit-pr: GNATS is presently locked, try again in a moment" fi - rm -f /tmp/user$$ + rm -f $userfile exit 1 fi =20 diff -ruN ../work/gnats-3.113/gnats/gnats-edit-pr.sh ./gnats/gnats-edit-pr.= sh --- ../work/gnats-3.113/gnats/gnats-edit-pr.sh Tue Apr 24 03:01:07 2001 +++ ./gnats/gnats-edit-pr.sh Tue Apr 24 02:54:08 2001 @@ -174,7 +174,7 @@ fi =20 # new =3D temp file to use for editing -new=3D"/tmp/ep$$" +new=3D`mktemp -t ep` || exit 1 =20 # lock the pr $debug_print "Locking $pr_id." diff -ruN ../work/gnats-3.113/gnats/mail-query.sh ./gnats/mail-query.sh --- ../work/gnats-3.113/gnats/mail-query.sh Thu Nov 5 11:54:10 1998 +++ ./gnats/mail-query.sh Tue Apr 24 02:57:49 2001 @@ -46,7 +46,8 @@ [ "$header" =3D "Subject" ] && args=3D"$contents" done =20 -mail=3D/tmp/query$$ +mail=3D`mktemp -t query` || exit 1 +trap "rm -f $mail; exit 1" 1 2 3 5 10 13 15 =20 exec 3>&1 4>&2 > $mail 2>&1 =20 diff -ruN ../work/gnats-3.113/send-pr/install-sid.sh ./send-pr/install-sid.= sh --- ../work/gnats-3.113/send-pr/install-sid.sh Thu Nov 5 11:54:07 1998 +++ ./send-pr/install-sid.sh Tue Apr 24 02:58:27 2001 @@ -28,7 +28,8 @@ BINDIR=3DxBINDIRx =20 SUBMITTER=3D -TEMP=3D/tmp/sp$$ +TEMP=3D`mktemp -t sp` || exit 1 +trap "rm -f $TEMP; exit 1" 1 2 3 5 10 13 15 =20 if [ $# -eq 0 ]; then echo "$USAGE" diff -ruN ../work/gnats-3.113/send-pr/send-pr.sh ./send-pr/send-pr.sh --- ../work/gnats-3.113/send-pr/send-pr.sh Tue Apr 20 14:17:06 1999 +++ ./send-pr/send-pr.sh Tue Apr 24 03:00:19 2001 @@ -75,17 +75,10 @@ =20 #=0C =20 -if [ -z "$TMPDIR" ]; then - TMPDIR=3D/tmp -else - if [ "`echo $TMPDIR | grep '/$'`" !=3D "" ]; then - TMPDIR=3D"`echo $TMPDIR | sed -e 's,/$,,'`" - fi -fi - -TEMP=3D$TMPDIR/p$$ -BAD=3D$TMPDIR/pbad$$ -REF=3D$TMPDIR/pf$$ +TEMP=3D`mktemp -t p` || exit 1 +BAD=3D`mktemp -t pbad` || exit 1 +REF=3D`mktemp -t pf` || exit 1 +trap "rm -f $TEMP $BAD $REF; exit 1" 1 2 3 5 10 13 15 =20 # find a user name if [ "$LOGNAME" =3D "" ]; then --4Ckj6UjgE2iN1+kY 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 iD8DBQE65VCHWry0BWjoQKURApEqAKCC+Q/V9KHIgQCJRSuXaGY/uUu7MQCgurlp qk79/Pix7DgBXMDMRdRElW8= =TeJL -----END PGP SIGNATURE----- --4Ckj6UjgE2iN1+kY-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 3: 8:42 2001 Delivered-To: freebsd-audit@freebsd.org Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by hub.freebsd.org (Postfix) with ESMTP id 786CE37B43C; Tue, 24 Apr 2001 03:08:38 -0700 (PDT) (envelope-from phk@critter.freebsd.dk) Received: from critter (localhost [127.0.0.1]) by critter.freebsd.dk (8.11.3/8.11.3) with ESMTP id f3OA8PU56543; Tue, 24 Apr 2001 12:08:25 +0200 (CEST) (envelope-from phk@critter.freebsd.dk) To: audit@freebsd.org, current@freebsd.org Subject: PATCH: move struct netexport to struct mount From: Poul-Henning Kamp Date: Tue, 24 Apr 2001 12:08:25 +0200 Message-ID: <56541.988106905@critter> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG http://phk.freebsd.dk/patch/export.patch 20010424 export.patch This patch moves the netexport structure from the fs-specific mountstructure to struct mount. This makes the "struct netexport *" paramter to the vfs_export and vfs_checkexport interface unneeded. Consequently that all non-stacking filesystems can use vfs_stdcheckexp(). At the same time, make it a pointer to a struct netexport in struct mount, so that we can remove the bogus AF_MAX and #include from -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 3:33: 5 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 57B7D37B422 for ; Tue, 24 Apr 2001 03:33:03 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 06C9766E1F; Tue, 24 Apr 2001 03:32:57 -0700 (PDT) Date: Tue, 24 Apr 2001 03:32:57 -0700 From: Kris Kennaway To: "Andrew R. Reiter" Cc: freebsd-audit@freebsd.org Subject: Re: audit work: mbox fixes Message-ID: <20010424033257.A81079@xor.obsecurity.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from arr@watson.org on Mon, Apr 16, 2001 at 08:59:19PM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 16, 2001 at 08:59:19PM -0400, Andrew R. Reiter wrote: > If you guys could checkout: =20 > http://www.watson.org/~arr/fbsd-audit/libexec/getty/ OpenBSD has quite a few other fixes in this directory which apply to us; would you be able to work up a patch? > http://www.watson.org/~arr/fbsd-audit/sbin/newfs/ Committed, plus a few other sprintf()->snprintf() fixes. Thanks! Kris --rwEMma7ioTxnRzrJ 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 iD8DBQE65VZZWry0BWjoQKURAma6AKCf5yQsTZ8tzhQlH+EccgL53N1IJACfR+DP sXlmFwngUyyonW+uGhQqs5Y= =WI7C -----END PGP SIGNATURE----- --rwEMma7ioTxnRzrJ-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 3:39:41 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 28E7537B424 for ; Tue, 24 Apr 2001 03:39:39 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 44F0E66DF6; Tue, 24 Apr 2001 03:39:34 -0700 (PDT) Date: Tue, 24 Apr 2001 03:39:34 -0700 From: Kris Kennaway To: "Andrew R. Reiter" Cc: freebsd-audit@freebsd.org Subject: Re: audit work: leave.c usage() fix (more obsd sync) Message-ID: <20010424033933.B81079@xor.obsecurity.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="hQiwHBbRI9kgIhsi" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from arr@watson.org on Tue, Apr 17, 2001 at 03:23:49AM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --hQiwHBbRI9kgIhsi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Apr 17, 2001 at 03:23:49AM -0400, Andrew R. Reiter wrote: > hi, >=20 > attached is a patch again for -current for leave.c. the sync up with obsd > was the call usage() if the number of arguments is greater than two. with > -Wall compile, it was also, of course, complaining about the register char > *cp not being initialized, so I just modified it to be set to NULL. >=20 > can also be found at http://www.watson.org/~arr/fbsd-audit/usr.bin/leave/ Committed! Kris --hQiwHBbRI9kgIhsi 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 iD8DBQE65VflWry0BWjoQKURAu2KAJ9CtUo0cwvBkXWHneV/CqbIpUxG6ACgnTAx Dj29rIB2hh1S9gPPnXakO/M= =WqyU -----END PGP SIGNATURE----- --hQiwHBbRI9kgIhsi-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 3:51:28 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 F148F37B423 for ; Tue, 24 Apr 2001 03:51:20 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 5D46C66DF6; Tue, 24 Apr 2001 03:51:16 -0700 (PDT) Date: Tue, 24 Apr 2001 03:51:16 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: More leave(1) syncing Message-ID: <20010424035116.A82401@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 While I was in there, I synced up the rest of leave(1) with OpenBSD. The main change is that it handles 24-hour times better. Please review, and especially check cvs diff to make sure I didn't spam any previous FreeBSD fixes. Thanks. Kris Index: leave.1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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: /home/ncvs/src/usr.bin/leave/leave.1,v retrieving revision 1.7 diff -u -r1.7 leave.1 --- leave.1 2001/02/06 16:20:31 1.7 +++ leave.1 2001/04/24 10:49:49 @@ -63,8 +63,8 @@ hours (on a 12 or 24 hour clock), and .Ar mm are minutes. -All times are converted to a 12 hour clock, and assumed to -be in the next 12 hours. +In ambiguous cases, times are converted to a 12 hour clock, +and assumed to be in the next 12 hours. .It Cm \&+ If the time is preceded by .Ql Cm \&+ , Index: leave.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: /home/ncvs/src/usr.bin/leave/leave.c,v retrieving revision 1.6 diff -u -r1.6 leave.c --- leave.c 2001/04/24 10:39:17 1.6 +++ leave.c 2001/04/24 10:49:49 @@ -42,7 +42,7 @@ static char sccsid[] =3D "@(#)leave.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] =3D - "$FreeBSD: src/usr.bin/leave/leave.c,v 1.6 2001/04/24 10:39:17 kris Exp = $"; + "$FreeBSD$"; #endif /* not lint */ =20 #include @@ -70,9 +70,9 @@ register u_int secs; register int hours, minutes; register char c, *cp =3D NULL; - struct tm *t, *localtime(); - time_t now, time(); - int plusnow, t_12_hour; + struct tm *t =3D NULL; + time_t now; + int plusnow; char buf[50]; =20 if (setlocale(LC_TIME, "") =3D=3D NULL) @@ -80,7 +80,7 @@ =20 if (argc < 2) { #define MSG1 "When do you have to leave? " - (void)write(1, MSG1, sizeof(MSG1) - 1); + (void)write(STDOUT_FILENO, MSG1, sizeof(MSG1) - 1); cp =3D fgets(buf, sizeof(buf), stdin); if (cp =3D=3D NULL || *cp =3D=3D '\n') exit(0); @@ -92,8 +92,11 @@ if (*cp =3D=3D '+') { plusnow =3D 1; ++cp; - } else + } else { plusnow =3D 0; + (void)time(&now); + t =3D localtime(&now); + } =20 for (hours =3D 0; (c =3D *cp) && c !=3D '\n'; ++cp) { if (!isdigit(c)) @@ -108,30 +111,19 @@ if (plusnow) secs =3D hours * 60 * 60 + minutes * 60; else { - (void)time(&now); - t =3D localtime(&now); - if (hours > 23) usage(); - - /* Convert tol to 12 hr time (0:00...11:59) */ - if (hours > 11) - hours -=3D 12; - - /* Convert tm to 12 hr time (0:00...11:59) */ - if (t->tm_hour > 11) - t_12_hour =3D t->tm_hour - 12; - else - t_12_hour =3D t->tm_hour; - - if (hours < t_12_hour || - (hours =3D=3D t_12_hour && minutes <=3D t->tm_min)) - /* Leave time is in the past so we add 12 hrs */ - hours +=3D 12; + if (t->tm_hour > hours ||=20 + (t->tm_hour =3D=3D hours && t->tm_min >=3D minutes)) { + /* determine 24 hours mode */ + if (hours >=3D 13) + hours +=3D 24; + else + hours +=3D 12; + } =20 - secs =3D (hours - t_12_hour) * 60 * 60; + secs =3D (hours - t->tm_hour) * 60 * 60; secs +=3D (minutes - t->tm_min) * 60; - secs -=3D now % 60; /* truncate (now + secs) to min */ } doalarm(secs); exit(0); @@ -142,15 +134,14 @@ u_int secs; { register int bother; - time_t daytime, time(); - char tb[80]; + time_t daytime; int pid; =20 if ((pid =3D fork())) { (void)time(&daytime); daytime +=3D secs; - strftime(tb, sizeof(tb), "%+", localtime(&daytime)); - printf("Alarm set for %s. (pid %d)\n", tb, pid); + printf("Alarm set for %.16s. (pid %d)\n", + ctime(&daytime), pid); exit(0); } sleep((u_int)2); /* let parent print set message */ @@ -165,7 +156,7 @@ #define MSG2 "\07\07You have to leave in 5 minutes.\n" if (secs >=3D FIVEMIN) { sleep(secs - FIVEMIN); - if (write(1, MSG2, sizeof(MSG2) - 1) !=3D sizeof(MSG2) - 1) + if (write(STDOUT_FILENO, MSG2, sizeof(MSG2) - 1) !=3D sizeof(MSG2) - 1) exit(0); secs =3D FIVEMIN; } @@ -174,19 +165,19 @@ #define MSG3 "\07\07Just one more minute!\n" if (secs >=3D ONEMIN) { sleep(secs - ONEMIN); - if (write(1, MSG3, sizeof(MSG3) - 1) !=3D sizeof(MSG3) - 1) + if (write(STDOUT_FILENO, MSG3, sizeof(MSG3) - 1) !=3D sizeof(MSG3) - 1) exit(0); } =20 #define MSG4 "\07\07Time to leave!\n" for (bother =3D 10; bother--;) { sleep((u_int)ONEMIN); - if (write(1, MSG4, sizeof(MSG4) - 1) !=3D sizeof(MSG4) - 1) + if (write(STDOUT_FILENO, MSG4, sizeof(MSG4) - 1) !=3D sizeof(MSG4) - 1) exit(0); } =20 #define MSG5 "\07\07That was the last time I'll tell you. Bye.\n" - (void)write(1, MSG5, sizeof(MSG5) - 1); + (void)write(STDOUT_FILENO, MSG5, sizeof(MSG5) - 1); exit(0); } =20 --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 iD8DBQE65VqiWry0BWjoQKURAtfZAJ4xq/EJQ9lAjgahrHSToT0GeJV77gCeJgsQ n37b6EN5bjZO4jtFZ6U8BTI= =EQ0i -----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 Tue Apr 24 9:15:32 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fw.wintelcom.net (ns1.wintelcom.net [209.1.153.20]) by hub.freebsd.org (Postfix) with ESMTP id 95F9337B423; Tue, 24 Apr 2001 09:15:28 -0700 (PDT) (envelope-from bright@fw.wintelcom.net) Received: (from bright@localhost) by fw.wintelcom.net (8.10.0/8.10.0) id f3OGFSr07253; Tue, 24 Apr 2001 09:15:28 -0700 (PDT) Date: Tue, 24 Apr 2001 09:15:28 -0700 From: Alfred Perlstein To: Poul-Henning Kamp Cc: audit@FreeBSD.ORG, current@FreeBSD.ORG Subject: Re: PATCH: move struct netexport to struct mount Message-ID: <20010424091528.K1790@fw.wintelcom.net> References: <56541.988106905@critter> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <56541.988106905@critter>; from phk@FreeBSD.ORG on Tue, Apr 24, 2001 at 12:08:25PM +0200 X-all-your-base: are belong to us. Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG * Poul-Henning Kamp [010424 03:08] wrote: > > http://phk.freebsd.dk/patch/export.patch > > 20010424 export.patch > > This patch moves the netexport structure from the fs-specific > mountstructure to struct mount. > > This makes the "struct netexport *" paramter to the vfs_export > and vfs_checkexport interface unneeded. > > Consequently that all non-stacking filesystems can use > vfs_stdcheckexp(). > > At the same time, make it a pointer to a struct netexport > in struct mount, so that we can remove the bogus AF_MAX > and #include from Nice, go for it. -- -Alfred Perlstein - [alfred@freebsd.org] Represent yourself, show up at BABUG http://www.babug.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 9:42:20 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 4EECA37B424 for ; Tue, 24 Apr 2001 09:42:16 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3OGgbB17806; Tue, 24 Apr 2001 12:42:37 -0400 (EDT) (envelope-from arr@watson.org) Date: Tue, 24 Apr 2001 12:42:37 -0400 (EDT) From: "Andrew R. Reiter" To: Kris Kennaway Cc: freebsd-audit@freebsd.org Subject: Re: audit work: mbox fixes In-Reply-To: <20010424033257.A81079@xor.obsecurity.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 Ok.. I can do that today. The reason I did these two was because the ease of recognizing similar code in each projects src code. I will however, work on these today. I started to look at the fd_set "overflow" problems and found a bunch in our tree... I will start making patches to move those over to kqueue in the near future (later this week). Andrew On Tue, 24 Apr 2001, Kris Kennaway wrote: > On Mon, Apr 16, 2001 at 08:59:19PM -0400, Andrew R. Reiter wrote: > > > If you guys could checkout: > > http://www.watson.org/~arr/fbsd-audit/libexec/getty/ > > OpenBSD has quite a few other fixes in this directory which apply to > us; would you be able to work up a patch? > > > http://www.watson.org/~arr/fbsd-audit/sbin/newfs/ > > Committed, plus a few other sprintf()->snprintf() fixes. > > Thanks! > > Kris > *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 14:52: 3 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 23CEC37B422 for ; Tue, 24 Apr 2001 14:52:01 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3OLqW722650 for ; Tue, 24 Apr 2001 17:52:32 -0400 (EDT) (envelope-from arr@watson.org) Date: Tue, 24 Apr 2001 17:52:31 -0400 (EDT) From: "Andrew R. Reiter" To: freebsd-audit@freebsd.org Subject: audit work: kerberosIV 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 hi, did some more sync up patches for obsd->fbsd. most all of it is just simply doing return value checking from setenv(3). the patches can be found at: http://www.watson.org/~arr/fbsd-audit/crypto/kerberosIV/ The directories with files are: appl/afsutil/ appl/bsd/ appl/kauth/ appl/telnet/libtelnet/ appl/telnet/telnetd/ lib/auth/afskauthlib/ There _are_ a bunch more of fixes for getty, ask kris mentioned, so I will try to get to those in the near future ;-) I am going to start actually writing the patches for select(2) calls (move them to k{queue,event}() calls). Andrew *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 17:59:59 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 A828137B423; Tue, 24 Apr 2001 17:59:55 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 4F21666DF6; Tue, 24 Apr 2001 17:59:55 -0700 (PDT) Date: Tue, 24 Apr 2001 17:59:55 -0700 From: Kris Kennaway To: "Andrew R. Reiter" Cc: freebsd-audit@freebsd.org, assar@FreeBSD.org Subject: Re: audit work: kerberosIV Message-ID: <20010424175955.B95577@xor.obsecurity.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="tsOsTdHNUZQcU9Ye" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from arr@watson.org on Tue, Apr 24, 2001 at 05:52:31PM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --tsOsTdHNUZQcU9Ye Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Sounds good. Bouncing a copy of this to Assar for evaluation of inclusion in the vendor distribution. Kris On Tue, Apr 24, 2001 at 05:52:31PM -0400, Andrew R. Reiter wrote: > hi, >=20 > did some more sync up patches for obsd->fbsd. most all of it is just > simply doing return value checking from setenv(3). the patches can be > found at: http://www.watson.org/~arr/fbsd-audit/crypto/kerberosIV/ >=20 > The directories with files are: > appl/afsutil/ > appl/bsd/ > appl/kauth/ > appl/telnet/libtelnet/ > appl/telnet/telnetd/ > lib/auth/afskauthlib/ >=20 >=20 > There _are_ a bunch more of fixes for getty, ask kris mentioned, so I will > try to get to those in the near future ;-) I am going to start actually > writing the patches for select(2) calls (move them to k{queue,event}() > calls). >=20 > Andrew >=20 > *-------------................................................. > | Andrew R. Reiter=20 > | arr@fledge.watson.org > | "It requires a very unusual mind > | to undertake the analysis of the obvious" -- A.N. Whitehead >=20 >=20 > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-audit" in the body of the message --tsOsTdHNUZQcU9Ye 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 iD8DBQE65iGLWry0BWjoQKURAn5KAKCpvRKd/IYWi91u9AF88WUFX6KNSwCfXGfO rxKj2vOiVpmINX8Kj1U9ogw= =iOOM -----END PGP SIGNATURE----- --tsOsTdHNUZQcU9Ye-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 18:58:36 2001 Delivered-To: freebsd-audit@freebsd.org Received: from assaris.sics.se (dhcp102.iss.kth.se [130.237.7.102]) by hub.freebsd.org (Postfix) with ESMTP id ADA3037B423 for ; Tue, 24 Apr 2001 18:58:23 -0700 (PDT) (envelope-from assar@assaris.sics.se) Received: (from assar@localhost) by assaris.sics.se (8.9.3/8.9.3) id DAA18428; Wed, 25 Apr 2001 03:58:39 +0200 (CEST) (envelope-from assar) From: assar@freebsd.org To: Kris Kennaway Cc: "Andrew R. Reiter" , freebsd-audit@freebsd.org Subject: Re: audit work: kerberosIV References: <20010424175955.B95577@xor.obsecurity.org> Date: 25 Apr 2001 03:58:39 +0200 In-Reply-To: Kris Kennaway's message of "Tue, 24 Apr 2001 17:59:55 -0700" Message-ID: <5litjt3flc.fsf@assaris.sics.se> Lines: 25 User-Agent: Gnus/5.070098 (Pterodactyl Gnus v0.98) Emacs/20.6 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --=-=-= Kris Kennaway writes: > Sounds good. Bouncing a copy of this to Assar for evaluation of > inclusion in the vendor distribution. Thanks for the copy Kris, I haven't had the time lately to keep up with -audit traffic. Andrew: in the development code of krb4, most calls to setenv() are replaced with calls to esetenv() (which just calls errx() if the setenv fails). For obvious reasons, I would prefer merging the fix that's in the vendor distribution instead. I hope that's ok with you? Patches follow. /assar > On Tue, Apr 24, 2001 at 05:52:31PM -0400, Andrew R. Reiter wrote: > > did some more sync up patches for obsd->fbsd. most all of it is just > > simply doing return value checking from setenv(3). the patches can be > > found at: http://www.watson.org/~arr/fbsd-audit/crypto/kerberosIV/ --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=kdiff Index: appl/afsutil/pagsh.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/krb4/appl/afsutil/pagsh.c,v retrieving revision 1.22 retrieving revision 1.24 diff -u -w -r1.22 -r1.24 --- appl/afsutil/pagsh.c 1999/12/02 16:58:28 1.22 +++ appl/afsutil/pagsh.c 2001/02/20 23:11:33 1.24 @@ -76,7 +78,7 @@ } while(f < 0); close(f); unlink(tf); - setenv("KRBTKFILE", tf, 1); + esetenv("KRBTKFILE", tf, 1); i = 0; Index: appl/bsd/login.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/krb4/appl/bsd/login.c,v retrieving revision 1.125 retrieving revision 1.132 diff -u -w -r1.125 -r1.132 --- appl/bsd/login.c 1999/11/30 19:24:01 1.125 +++ appl/bsd/login.c 2001/02/20 23:07:50 1.132 @@ -659,7 +665,7 @@ sysv_newenv(argc, argv, pwd, term, pflag); #ifdef KERBEROS if (krbtkfile_env) - setenv("KRBTKFILE", krbtkfile_env, 1); + esetenv("KRBTKFILE", krbtkfile_env, 1); #endif if (tty[sizeof("tty")-1] == 'd') Index: appl/bsd/su.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/krb4/appl/bsd/su.c,v retrieving revision 1.70 retrieving revision 1.76 diff -u -w -r1.70 -r1.76 --- appl/bsd/su.c 1999/11/13 06:14:11 1.70 +++ appl/bsd/su.c 2001/02/20 23:07:52 1.76 @@ -240,18 +260,18 @@ if (environ == NULL) err (1, "malloc"); environ[0] = NULL; - setenv ("PATH", _PATH_DEFPATH, 1); + esetenv ("PATH", _PATH_DEFPATH, 1); if (t) - setenv ("TERM", t, 1); + esetenv ("TERM", t, 1); if (k) - setenv ("KRBTKFILE", k, 1); + esetenv ("KRBTKFILE", k, 1); if (chdir (pwd->pw_dir) < 0) errx (1, "no directory"); } if (asthem || pwd->pw_uid) - setenv ("USER", pwd->pw_name, 1); - setenv ("HOME", pwd->pw_dir, 1); - setenv ("SHELL", shell, 1); + esetenv ("USER", pwd->pw_name, 1); + esetenv ("HOME", pwd->pw_dir, 1); + esetenv ("SHELL", shell, 1); } if (iscsh == YES) { if (fastlogin) @@ -343,7 +370,7 @@ "%s_%s_to_%s_%u", TKT_ROOT, username, user, (unsigned) getpid ()); - setenv ("KRBTKFILE", krbtkfile, 1); + esetenv ("KRBTKFILE", krbtkfile, 1); krb_set_tkt_string (krbtkfile); /* * Set real as well as effective ID to 0 for the moment, Index: appl/bsd/sysv_environ.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/krb4/appl/bsd/sysv_environ.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -w -r1.23 -r1.24 --- appl/bsd/sysv_environ.c 1997/12/14 23:50:44 1.23 +++ appl/bsd/sysv_environ.c 2000/10/02 05:35:56 1.24 @@ -36,7 +36,7 @@ if (val == NULL) continue; *val = '\0'; - setenv(buf, val + 1, 1); + esetenv(buf, val + 1, 1); } fclose (f); } @@ -110,12 +110,12 @@ for (pp = preserved; pp->name; pp++) if (pp->value) - setenv(pp->name, pp->value, 1); + esetenv(pp->name, pp->value, 1); /* The TERM definition from e.g. rlogind can override an existing one. */ if (term[0]) - setenv("TERM", term, 1); + esetenv("TERM", term, 1); /* * Environment definitions from the command line overrule existing ones, @@ -130,7 +130,7 @@ while (argc && *argv) { if (strchr(*argv, '=') == 0) { snprintf(buf, sizeof(buf), "L%d", count++); - setenv(buf, *argv, 1); + esetenv(buf, *argv, 1); } else { for (cp = censored; cp->prefix; cp++) if (STREQN(*argv, cp->prefix, cp->length)) @@ -143,20 +143,20 @@ /* PATH is always reset. */ - setenv("PATH", pwd->pw_uid ? default_path : default_supath, 1); + esetenv("PATH", pwd->pw_uid ? default_path : default_supath, 1); /* Undocumented: HOME, MAIL and LOGNAME are always reset (SunOS 5.1). */ - setenv("HOME", pwd->pw_dir, 1); + esetenv("HOME", pwd->pw_dir, 1); { char *sep = "/"; if(KRB4_MAILDIR[strlen(KRB4_MAILDIR) - 1] == '/') sep = ""; roken_concat(buf, sizeof(buf), KRB4_MAILDIR, sep, pwd->pw_name, NULL); } - setenv("MAIL", buf, 1); - setenv("LOGNAME", pwd->pw_name, 1); - setenv("USER", pwd->pw_name, 1); + esetenv("MAIL", buf, 1); + esetenv("LOGNAME", pwd->pw_name, 1); + esetenv("USER", pwd->pw_name, 1); /* * Variables that may be set according to specifications in the defaults @@ -167,11 +167,11 @@ */ if (strcasecmp(default_altsh, "YES") == 0) - setenv("SHELL", pwd->pw_shell, 1); + esetenv("SHELL", pwd->pw_shell, 1); if (default_hz) - setenv("HZ", default_hz, 0); + esetenv("HZ", default_hz, 0); if (default_timezone) - setenv("TZ", default_timezone, 0); + esetenv("TZ", default_timezone, 0); /* Non-environment stuff. */ Index: appl/kauth/kauth.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/appl/kauth/kauth.c,v retrieving revision 1.97 retrieving revision 1.101 diff -u -w -r1.97 -r1.101 --- appl/kauth/kauth.c 1999/12/02 16:58:31 1.97 +++ appl/kauth/kauth.c 2001/02/20 01:44:44 1.101 @@ -316,7 +314,7 @@ }while(f < 0); close(f); unlink(tf); - setenv("KRBTKFILE", tf, 1); + esetenv("KRBTKFILE", tf, 1); krb_set_tkt_string (tf); } Index: appl/telnet/libtelnet/kerberos.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/appl/telnet/libtelnet/kerberos.c,v retrieving revision 1.46 retrieving revision 1.51 diff -u -w -r1.46 -r1.51 --- appl/telnet/libtelnet/kerberos.c 1999/09/16 20:41:33 1.46 +++ appl/telnet/libtelnet/kerberos.c 2001/02/15 04:20:52 1.51 @@ -331,7 +331,7 @@ "%s%u", TKT_ROOT, (unsigned)pw->pw_uid); - setenv("KRBTKFILE", ts, 1); + esetenv("KRBTKFILE", ts, 1); if (pw->pw_uid == 0) syslog(LOG_INFO|LOG_AUTH, Index: appl/telnet/telnetd/state.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/appl/telnet/telnetd/state.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- appl/telnet/telnetd/state.c 1999/05/13 23:12:50 1.13 +++ appl/telnet/telnetd/state.c 2000/10/02 05:06:02 1.14 @@ -1016,7 +1016,7 @@ return; settimer(xdisplocsubopt); subpointer[SB_LEN()] = '\0'; - setenv("DISPLAY", (char *)subpointer, 1); + esetenv("DISPLAY", (char *)subpointer, 1); break; } /* end of case TELOPT_XDISPLOC */ @@ -1183,7 +1183,7 @@ case ENV_USERVAR: *cp = '\0'; if (valp) - setenv(varp, valp, 1); + esetenv(varp, valp, 1); else unsetenv(varp); cp = varp = (char *)subpointer; @@ -1202,7 +1202,7 @@ } *cp = '\0'; if (valp) - setenv(varp, valp, 1); + esetenv(varp, valp, 1); else unsetenv(varp); break; Index: appl/telnet/telnetd/telnetd.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/appl/telnet/telnetd/telnetd.c,v retrieving revision 1.58 retrieving revision 1.64 diff -u -w -r1.58 -r1.64 --- appl/telnet/telnetd/telnetd.c 1999/11/13 06:31:04 1.58 +++ appl/telnet/telnetd/telnetd.c 2001/02/08 16:06:27 1.64 @@ -776,7 +739,7 @@ */ *user_name = 0; level = getterminaltype(user_name, sizeof(user_name)); - setenv("TERM", terminaltype ? terminaltype : "network", 1); + esetenv("TERM", terminaltype ? terminaltype : "network", 1); #ifdef _SC_CRAY_SECURE_SYS if (secflag) { Index: lib/auth/afskauthlib/verify.c =================================================================== RCS file: /afs/pdc.kth.se/src/packages/kth-krb/SourceRepository/lib/auth/afskauthlib/verify.c,v retrieving revision 1.20 retrieving revision 1.24 diff -u -w -r1.20 -r1.24 --- lib/auth/afskauthlib/verify.c 1999/12/02 16:58:37 1.20 +++ lib/auth/afskauthlib/verify.c 2000/12/31 07:57:08 1.24 @@ -277,10 +290,10 @@ } } #ifdef KRB5 - setenv("KRB5CCNAME",krb5ccname,1); + esetenv("KRB5CCNAME",krb5ccname,1); #endif #ifdef KRB4 - setenv("KRBTKFILE",krbtkfile,1); + esetenv("KRBTKFILE",krbtkfile,1); return krbtkfile; #else return ""; --=-=-= --=-=-= Content-Type: text/x-patch; charset=iso-8859-1 Content-Disposition: attachment; filename=esetenv.c Content-Transfer-Encoding: 8bit Index: esetenv.c =================================================================== RCS file: esetenv.c diff -N esetenv.c --- /dev/null Wed Apr 25 03:51:31 2001 +++ /tmp/cvsLAAabzfBa Wed Apr 25 03:51:32 2001 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2000, 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include +RCSID("$Id: esetenv.c,v 1.3 2001/01/27 05:28:38 assar Exp $"); +#endif + +#include "roken.h" + +#include + +void +esetenv(const char *var, const char *val, int rewrite) +{ + if (setenv ((char *)var, (char *)val, rewrite)) + errx (1, "failed setting environment variable %s", var); +} --=-=-=-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Tue Apr 24 19:23:23 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id B432C37B422; Tue, 24 Apr 2001 19:23:20 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3P2NpH27022; Tue, 24 Apr 2001 22:23:51 -0400 (EDT) (envelope-from arr@watson.org) Date: Tue, 24 Apr 2001 22:23:51 -0400 (EDT) From: "Andrew R. Reiter" To: assar@freebsd.org Cc: Kris Kennaway , freebsd-audit@freebsd.org Subject: Re: audit work: kerberosIV In-Reply-To: <5litjt3flc.fsf@assaris.sics.se> 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 25 Apr 2001 assar@freebsd.org wrote: > Kris Kennaway writes: > > Sounds good. Bouncing a copy of this to Assar for evaluation of > > inclusion in the vendor distribution. > > Thanks for the copy Kris, I haven't had the time lately to keep up > with -audit traffic. > > Andrew: in the development code of krb4, most calls to setenv() are > replaced with calls to esetenv() (which just calls errx() if the > setenv fails). For obvious reasons, I would prefer merging the fix > that's in the vendor distribution instead. I hope that's ok with you? > Patches follow. > > /assar > Sounds great! Thanks for the info :-) Andrew *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 2:37:48 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 938C837B423; Wed, 25 Apr 2001 02:37:41 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 11A1A66DF6; Wed, 25 Apr 2001 02:37:40 -0700 (PDT) Date: Wed, 25 Apr 2001 02:37:40 -0700 From: Kris Kennaway To: Kris Kennaway Cc: audit@FreeBSD.ORG, pst@FreeBSD.ORG, bug-gnats@gnu.org Subject: Re: GNATS tempfile patch Message-ID: <20010425023740.C54713@xor.obsecurity.org> References: <20010424030808.A79902@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="sHrvAb52M6C8blB9" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010424030808.A79902@xor.obsecurity.org>; from kris@obsecurity.org on Tue, Apr 24, 2001 at 03:08:08AM -0700 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --sHrvAb52M6C8blB9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =2E.and here's part II, fixing the C code to use mkstemp() if available, instead of mktemp(). Please review, etc. Kris --- gnats/cmds.c.orig Wed Mar 17 15:45:36 1999 +++ gnats/cmds.c Wed Apr 25 02:24:59 2001 @@ -121,19 +121,33 @@ char *buf, *tmpdir; MsgType r; int i; +#ifdef HAVE_MKSTEMP + int fd; +#endif =20 tmpdir =3D getenv ("TMPDIR"); if (tmpdir =3D=3D NULL) tmpdir =3D "/tmp"; /* XXX */ -#ifdef HAVE_MKTEMP +#if defined(HAVE_MKSTEMP) || defined(HAVE_MKTEMP) sprintf (path, "%s/gnatsXXXXXX", tmpdir); +#endif +#ifdef HAVE_MKSTEMP + if ((fd =3D mkstemp (path)) =3D=3D -1) + goto die; +#else +#ifdef HAVE_MKTEMP mktemp (path); #else tmpnam (name); strcpy (path, name); #endif +#endif =20 +#ifdef HAVE_MKSTEMP + if ((tf =3D fdopen (fd, "w")) =3D=3D (FILE *) NULL) +#else if ((tf =3D fopen (path, "w")) =3D=3D (FILE *) NULL) +#endif { /* give error that we can't create the temp and leave. */ xfree (path); --- gnats/internal.c.orig Tue Mar 2 16:18:53 1999 +++ gnats/internal.c Wed Apr 25 02:24:45 2001 @@ -36,20 +36,38 @@ char name[L_tmpnam]; #endif Index *i; +#ifdef HAVE_MKSTEMP + int fd; +#endif =20 -#ifdef HAVE_MKTEMP +#if defined(HAVE_MKTEMP) || defined(HAVE_MKSTEMP) workfile =3D (char *) xmalloc (strlen (gnats_root) + strlen ("/gnats-adm/indXXXXXX") + 1 /* null */ ); sprintf (workfile, "%s/gnats-adm/indXXXXXX", gnats_root); +#endif +#ifdef HAVE_MKSTEMP + if ((fd =3D mkstemp (workfile)) =3D=3D -1) { + fprintf (stderr, "%s: can't open the temporary file\n", + program_name); + xfree (workfile); + return; + } +#else +#ifdef HAVE_MKTEMP mktemp (workfile); #else workfile =3D (char *) xmalloc (L_tmpnam); tmpnam (name); strcpy (workfile, name); #endif +#endif =20 +#ifdef HAVE_MKSTEMP + fp =3D fdopen (fd, "w"); +#else fp =3D fopen (workfile, "w"); +#endif if (fp =3D=3D NULL) { fprintf (stderr, "%s: can't open the temporary file %s\n", --- gnats/autoconf.h.in.orig Thu Nov 5 11:54:09 1998 +++ gnats/autoconf.h.in Wed Apr 25 02:24:07 2001 @@ -60,8 +60,13 @@ /* Define if you have the mkdir function. */ #undef HAVE_MKDIR =20 +/* Define if you have the mkstemp function. */ +#undef HAVE_MKSTEMP + /* Define if you have the mktemp function. */ +#ifndef HAVE_MKSTEMP #undef HAVE_MKTEMP +#endif =20 /* Define if you have the header file. */ #undef HAVE_DIRENT_H --- gnats/configure.orig Wed Apr 25 02:22:53 2001 +++ gnats/configure Wed Apr 25 02:22:59 2001 @@ -1831,7 +1831,7 @@ fi done =20 -for ac_func in ftime mkdir mktemp +for ac_func in ftime mkdir mktemp mkstemp do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1838: checking for $ac_func" >&5 diff -ruN gnats-3.113/gnats/configure.in work/gnats-3.113/gnats/configure.in --- gnats-3.113/gnats/configure.in Thu Nov 5 11:54:10 1998 +++ gnats/configure.in Wed Apr 25 02:13:34 2001 @@ -54,7 +54,7 @@ AC_CHECK_LIB(gen, main) AC_STDC_HEADERS AC_HAVE_HEADERS(string.h fcntl.h limits.h syslog.h memory.h netdb.h unistd= .h sys/select.h machine/endian.h) -AC_HAVE_FUNCS(ftime mkdir mktemp) +AC_HAVE_FUNCS(ftime mkdir mkstemp mktemp) AC_HEADER_DIRENT AC_SIZE_T AC_LISPDIR --- gnats/queue-pr.c.orig Wed Nov 25 06:15:20 1998 +++ gnats/queue-pr.c Wed Apr 25 02:32:29 2001 @@ -247,15 +247,22 @@ tmpdir =3D getenv ("TMPDIR"); if (tmpdir =3D=3D NULL) tmpdir =3D "/tmp"; /* FIXME */ -#ifdef HAVE_MKTEMP +#if defined(HAVE_MKSTEMP) || defined(HAVE_MKTEMP) sprintf (bug_file, "%s/gnatsXXXXXX", tmpdir); +#endif + +#ifdef HAVE_MKSTEMP + fd[1] =3D mkstemp(bug_file); +#else +#ifdef HAVE_MKTEMP mktemp (bug_file); #else tmpnam (name); strcpy (bug_file, name); #endif - =20 fd[1] =3D open (bug_file, O_WRONLY|O_CREAT, 0664); +#endif + =20 if (fd[1] < 0) punt (1, "%s: can't open queue file %s for writing: %s\n", program_name, bug_file, strerror (errno)); --sHrvAb52M6C8blB9 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 iD8DBQE65prkWry0BWjoQKURAglOAKCDKT9R0w7DDypxA0qhMD1XoVM4wQCg6yj5 GOWLpaWQAAImno5ldOcwWCg= =RI7n -----END PGP SIGNATURE----- --sHrvAb52M6C8blB9-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 3:32:21 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 12DBF37B422 for ; Wed, 25 Apr 2001 03:32:12 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id B0A8F66DF6; Wed, 25 Apr 2001 03:32:07 -0700 (PDT) Date: Wed, 25 Apr 2001 03:32:07 -0700 From: Kris Kennaway To: dhcp-client@isc.org Cc: audit@FreeBSD.org Subject: Format string security patches Message-ID: <20010425033207.A68532@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="4Ckj6UjgE2iN1+kY" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --4Ckj6UjgE2iN1+kY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi there, The following patches are against the DHCP 2.0pl5 code, and include a number of format string errors which may be exploitable under the right (wrong) circumstances (I didn't check too closely yet), as well as a number which are trivial and just silence compiler warnings. There are also several bugs due to missing format string arguments which I came across and fixed -- one or two I had to guess from context. Please send me back a copy of the version of this patch which you eventually apply to your CVS repository so I can import the same patch into FreeBSD -- thanks. Kris P.S. I couldn't find a contact address on the ISC website for security issues, so I hope this list is acceptible. The website contains a PGP key presumably for use in security matters, but doesn't give a contact address with which to use it to contact ISC developers directly. Index: client/clparse.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/contrib/isc-dhcp/client/clparse.c,v retrieving revision 1.6 diff -u -r1.6 clparse.c --- client/clparse.c 2000/07/20 09:56:18 1.6 +++ client/clparse.c 2001/04/25 10:09:46 @@ -389,7 +389,7 @@ break; } if (i =3D=3D 256) { - parse_warn ("%s: expected option name."); + parse_warn ("%s: expected option name.", val); skip_to_semi (cfile); return 0; } Index: client/dhclient.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/contrib/isc-dhcp/client/dhclient.c,v retrieving revision 1.18 diff -u -r1.18 dhclient.c --- client/dhclient.c 2000/11/04 19:59:11 1.18 +++ client/dhclient.c 2001/04/25 10:10:44 @@ -178,11 +178,11 @@ =20 if (!quiet) { note ("%s %s", message, DHCP_VERSION); - note (copyright); - note (arr); + note ("%s", copyright); + note ("%s", arr); note (""); - note (contrib); - note (url); + note ("%s", contrib); + note ("%s", url); note (""); } else log_perror =3D 0; @@ -293,12 +293,12 @@ static void usage (appname) char *appname; { - note (message); - note (copyright); - note (arr); + note ("%s", message); + note ("%s", copyright); + note ("%s", arr); note (""); - note (contrib); - note (url); + note ("%s", contrib); + note ("%s", url); note (""); =20 warn ("Usage: %s [-D] [-d] [-p ] [-cf conf-file]", appname); Index: common/bpf.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/contrib/isc-dhcp/common/bpf.c,v retrieving revision 1.1.1.5 diff -u -r1.1.1.5 bpf.c --- common/bpf.c 1999/06/23 23:39:42 1.1.1.5 +++ common/bpf.c 2001/04/25 10:12:06 @@ -249,7 +249,7 @@ error ("Can't get bpf buffer length: %m"); info -> rbuf =3D malloc (info -> rbuf_max); if (!info -> rbuf) - error ("Can't allocate %d bytes for bpf input buffer."); + error ("Can't allocate %d bytes for bpf input buffer.", info -> rbuf_max= ); info -> rbuf_offset =3D 0; info -> rbuf_len =3D 0; =20 Index: common/errwarn.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/contrib/isc-dhcp/common/errwarn.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 errwarn.c --- common/errwarn.c 1999/02/10 09:10:13 1.1.1.1 +++ common/errwarn.c 2001/04/25 10:08:43 @@ -71,7 +71,7 @@ va_end (list); =20 #ifndef DEBUG - syslog (log_priority | LOG_ERR, mbuf); + syslog (log_priority | LOG_ERR, "%s", mbuf); #endif =20 /* Also log it to stderr? */ @@ -104,7 +104,7 @@ va_end (list); =20 #ifndef DEBUG - syslog (log_priority | LOG_ERR, mbuf); + syslog (log_priority | LOG_ERR, "%s", mbuf); #endif =20 if (log_perror) { @@ -130,7 +130,7 @@ va_end (list); =20 #ifndef DEBUG - syslog (log_priority | LOG_INFO, mbuf); + syslog (log_priority | LOG_INFO, "%s", mbuf); #endif =20 if (log_perror) { @@ -156,7 +156,7 @@ va_end (list); =20 #ifndef DEBUG - syslog (log_priority | LOG_DEBUG, mbuf); + syslog (log_priority | LOG_DEBUG, "%s", mbuf); #endif =20 if (log_perror) { @@ -231,8 +231,8 @@ va_end (list); =20 #ifndef DEBUG - syslog (log_priority | LOG_ERR, mbuf); - syslog (log_priority | LOG_ERR, token_line); + syslog (log_priority | LOG_ERR, "%s", mbuf); + syslog (log_priority | LOG_ERR, "%s", token_line); if (lexline < 81) syslog (log_priority | LOG_ERR, "%s^", &spaces [sizeof spaces - lexchar]); Index: common/print.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/contrib/isc-dhcp/common/print.c,v retrieving revision 1.1.1.3 diff -u -r1.1.1.3 print.c --- common/print.c 1999/02/28 20:34:39 1.1.1.3 +++ common/print.c 2001/04/25 10:13:19 @@ -150,7 +150,7 @@ for (i =3D 0; i < len; i++) { if ((i & 15) =3D=3D 0) { if (lbix) - note (lbuf); + note ("%s", lbuf); sprintf (lbuf, "%03x:", i); lbix =3D 4; } else if ((i & 7) =3D=3D 0) @@ -158,7 +158,7 @@ sprintf (&lbuf [lbix], " %02x", buf [i]); lbix +=3D 3; } - note (lbuf); + note ("%s", lbuf); } =20 void hash_dump (table) @@ -178,7 +178,7 @@ if (bp -> len) dump_raw (bp -> name, bp -> len); else - note ((char *)bp -> name); + note ("%s", (char *)bp -> name); } } } Index: common/tree.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/contrib/isc-dhcp/common/tree.c,v retrieving revision 1.1.1.1 diff -u -r1.1.1.1 tree.c --- common/tree.c 1999/02/10 09:10:13 1.1.1.1 +++ common/tree.c 2001/04/25 10:13:53 @@ -275,7 +275,7 @@ return t1; =20 default: - warn ("Bad node id in tree: %d."); + warn ("Bad node id in tree: %d.", tree -> op); t1 =3D MAX_TIME; return t1; } Index: includes/dhcpd.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/contrib/isc-dhcp/includes/dhcpd.h,v retrieving revision 1.1.1.6 diff -u -r1.1.1.6 dhcpd.h --- includes/dhcpd.h 2000/07/20 08:36:42 1.1.1.6 +++ includes/dhcpd.h 2001/04/25 10:11:24 @@ -487,11 +487,11 @@ =20 /* errwarn.c */ extern int warnings_occurred; -void error PROTO ((char *, ...)); -int warn PROTO ((char *, ...)); -int note PROTO ((char *, ...)); -int debug PROTO ((char *, ...)); -int parse_warn PROTO ((char *, ...)); +void error PROTO ((char *, ...)) __attribute__((format(printf, 1, 2))); +int warn PROTO ((char *, ...)) __attribute__((format(printf, 1, 2))); +int note PROTO ((char *, ...)) __attribute__((format(printf, 1, 2))); +int debug PROTO ((char *, ...)) __attribute__((format(printf, 1, 2))); +int parse_warn PROTO ((char *, ...)) __attribute__((format(printf, 1, 2))); =20 /* dhcpd.c */ extern TIME cur_time; @@ -905,7 +905,7 @@ char *, struct client_lease *)); int script_go PROTO ((struct interface_info *)); void client_envadd PROTO ((struct client_state *, - const char *, const char *, const char *, ...)); + const char *, const char *, const char *, ...)) __attribute__((forma= t(printf, 4, 5))); int dhcp_option_ev_name (char *, size_t, struct option *); =20 struct client_lease *packet_to_lease PROTO ((struct packet *)); --4Ckj6UjgE2iN1+kY 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 iD8DBQE65qemWry0BWjoQKURAnAjAKCf+kgrHOiai1nAm1fAbTIcL+EUXACgjlnn wZ8o6a8skPVk8hB2EQ/ipQ0= =U3Jf -----END PGP SIGNATURE----- --4Ckj6UjgE2iN1+kY-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 4:18:47 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 2A13C37B422 for ; Wed, 25 Apr 2001 04:18:40 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id C450766E1F; Wed, 25 Apr 2001 04:18:39 -0700 (PDT) Date: Wed, 25 Apr 2001 04:18:39 -0700 From: Kris Kennaway To: audit@FreeBSD.org Subject: pax mkstemp() fixes Message-ID: <20010425041839.C70021@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="6zdv2QT/q3FMhpsV" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --6zdv2QT/q3FMhpsV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable This is taken from OpenBSD. There are a lot of little style changes, typo fixes and gratuitous function renames which complicate the remaining diffs between the two versions; probably we should sync up with that, and then look at what's left (OpenBSD have maintained their pax(1) better than we have) Kris Index: extern.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/bin/pax/extern.h,v retrieving revision 1.8 diff -u -r1.8 extern.h --- extern.h 2001/04/17 07:46:37 1.8 +++ extern.h 2001/04/25 10:59:33 @@ -224,6 +224,9 @@ extern int docrc; extern char *dirptr; extern char *argv0; +extern char *tempfile; +extern char *tempbase; + int main __P((int, char **)); void sig_cleanup __P((int)); =20 Index: pax.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/bin/pax/pax.c,v retrieving revision 1.14 diff -u -r1.14 pax.c --- pax.c 2001/03/02 16:19:49 1.14 +++ pax.c 2001/04/25 11:05:47 @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -96,6 +97,8 @@ int docrc; /* check/create file crc */ char *dirptr; /* destination dir in a copy */ char *argv0; /* root of argv[0] */ +char *tempfile; /* tempfile to use for mkstemp(3) */ +char *tempbase; /* basename of tempfile to use for mkstemp(3) */ sigset_t s_mask; /* signal mask for cleanup critical sect */ =20 /* @@ -228,7 +231,29 @@ char **argv; #endif { + char *tmpdir; + size_t tdlen; + (void) setlocale(LC_ALL, ""); + + /* + * Where should we put temporary files? + */ + if ((tmpdir =3D getenv("TMPDIR")) =3D=3D NULL || *tmpdir =3D=3D '\0') + tmpdir =3D _PATH_TMP; + tdlen =3D strlen(tmpdir); + while(tdlen > 0 && tmpdir[tdlen - 1] =3D=3D '/') + tdlen--; + tempfile =3D malloc(tdlen + 1 + sizeof(_TFILE_BASE)); + if (tempfile =3D=3D NULL) { + pax_warn(1, "Cannot allocate memory for temp file name."); + return(exit_val); + } + if (tdlen) + memcpy(tempfile, tmpdir, tdlen); + tempbase =3D tempfile + tdlen; + *tempbase++ =3D '/'; + /* * parse options, determine operational mode, general init */ Index: pax.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/bin/pax/pax.h,v retrieving revision 1.8 diff -u -r1.8 pax.h --- pax.h 1999/08/27 23:14:45 1.8 +++ pax.h 2001/04/25 11:00:53 @@ -237,3 +237,4 @@ #define HEX 16 #define OCT 8 #define _PAX_ 1 +#define _TFILE_BASE "paxXXXXXXXXXX" Index: tables.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/bin/pax/tables.c,v retrieving revision 1.13 diff -u -r1.13 tables.c --- tables.c 1999/08/27 23:14:46 1.13 +++ tables.c 2001/04/25 11:14:09 @@ -360,8 +360,6 @@ ftime_start() #endif { - char *pt; - if (ftab !=3D NULL) return(0); if ((ftab =3D (FTM **)calloc(F_TAB_SZ, sizeof(FTM *))) =3D=3D NULL) { @@ -373,16 +371,14 @@ * get random name and create temporary scratch file, unlink name * so it will get removed on exit */ - if ((pt =3D tempnam((char *)NULL, (char *)NULL)) =3D=3D NULL) - return(-1); - (void)unlink(pt); - - if ((ffd =3D open(pt, O_RDWR | O_CREAT, S_IRWXU)) < 0) { - sys_warn(1, errno, "Unable to open temporary file: %s", pt); + memcpy(tempbase, _TFILE_BASE, sizeof(_TFILE_BASE)); + if ((ffd =3D mkstemp(tempfile)) < 0) { + sys_warn(1, errno, "Unable to create temporary file: %s", + tempfile); return(-1); } + (void)unlink(tempfile); =20 - (void)unlink(pt); return(0); } =20 @@ -1210,22 +1206,19 @@ dir_start() #endif { - char *pt; - if (dirfd !=3D -1) return(0); - if ((pt =3D tempnam((char *)NULL, (char *)NULL)) =3D=3D NULL) - return(-1); =20 /* * unlink the file so it goes away at termination by itself */ - (void)unlink(pt); - if ((dirfd =3D open(pt, O_RDWR|O_CREAT, 0600)) >=3D 0) { - (void)unlink(pt); + memcpy(tempbase, _TFILE_BASE, sizeof(_TFILE_BASE)); + if ((dirfd =3D mkstemp(tempfile)) >=3D 0) { + (void)unlink(tempfile); return(0); } - pax_warn(1, "Unable to create temporary file for directory times: %s", pt= ); + pax_warn(1, "Unable to create temporary file for directory times: %s", + tempfile); return(-1); } =20 --6zdv2QT/q3FMhpsV 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 iD8DBQE65rKOWry0BWjoQKURAvGKAJ96RgxVFaBqDJSzA2K5mg76wuGAzQCeIMlb Ll2iGldWIsIe/sKy9gH44qI= =DMF5 -----END PGP SIGNATURE----- --6zdv2QT/q3FMhpsV-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 10:57: 8 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 7279437B42C for ; Wed, 25 Apr 2001 10:57:05 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3PHvXI38596 for ; Wed, 25 Apr 2001 13:57:34 -0400 (EDT) (envelope-from arr@watson.org) Date: Wed, 25 Apr 2001 13:57:33 -0400 (EDT) From: "Andrew R. Reiter" To: freebsd-audit@freebsd.org Subject: audit work: more setenv checking 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 hi, after quickly fixing the kerberosIV setenv() calls, I just grep'd for setenv() and found a couple in libutil's login_class.c. in the patch, I handle alittle bit of some free()'ing of allocated space, but I'd enjoy someone who has done a bit more work with libutil to check it out. the patch is at: http://www.watson.org/~arr/fbsd-audit/lib/libutil/login_class.c.04252001.diff thanks, Andrew *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 11: 2:42 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 0348A37B422 for ; Wed, 25 Apr 2001 11:02:38 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3PI38x38685 for ; Wed, 25 Apr 2001 14:03:08 -0400 (EDT) (envelope-from arr@watson.org) Date: Wed, 25 Apr 2001 14:03:08 -0400 (EDT) From: "Andrew R. Reiter" To: freebsd-audit@FreeBSD.ORG Subject: Re: more audit work... chpass (openbsd sync) In-Reply-To: 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 Just wondering if this got patched? :-) On Mon, 16 Apr 2001, Andrew R. Reiter wrote: > hi, > > attached is another diff for chpass to disallow non-printables in the > passwd file. this is another obsd sync up. > > you can also find the diff at > www.watson.org/~arr/fbsd-audit/usr.bin/chpass/ > > andrew > > *-------------................................................. > | Andrew R. Reiter > | arr@fledge.watson.org > | "It requires a very unusual mind > | to undertake the analysis of the obvious" -- A.N. Whitehead > *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 12:44: 7 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 A92B137B424 for ; Wed, 25 Apr 2001 12:44:05 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 4258966DF6; Wed, 25 Apr 2001 12:44:05 -0700 (PDT) Date: Wed, 25 Apr 2001 12:44:05 -0700 From: Kris Kennaway To: "Andrew R. Reiter" Cc: freebsd-audit@FreeBSD.ORG Subject: Re: more audit work... chpass (openbsd sync) Message-ID: <20010425124405.M78153@xor.obsecurity.org> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="Kc9HNjpzOXVc7FFU" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from arr@watson.org on Wed, Apr 25, 2001 at 02:03:08PM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Kc9HNjpzOXVc7FFU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 25, 2001 at 02:03:08PM -0400, Andrew R. Reiter wrote: > Just wondering if this got patched? :-) Not yet, I'm not familiar with isprint() and how it relates to things like I18N. Someone else should review this one. Kris --Kc9HNjpzOXVc7FFU 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 iD8DBQE65ykEWry0BWjoQKURArvYAKDPwHJ8kqNFxxHRI02p+iT7Xh+YXACg3zaL vUdDcMcjxeq83JiK4gHJa9Y= =yoLc -----END PGP SIGNATURE----- --Kc9HNjpzOXVc7FFU-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Wed Apr 25 14:30:20 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 D9BAF37B423 for ; Wed, 25 Apr 2001 14:30:16 -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 f3PLUFu231925; Wed, 25 Apr 2001 17:30:16 -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 <0GCD00F4TAEFLQ@gkar.cc.vt.edu>; Wed, 25 Apr 2001 17:30:15 -0400 (EDT) Date: Wed, 25 Apr 2001 17:29:42 -0400 (EDT) From: Mike Heffner Subject: RE: pax mkstemp() fixes In-reply-to: <20010425041839.C70021@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:20010425172942:436=_"; 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:20010425172942:436=_ Content-Type: text/plain; charset=us-ascii Looks good. Any reason to use memcpy over str[ln]cpy? On 25-Apr-2001 Kris Kennaway wrote: | This is taken from OpenBSD. There are a lot of little style changes, | typo fixes and gratuitous function renames which complicate the | remaining diffs between the two versions; probably we should sync up | with that, and then look at what's left (OpenBSD have maintained their | pax(1) better than we have) Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010425172942:436=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE650HGFokZQs3sv5kRArNYAKCEiHRqdPUgA2Rx0iueXUMWiGnF+wCePrTK IEWskBpQr41TfqobXOOMyKY= =CM6u -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010425172942:436=_-- 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 Wed Apr 25 14:44:52 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 533EC37B423; Wed, 25 Apr 2001 14:44:48 -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 f3PLilu235216; Wed, 25 Apr 2001 17:44:47 -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 <0GCD00GK3B2MZD@gkar.cc.vt.edu>; Wed, 25 Apr 2001 17:44:46 -0400 (EDT) Date: Wed, 25 Apr 2001 17:44:13 -0400 (EDT) From: Mike Heffner Subject: Re: GNATS tempfile patch In-reply-to: <20010425023740.C54713@xor.obsecurity.org> To: Kris Kennaway Cc: bug-gnats@gnu.org, pst@FreeBSD.ORG, 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:20010425174413:436=_"; 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:20010425174413:436=_ Content-Type: text/plain; charset=us-ascii On 25-Apr-2001 Kris Kennaway wrote: | ..and here's part II, fixing the C code to use mkstemp() if available, | instead of mktemp(). Please review, etc. | | --- gnats/cmds.c.orig Wed Mar 17 15:45:36 1999 | +++ gnats/cmds.c Wed Apr 25 02:24:59 2001 | @@ -121,19 +121,33 @@ [snip] | +#ifdef HAVE_MKSTEMP | + if ((tf = fdopen (fd, "w")) == (FILE *) NULL) | +#else | if ((tf = fopen (path, "w")) == (FILE *) NULL) | +#endif If we're using mkstemp(), we could get here and the fdopen() could fail, but we still have created the tempfile. I think there needs to be an unlink() within #ifdef HAVE_MKSTEMP to remove the file on failure. | --- gnats/internal.c.orig Tue Mar 2 16:18:53 1999 | +++ gnats/internal.c Wed Apr 25 02:24:45 2001 | @@ -36,20 +36,38 @@ [snip] | +#ifdef HAVE_MKSTEMP | + fp = fdopen (fd, "w"); | +#else | fp = fopen (workfile, "w"); | +#endif | if (fp == NULL) Same here. Otherwise, looks good =) Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010425174413:436=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE650UtFokZQs3sv5kRAq4qAJ9nQlVphhFDDatZQTBnyTyaOcDvpACgjeou XegNmcQYZC4wF5LL1h/Qpbo= =b5I7 -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010425174413:436=_-- 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 Wed Apr 25 15:26:49 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 3E5D737B43E for ; Wed, 25 Apr 2001 15:26:46 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3PMRGU42882 for ; Wed, 25 Apr 2001 18:27:17 -0400 (EDT) (envelope-from arr@watson.org) Date: Wed, 25 Apr 2001 18:27:16 -0400 (EDT) From: "Andrew R. Reiter" To: freebsd-audit@FreeBSD.org Subject: audit work: libc's setenv() and putenv() Message-ID: MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-651953887-988237636=:42833" Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-651953887-988237636=:42833 Content-Type: TEXT/PLAIN; charset=US-ASCII hi, i found a small stupid issue with putenv() in our libc, as well as OpenBSD's... basically if you do: putenv("=bleh"); /* incorrect usage */ it will not return a -1 error value, but instead return 0. Attached is a patch which does a couple of fixes: - assertion (not using assert()) checks on the arguments being passed to setenv and putenv because both with core if any of the const char *'s are NULL. - assertion checks on values being passed to setenv() from putenv(). I was kind of uncertain as to whether or not such assertion checks should be done in the libc code, but I found some sanity checks in other functions so I figured it was "OK." Anyway, the diff is attached, but can also be found at: http://www.watson.org/~arr/fbsd-audit/lib/libc/stdlib/ Thoughts? Andrew *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead --0-651953887-988237636=:42833 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="environ.04252001.diff" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: LS0tIHB1dGVudi5jLm9yaWcJV2VkIEFwciAyNSAxMzozMTo0MiAyMDAxDQor KysgcHV0ZW52LmMJV2VkIEFwciAyNSAxNDoxNDoyNiAyMDAxDQpAQCAtNDUs NiArNDUsOCBAQA0KIAljaGFyICpwLCAqZXF1YWw7DQogCWludCBydmFsOw0K IA0KKwlpZiAoc3RyID09IE5VTEwpDQorCQlyZXR1cm4oLTEpOw0KIAlpZiAo KHAgPSBzdHJkdXAoc3RyKSkgPT0gTlVMTCkNCiAJCXJldHVybiAoLTEpOw0K IAlpZiAoKGVxdWFsID0gaW5kZXgocCwgJz0nKSkgPT0gTlVMTCkgew0KQEAg LTUyLDYgKzU0LDggQEANCiAJCXJldHVybiAoLTEpOw0KIAl9DQogCSplcXVh bCA9ICdcMCc7DQorCWlmIChzdHJsZW4ocCkgPT0gMCB8fCBzdHJsZW4oZXF1 YWwgKyAxKSA9PSAwKQ0KKwkJcmV0dXJuKC0xKTsNCiAJcnZhbCA9IHNldGVu dihwLCBlcXVhbCArIDEsIDEpOw0KIAkodm9pZClmcmVlKHApOw0KIAlyZXR1 cm4gKHJ2YWwpOw0KLS0tIHNldGVudi5jLm9yaWcJV2VkIEFwciAyNSAxMzo0 MzoyMSAyMDAxDQorKysgc2V0ZW52LmMJV2VkIEFwciAyNSAxMzo0NjoyNyAy MDAxDQpAQCAtNjAsNiArNjAsOSBAQA0KIAlyZWdpc3RlciBjaGFyICpjOw0K IAlpbnQgbF92YWx1ZSwgb2Zmc2V0Ow0KIA0KKwlpZiAobmFtZSA9PSBOVUxM IHx8IHZhbHVlID09IE5VTEwpDQorIAkJcmV0dXJuKC0xKTsNCisNCiAJaWYg KCp2YWx1ZSA9PSAnPScpCQkJLyogbm8gYD0nIGluIHZhbHVlICovDQogCQkr K3ZhbHVlOw0KIAlsX3ZhbHVlID0gc3RybGVuKHZhbHVlKTsNCg== --0-651953887-988237636=:42833-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 0:25: 3 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 809A037B422 for ; Thu, 26 Apr 2001 00:25:00 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id ADFC266E1F; Thu, 26 Apr 2001 00:24:59 -0700 (PDT) Date: Thu, 26 Apr 2001 00:24:59 -0700 From: Kris Kennaway To: Mike Heffner Cc: Kris Kennaway , audit@FreeBSD.org Subject: Re: pax mkstemp() fixes Message-ID: <20010426002459.A88389@xor.obsecurity.org> References: <20010425041839.C70021@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="pf9I7BMVVzbSWLtt" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from mheffner@vt.edu on Wed, Apr 25, 2001 at 05:29:42PM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 25, 2001 at 05:29:42PM -0400, Mike Heffner wrote: > Looks good. Any reason to use memcpy over str[ln]cpy? OpenBSD did it that way; I don't know why. Kris --pf9I7BMVVzbSWLtt 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 iD8DBQE6581LWry0BWjoQKURAnSqAJ9FMNvNIuxrG7ENZtHlkfSVMwAqEACghveK bnIRGsS6sDD/108U/TiAXmI= =CpwK -----END PGP SIGNATURE----- --pf9I7BMVVzbSWLtt-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 0:27:46 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 7D3A137B423 for ; Thu, 26 Apr 2001 00:27:44 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 289E466DF6; Thu, 26 Apr 2001 00:27:44 -0700 (PDT) Date: Thu, 26 Apr 2001 00:27:44 -0700 From: Kris Kennaway To: Kris Kennaway Cc: Mike Heffner , audit@FreeBSD.ORG Subject: Re: pax mkstemp() fixes Message-ID: <20010426002743.B88389@xor.obsecurity.org> References: <20010425041839.C70021@xor.obsecurity.org> <20010426002459.A88389@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="+g7M9IMkV8truYOl" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010426002459.A88389@xor.obsecurity.org>; from kris@obsecurity.org on Thu, Apr 26, 2001 at 12:24:59AM -0700 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --+g7M9IMkV8truYOl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 26, 2001 at 12:24:59AM -0700, Kris Kennaway wrote: > On Wed, Apr 25, 2001 at 05:29:42PM -0400, Mike Heffner wrote: > > Looks good. Any reason to use memcpy over str[ln]cpy? >=20 > OpenBSD did it that way; I don't know why. I should note that one of my goals here is to minimize the diffs with OpenBSD; there's currently a lot of gratuitous stuff, and quite a few feature additions and fixes. Kris --+g7M9IMkV8truYOl 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 iD8DBQE6583vWry0BWjoQKURApqeAJoDYalTV8yAZu2IRy7UaX1r3AsukwCg6Rzu 75ABRQATFQZydW2eZq2oe+g= =U9iH -----END PGP SIGNATURE----- --+g7M9IMkV8truYOl-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 0:30:54 2001 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id E154E37B422 for ; Thu, 26 Apr 2001 00:30:50 -0700 (PDT) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f3Q7USQ13483; Thu, 26 Apr 2001 10:30:28 +0300 (EEST) (envelope-from ru) Date: Thu, 26 Apr 2001 10:30:28 +0300 From: Ruslan Ermilov To: Kris Kennaway Cc: Mike Heffner , audit@FreeBSD.ORG Subject: Re: pax mkstemp() fixes Message-ID: <20010426103028.A13304@sunbay.com> References: <20010425041839.C70021@xor.obsecurity.org> <20010426002459.A88389@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010426002459.A88389@xor.obsecurity.org>; from kris@obsecurity.org on Thu, Apr 26, 2001 at 12:24:59AM -0700 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Apr 26, 2001 at 12:24:59AM -0700, Kris Kennaway wrote: > On Wed, Apr 25, 2001 at 05:29:42PM -0400, Mike Heffner wrote: > > Looks good. Any reason to use memcpy over str[ln]cpy? > > OpenBSD did it that way; I don't know why. > Because strlcpy(3) is non-standard, I think. -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 1:12:59 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 52AE937B422; Thu, 26 Apr 2001 01:12:56 -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 f3Q8Cm832058; Thu, 26 Apr 2001 02:12:48 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200104260812.f3Q8Cm832058@harmony.village.org> To: Ruslan Ermilov Subject: Re: pax mkstemp() fixes Cc: Kris Kennaway , Mike Heffner , audit@FreeBSD.org In-reply-to: Your message of "Thu, 26 Apr 2001 10:30:28 +0300." <20010426103028.A13304@sunbay.com> References: <20010426103028.A13304@sunbay.com> <20010425041839.C70021@xor.obsecurity.org> <20010426002459.A88389@xor.obsecurity.org> Date: Thu, 26 Apr 2001 02:12:48 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <20010426103028.A13304@sunbay.com> Ruslan Ermilov writes: : On Thu, Apr 26, 2001 at 12:24:59AM -0700, Kris Kennaway wrote: : > On Wed, Apr 25, 2001 at 05:29:42PM -0400, Mike Heffner wrote: : > > Looks good. Any reason to use memcpy over str[ln]cpy? : > : > OpenBSD did it that way; I don't know why. : > : Because strlcpy(3) is non-standard, I think. I doubt that. OpenBSD invented strlcpy and haven't been shy about using it. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 2:54:50 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 9765337B424; Thu, 26 Apr 2001 02:54:26 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id EAFA166DF6; Thu, 26 Apr 2001 02:54:25 -0700 (PDT) Date: Thu, 26 Apr 2001 02:54:25 -0700 From: Kris Kennaway To: hackers@FreeBSD.org Cc: audit@FreeBSD.org Subject: pax(1) gzip functionality Message-ID: <20010426025425.A92262@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="PEIAKu/WMn1b1Hv9" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --PEIAKu/WMn1b1Hv9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi all, Please review the following code from OpenBSD; it adds -z and -Z options to pax(1) to gzip(1) the archives created. Kris Index: ar_io.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: /home/ncvs/src/bin/pax/ar_io.c,v retrieving revision 1.14 diff -u -r1.14 ar_io.c --- ar_io.c 2001/04/26 09:22:27 1.14 +++ ar_io.c 2001/04/26 09:52:32 @@ -44,16 +44,18 @@ #endif /* not lint */ =20 #include -#include #include #include -#include -#include +#include +#include +#include +#include #include -#include +#include #include -#include +#include #include +#include #include "pax.h" #include "extern.h" =20 @@ -79,9 +81,12 @@ static int wr_trail =3D 1; /* trailer was rewritten in append */ static int can_unlnk =3D 0; /* do we unlink null archives? */ char *arcname; /* printable name of archive */ +const char *gzip_program; /* name of gzip program */ +static pid_t zpid =3D -1; /* pid of child process */ =20 static int get_phys __P((void)); extern sigset_t s_mask; +static void ar_start_gzip __P((int, const char *, int)); =20 /* * ar_open() @@ -121,6 +126,8 @@ arcname =3D STDN; } else if ((arfd =3D open(name, EXT_MODE, DMOD)) < 0) syswarn(0, errno, "Failed open to read on %s", name); + if (arfd !=3D -1 && gzip_program !=3D NULL) + ar_start_gzip(arfd, gzip_program, 0); break; case ARCHIVE: if (name =3D=3D NULL) { @@ -130,6 +137,8 @@ syswarn(0, errno, "Failed open to write on %s", name); else can_unlnk =3D 1; + if (arfd !=3D -1 && gzip_program !=3D NULL) + ar_start_gzip(arfd, gzip_program, 1); break; case APPND: if (name =3D=3D NULL) { @@ -335,6 +344,16 @@ can_unlnk =3D 0; } =20 + /* + * for a quick extract/list, pax frequently exits before the child + * process is done + */ + if ((act =3D=3D LIST || act =3D=3D EXTRACT) && nflag && zpid > 0) { + int status; + kill(zpid, SIGINT); + waitpid(zpid, &status, 0); + } + (void)close(arfd); =20 if (vflag && (artyp =3D=3D ISTAPE)) { @@ -1286,4 +1305,47 @@ continue; } return(0); +} + +/* + * ar_start_gzip() + * starts the gzip compression/decompression process as a child, using mag= ic + * to keep the fd the same in the calling function (parent). + */ +void +ar_start_gzip(int fd, const char *gzip_program, int wr) +{ + int fds[2]; + char *gzip_flags; + + if (pipe(fds) < 0) + err(1, "could not pipe"); + zpid =3D fork(); + if (zpid < 0) + err(1, "could not fork"); + + /* parent */ + if (zpid) { + if (wr) + dup2(fds[1], fd); + else + dup2(fds[0], fd); + close(fds[0]); + close(fds[1]); + } else { + if (wr) { + dup2(fds[0], STDIN_FILENO); + dup2(fd, STDOUT_FILENO); + gzip_flags =3D "-c"; + } else { + dup2(fds[1], STDOUT_FILENO); + dup2(fd, STDIN_FILENO); + gzip_flags =3D "-dc"; + } + close(fds[0]); + close(fds[1]); + if (execlp(gzip_program, gzip_program, gzip_flags, NULL) < 0) + err(1, "could not exec"); + /* NOTREACHED */ + } } Index: extern.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: /home/ncvs/src/bin/pax/extern.h,v retrieving revision 1.10 diff -u -r1.10 extern.h --- extern.h 2001/04/26 08:37:00 1.10 +++ extern.h 2001/04/26 09:52:32 @@ -48,6 +48,7 @@ * ar_io.c */ extern char *arcname; +extern const char *gzip_program; int ar_open __P((char *)); void ar_close __P((void)); void ar_drain __P((void)); Index: options.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: /home/ncvs/src/bin/pax/options.c,v retrieving revision 1.17 diff -u -r1.17 options.c --- options.c 2001/04/26 09:22:28 1.17 +++ options.c 2001/04/26 09:52:32 @@ -78,6 +78,9 @@ static void cpio_usage __P((void)); #endif =20 +#define GZIP_CMD "gzip" /* command to run as gzip */ +#define COMPRESS_CMD "compress" /* command to run as compress */ + /* * Format specific routine table - MUST BE IN SORTED ORDER BY NAME * (see pax.h for description of each function) @@ -192,7 +195,7 @@ /* * process option flags */ - while ((c=3Dgetopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:B:DE:G:HLPT:U:XYZ")) + while ((c=3Dgetopt(argc,argv,"ab:cdf:iklno:p:rs:tuvwx:zB:DE:G:HLPT:U:XYZ"= )) !=3D -1) { switch (c) { case 'a': @@ -376,6 +379,12 @@ (void)fputs("\n\n", stderr); pax_usage(); break; + case 'z': + /* + * use gzip. Non standard option. + */ + gzip_program =3D GZIP_CMD; + break; case 'B': /* * non-standard option on number of bytes written on a @@ -694,6 +703,12 @@ */ act =3D EXTRACT; break; + case 'z': + /* + * use gzip. Non standard option. + */ + gzip_program =3D GZIP_CMD; + break; case 'B': /* * Nothing to do here, this is pax default @@ -723,6 +738,12 @@ */ Xflag =3D 1; break; + case 'Z': + /* + * use compress. + */ + gzip_program =3D COMPRESS_CMD; + break; case '0': arcname =3D DEV_0; break; @@ -1075,18 +1096,18 @@ pax_usage() #endif { - (void)fputs("usage: pax [-cdnv] [-E limit] [-f archive] ", stderr); + (void)fputs("usage: pax [-cdnvz] [-E limit] [-f archive] ", stderr); (void)fputs("[-s replstr] ... [-U user] ...", stderr); (void)fputs("\n [-G group] ... ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs("[pattern ...]\n", stderr); - (void)fputs(" pax -r [-cdiknuvDYZ] [-E limit] ", stderr); + (void)fputs(" pax -r [-cdiknuvzDYZ] [-E limit] ", stderr); (void)fputs("[-f archive] [-o options] ... \n", stderr); (void)fputs(" [-p string] ... [-s replstr] ... ", stderr); (void)fputs("[-U user] ... [-G group] ...\n ", stderr); (void)fputs("[-T [from_date][,to_date]] ... ", stderr); (void)fputs(" [pattern ...]\n", stderr); - (void)fputs(" pax -w [-dituvHLPX] [-b blocksize] ", stderr); + (void)fputs(" pax -w [-dituvzHLPX] [-b blocksize] ", stderr); (void)fputs("[ [-a] [-f archive] ] [-x format] \n", stderr); (void)fputs(" [-B bytes] [-s replstr] ... ", stderr); (void)fputs("[-o options] ... [-U user] ...", stderr); @@ -1114,7 +1135,7 @@ tar_usage() #endif { - (void)fputs("usage: tar -{txru}[cevfbmopwBHLPX014578] [tapefile] ", + (void)fputs("usage: tar -{txru}[cevfbmopwzBHLPXZ014578] [tapefile] ", stderr); (void)fputs("[blocksize] file1 file2...\n", stderr); exit(1); Index: pax.1 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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: /home/ncvs/src/bin/pax/pax.1,v retrieving revision 1.16 diff -u -r1.16 pax.1 --- pax.1 2001/02/13 09:50:27 1.16 +++ pax.1 2001/04/26 09:52:33 @@ -44,7 +44,7 @@ .Nd read and write file archives and copy directory hierarchies .Sh SYNOPSIS .Nm -.Op Fl cdnv +.Op Fl cdnvz .Bk -words .Op Fl f Ar archive .Ek @@ -71,7 +71,7 @@ .Op Ar pattern ...\& .Nm .Fl r -.Op Fl cdiknuvDYZ +.Op Fl cdiknuvzDYZ .Bk -words .Op Fl f Ar archive .Ek @@ -107,7 +107,7 @@ .Op Ar pattern ...\& .Nm .Fl w -.Op Fl dituvHLPX +.Op Fl dituvzHLPX .Bk -words .Op Fl b Ar blocksize .Ek @@ -756,6 +756,12 @@ The individual archive formats may impose additional restrictions on use. Typical archive format restrictions include (but are not limited to): file pathname length, file size, link pathname length and the type of the = file. +.It Fl z +Use +.Xr gzip 1 +to compress (decompress) the archive while writing (reading). +Incompatible with +.Fl a . .It Fl B Ar bytes Limit the number of bytes written to a single archive volume to .Ar bytes . Index: pax.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: /home/ncvs/src/bin/pax/pax.c,v retrieving revision 1.17 diff -u -r1.17 pax.c --- pax.c 2001/04/26 09:22:28 1.17 +++ pax.c 2001/04/26 09:52:33 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -272,6 +273,8 @@ archive(); break; case APPND: + if (gzip_program !=3D NULL) + err(1, "can not gzip while appending"); append(); break; case COPY: --PEIAKu/WMn1b1Hv9 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 iD8DBQE65/BRWry0BWjoQKURAnUYAJsGTDfFtQkbK0iWnjNZKh5Dkh9tDgCg0YfW wBpGzhlNrd6YPWTrApsQJWc= =ADf+ -----END PGP SIGNATURE----- --PEIAKu/WMn1b1Hv9-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 8:21:56 2001 Delivered-To: freebsd-audit@freebsd.org Received: from dragon.nuxi.com (trang.nuxi.com [209.152.133.57]) by hub.freebsd.org (Postfix) with ESMTP id 95BB237B422; Thu, 26 Apr 2001 08:21:52 -0700 (PDT) (envelope-from obrien@NUXI.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.11.3/8.11.1) id f3QFLY473071; Thu, 26 Apr 2001 08:21:34 -0700 (PDT) (envelope-from obrien) Date: Thu, 26 Apr 2001 08:21:33 -0700 From: "David O'Brien" To: Kris Kennaway Cc: hackers@FreeBSD.org, audit@FreeBSD.org Subject: Re: pax(1) gzip functionality Message-ID: <20010426082133.B72609@dragon.nuxi.com> Reply-To: obrien@FreeBSD.org References: <20010426025425.A92262@xor.obsecurity.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010426025425.A92262@xor.obsecurity.org>; from kris@obsecurity.org on Thu, Apr 26, 2001 at 02:54:25AM -0700 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Apr 26, 2001 at 02:54:25AM -0700, Kris Kennaway wrote: > Please review the following code from OpenBSD; it adds -z and -Z > options to pax(1) to gzip(1) the archives created. Sigh. They could have generalized this just a little and supported Bzip2 at the same time. Please let me know after you commit this so I can do this. -- -- David (obrien@FreeBSD.org) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 8:41:58 2001 Delivered-To: freebsd-audit@freebsd.org Received: from Awfulhak.org (awfulhak.demon.co.uk [194.222.196.252]) by hub.freebsd.org (Postfix) with ESMTP id E102B37B423; Thu, 26 Apr 2001 08:41:52 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.3/8.11.3) with ESMTP id f3QFfY319403; Thu, 26 Apr 2001 16:41:34 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.3/8.11.3) with ESMTP id f3QFgiM61575; Thu, 26 Apr 2001 16:42:44 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200104261542.f3QFgiM61575@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: obrien@FreeBSD.ORG Cc: Kris Kennaway , hackers@FreeBSD.ORG, audit@FreeBSD.ORG, brian@Awfulhak.org Subject: Re: pax(1) gzip functionality In-Reply-To: Message from "David O'Brien" of "Thu, 26 Apr 2001 08:21:33 PDT." <20010426082133.B72609@dragon.nuxi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 26 Apr 2001 16:42:44 +0100 From: Brian Somers Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > On Thu, Apr 26, 2001 at 02:54:25AM -0700, Kris Kennaway wrote: > > Please review the following code from OpenBSD; it adds -z and -Z > > options to pax(1) to gzip(1) the archives created. > > Sigh. They could have generalized this just a little and supported Bzip2 > at the same time. Please let me know after you commit this so I can do > this. Is this necessary ? What's the problem with using a pipe ? Isn't this the same argument as the xargs one we've just gotten through ? Maybe I'm missing something... > -- > -- David (obrien@FreeBSD.org) -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 10: 1:36 2001 Delivered-To: freebsd-audit@freebsd.org Received: from dragon.nuxi.com (trang.nuxi.com [209.152.133.57]) by hub.freebsd.org (Postfix) with ESMTP id 05CC337B422; Thu, 26 Apr 2001 10:01:32 -0700 (PDT) (envelope-from obrien@NUXI.com) Received: (from obrien@localhost) by dragon.nuxi.com (8.11.3/8.11.1) id f3QH0bw89420; Thu, 26 Apr 2001 10:00:37 -0700 (PDT) (envelope-from obrien) Date: Thu, 26 Apr 2001 10:00:37 -0700 From: "David O'Brien" To: Brian Somers Cc: Kris Kennaway , hackers@FreeBSD.ORG, audit@FreeBSD.ORG Subject: Re: pax(1) gzip functionality Message-ID: <20010426100037.C84210@dragon.nuxi.com> Reply-To: obrien@FreeBSD.ORG References: <200104261542.f3QFgiM61575@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200104261542.f3QFgiM61575@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Thu, Apr 26, 2001 at 04:42:44PM +0100 X-Operating-System: FreeBSD 5.0-CURRENT Organization: The NUXI BSD group X-Pgp-Rsa-Fingerprint: B7 4D 3E E9 11 39 5F A3 90 76 5D 69 58 D9 98 7A X-Pgp-Rsa-Keyid: 1024/34F9F9D5 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Thu, Apr 26, 2001 at 04:42:44PM +0100, Brian Somers wrote: > > On Thu, Apr 26, 2001 at 02:54:25AM -0700, Kris Kennaway wrote: > > > Please review the following code from OpenBSD; it adds -z and -Z > > > options to pax(1) to gzip(1) the archives created. > > > > Sigh. They could have generalized this just a little and supported Bzip2 > > at the same time. Please let me know after you commit this so I can do > > this. > > Is this necessary ? What's the problem with using a pipe ? Isn't > this the same argument as the xargs one we've just gotten through ? What's wrong with: tar cf - foo | gzip >foo.tar.gz gzip -dc foo.tar.gz | tar xf - Someone deemed them too inconvient for the number of times they are invoked. I'm not going to enter that discussion, but _if_ gzip support is added, I feel bzip2 support should be added to be orthogonal with today's uses. -- -- David (obrien@FreeBSD.org) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 11:22:50 2001 Delivered-To: freebsd-audit@freebsd.org Received: from Awfulhak.org (awfulhak.demon.co.uk [194.222.196.252]) by hub.freebsd.org (Postfix) with ESMTP id A531137B424; Thu, 26 Apr 2001 11:22:42 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from hak.lan.Awfulhak.org (root@hak.lan.Awfulhak.org [172.16.0.12]) by Awfulhak.org (8.11.3/8.11.3) with ESMTP id f3QIML324417; Thu, 26 Apr 2001 19:22:21 +0100 (BST) (envelope-from brian@lan.Awfulhak.org) Received: from hak.lan.Awfulhak.org (brian@localhost [127.0.0.1]) by hak.lan.Awfulhak.org (8.11.3/8.11.3) with ESMTP id f3QINUM63571; Thu, 26 Apr 2001 19:23:30 +0100 (BST) (envelope-from brian@hak.lan.Awfulhak.org) Message-Id: <200104261823.f3QINUM63571@hak.lan.Awfulhak.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: obrien@FreeBSD.ORG Cc: Brian Somers , Kris Kennaway , hackers@FreeBSD.ORG, audit@FreeBSD.ORG, brian@Awfulhak.org Subject: Re: pax(1) gzip functionality In-Reply-To: Message from "David O'Brien" of "Thu, 26 Apr 2001 10:00:37 PDT." <20010426100037.C84210@dragon.nuxi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 26 Apr 2001 19:23:30 +0100 From: Brian Somers Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > On Thu, Apr 26, 2001 at 04:42:44PM +0100, Brian Somers wrote: > > > On Thu, Apr 26, 2001 at 02:54:25AM -0700, Kris Kennaway wrote: > > > > Please review the following code from OpenBSD; it adds -z and -Z > > > > options to pax(1) to gzip(1) the archives created. > > > > > > Sigh. They could have generalized this just a little and supported Bzip2 > > > at the same time. Please let me know after you commit this so I can do > > > this. > > > > Is this necessary ? What's the problem with using a pipe ? Isn't > > this the same argument as the xargs one we've just gotten through ? > > What's wrong with: > tar cf - foo | gzip >foo.tar.gz > gzip -dc foo.tar.gz | tar xf - > > Someone deemed them too inconvient for the number of times they are > invoked. I'm not going to enter that discussion, but _if_ gzip support > is added, I feel bzip2 support should be added to be orthogonal with > today's uses. Agreed. > -- > -- David (obrien@FreeBSD.org) -- Brian Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 12: 4:38 2001 Delivered-To: freebsd-audit@freebsd.org Received: from hsaloubh01.hsacorp.net (63-93-158-26.hsacorp.net [63.93.158.26]) by hub.freebsd.org (Postfix) with ESMTP id 298C337B423 for ; Thu, 26 Apr 2001 12:04:36 -0700 (PDT) (envelope-from BKellerman@hsacorp.net) Received: by HSALOUBH01 with Internet Mail Service (5.5.2650.21) id ; Thu, 26 Apr 2001 15:01:19 -0400 Message-ID: <0D4982E5B3BED411910A00034708D24D31B6F2@hsaloumx01.hsacorp.net> From: "Kellerman, Bert" To: "'freebsd-audit@freebsd.org'" Subject: some mbox fixes Date: Thu, 26 Apr 2001 15:03:13 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hello, Here are some patches using obsd fixes from Kris' mbox. I am new so let me know if everything looks good. For consistency, I am using the same filename format as Andrew Reiter. http://24.130.180.121/freebsd-audit/sbin/ping/ping.c.04252001.diff Message-Id: <200012210025.eBL0PII23790@cvs.openbsd.org> http://24.130.180.121/freebsd-audit/usr.bin/tftp/tftp.c.04252001.diff Message-Id: <200012071813.eB7IDFI14188@cvs.openbsd.org> Thanks! Bert To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 12:18:54 2001 Delivered-To: freebsd-audit@freebsd.org Received: from big.endian.de (big.endian.de [194.145.150.69]) by hub.freebsd.org (Postfix) with ESMTP id BAE2A37B42C for ; Thu, 26 Apr 2001 12:18:51 -0700 (PDT) (envelope-from alex@big.endian.de) Received: by big.endian.de (Postfix, from userid 1001) id 690BF9B003; Thu, 26 Apr 2001 21:25:12 +0200 (CEST) Date: Thu, 26 Apr 2001 21:25:12 +0200 To: "Kellerman, Bert" Cc: "'freebsd-audit@freebsd.org'" Subject: Re: some mbox fixes Message-ID: <20010426212512.A22048@big.endian.de> References: <0D4982E5B3BED411910A00034708D24D31B6F2@hsaloumx01.hsacorp.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <0D4982E5B3BED411910A00034708D24D31B6F2@hsaloumx01.hsacorp.net>; from BKellerman@hsacorp.net on Thu, Apr 26, 2001 at 03:03:13PM -0400 X-PGP-Fingerprint: 44 28 CA 4C 46 5B D3 A8 A8 E3 BA F3 4E 60 7D 7F X-PGP-at: finger alex@big.endian.de X-Verwirrung: Dieser Header dient der allgemeinen Verwirrung. From: alex@big.endian.de (Alexander Langer) Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Thus spake Kellerman, Bert (BKellerman@hsacorp.net): > Here are some patches using obsd fixes from Kris' mbox. I am new so > let me know if everything looks good. For consistency, I am using the same > filename format as Andrew Reiter. > http://24.130.180.121/freebsd-audit/sbin/ping/ping.c.04252001.diff > Message-Id: <200012210025.eBL0PII23790@cvs.openbsd.org> > http://24.130.180.121/freebsd-audit/usr.bin/tftp/tftp.c.04252001.diff > Message-Id: <200012071813.eB7IDFI14188@cvs.openbsd.org> Both patches are fine. Alex To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 13:22: 2 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 2695937B422; Thu, 26 Apr 2001 13:21:56 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 82FE766DF6; Thu, 26 Apr 2001 13:21:55 -0700 (PDT) Date: Thu, 26 Apr 2001 13:21:55 -0700 From: Kris Kennaway To: Brian Somers Cc: obrien@FreeBSD.ORG, Kris Kennaway , hackers@FreeBSD.ORG, audit@FreeBSD.ORG Subject: Re: pax(1) gzip functionality Message-ID: <20010426132155.C2224@xor.obsecurity.org> References: <200104261823.f3QINUM63571@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="ghzN8eJ9Qlbqn3iT" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200104261823.f3QINUM63571@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Thu, Apr 26, 2001 at 07:23:30PM +0100 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --ghzN8eJ9Qlbqn3iT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 26, 2001 at 07:23:30PM +0100, Brian Somers wrote: > > On Thu, Apr 26, 2001 at 04:42:44PM +0100, Brian Somers wrote: > > > > On Thu, Apr 26, 2001 at 02:54:25AM -0700, Kris Kennaway wrote: > > > > > Please review the following code from OpenBSD; it adds -z and -Z > > > > > options to pax(1) to gzip(1) the archives created. > > > >=20 > > > > Sigh. They could have generalized this just a little and supported= Bzip2 > > > > at the same time. Please let me know after you commit this so I ca= n do > > > > this. > > >=20 > > > Is this necessary ? What's the problem with using a pipe ? Isn't=20 > > > this the same argument as the xargs one we've just gotten through ? > >=20 > > What's wrong with: > > tar cf - foo | gzip >foo.tar.gz > > gzip -dc foo.tar.gz | tar xf - > >=20 > > Someone deemed them too inconvient for the number of times they are > > invoked. I'm not going to enter that discussion, but _if_ gzip support > > is added, I feel bzip2 support should be added to be orthogonal with > > today's uses. >=20 > Agreed. Fair enough; would be a trivial thing to do. Increased compatibility with tar and cpio seems to have been one of the goals of OpenBSD's work on pax(1); I'm intending to go through and pull over the other bugfixes and extensions too. Kris --ghzN8eJ9Qlbqn3iT 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 iD8DBQE66INjWry0BWjoQKURAiDNAJ9AzIjMFxEnsv7uRkby+i6nUhGRWgCg5Ykz CrkVQsXGP8XVmWm+Y5NBtgM= =EeAs -----END PGP SIGNATURE----- --ghzN8eJ9Qlbqn3iT-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 13:24:52 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 B88BE37B422; Thu, 26 Apr 2001 13:24:47 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 7060B66E8E; Thu, 26 Apr 2001 13:24:47 -0700 (PDT) Date: Thu, 26 Apr 2001 13:24:47 -0700 From: Kris Kennaway To: Brian Somers Cc: obrien@FreeBSD.ORG, Kris Kennaway , hackers@FreeBSD.ORG, audit@FreeBSD.ORG Subject: Re: pax(1) gzip functionality Message-ID: <20010426132447.F2224@xor.obsecurity.org> References: <200104261542.f3QFgiM61575@hak.lan.Awfulhak.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="yH1ZJFh+qWm+VodA" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <200104261542.f3QFgiM61575@hak.lan.Awfulhak.org>; from brian@Awfulhak.org on Thu, Apr 26, 2001 at 04:42:44PM +0100 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --yH1ZJFh+qWm+VodA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 26, 2001 at 04:42:44PM +0100, Brian Somers wrote: > > On Thu, Apr 26, 2001 at 02:54:25AM -0700, Kris Kennaway wrote: > > > Please review the following code from OpenBSD; it adds -z and -Z > > > options to pax(1) to gzip(1) the archives created. > >=20 > > Sigh. They could have generalized this just a little and supported Bzi= p2 > > at the same time. Please let me know after you commit this so I can do > > this. >=20 > Is this necessary ? What's the problem with using a pipe ? Isn't=20 > this the same argument as the xargs one we've just gotten through ? >=20 > Maybe I'm missing something... This is useful in tar compatibility mode, and therefore it may as well be used for pax mode too. Kris --yH1ZJFh+qWm+VodA 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 iD8DBQE66IQOWry0BWjoQKURApMAAJ0b2gV50V8vZE+CXNL61eMPbvoGXgCg4NdA ZWJBYg4lt4z8wTFXsa9T8fU= =HTGZ -----END PGP SIGNATURE----- --yH1ZJFh+qWm+VodA-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 13:25:21 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 CECED37B423 for ; Thu, 26 Apr 2001 13:25:18 -0700 (PDT) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 88C6566E09; Thu, 26 Apr 2001 13:25:18 -0700 (PDT) Date: Thu, 26 Apr 2001 13:25:18 -0700 From: Kris Kennaway To: "Kellerman, Bert" Cc: "'freebsd-audit@freebsd.org'" Subject: Re: some mbox fixes Message-ID: <20010426132518.G2224@xor.obsecurity.org> References: <0D4982E5B3BED411910A00034708D24D31B6F2@hsaloumx01.hsacorp.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="yQbNiKLmgenwUfTN" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <0D4982E5B3BED411910A00034708D24D31B6F2@hsaloumx01.hsacorp.net>; from BKellerman@hsacorp.net on Thu, Apr 26, 2001 at 03:03:13PM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --yQbNiKLmgenwUfTN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 26, 2001 at 03:03:13PM -0400, Kellerman, Bert wrote: > Hello, >=20 > Here are some patches using obsd fixes from Kris' mbox. I am new so > let me know if everything looks good. For consistency, I am using the same > filename format as Andrew Reiter. >=20 > http://24.130.180.121/freebsd-audit/sbin/ping/ping.c.04252001.diff > Message-Id: <200012210025.eBL0PII23790@cvs.openbsd.org> >=20 > http://24.130.180.121/freebsd-audit/usr.bin/tftp/tftp.c.04252001.diff > Message-Id: <200012071813.eB7IDFI14188@cvs.openbsd.org> Thanks Bert! I'll review these ASAP. Kris --yQbNiKLmgenwUfTN 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 iD8DBQE66IQtWry0BWjoQKURApqQAJ9ng5TB6w1b9QpzeZie2DX3w39bLgCeMsD0 mjk6YPM+Exkv6XwpR2o+UpQ= =A3T0 -----END PGP SIGNATURE----- --yQbNiKLmgenwUfTN-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 16:23:27 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 6E66137B424 for ; Thu, 26 Apr 2001 16:23:23 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3QNNrA61757 for ; Thu, 26 Apr 2001 19:23:54 -0400 (EDT) (envelope-from arr@watson.org) Date: Thu, 26 Apr 2001 19:23:53 -0400 (EDT) From: "Andrew R. Reiter" To: freebsd-audit@FreeBSD.ORG Subject: Re: audit work: libc's setenv() and putenv() In-Reply-To: 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 Although, the actions of putenv("=blah"); returning 0 seems weird and after talking to Theo a bit.. I've kind of decided to retract this patch :-) Basically, the sanity checks should not be there.. which I was questioning anyway (check below). Also, since openbsd, solaris _and_ freebsd all do the returning of 0 on the above call, then I think it would be bad to change this functionality. anyway, if people think otherwise, interject! andrew On Wed, 25 Apr 2001, Andrew R. Reiter wrote: > hi, > > i found a small stupid issue with putenv() in our libc, as well as > OpenBSD's... basically if you do: > > putenv("=bleh"); /* incorrect usage */ > > it will not return a -1 error value, but instead return 0. Attached is a > patch which does a couple of fixes: > > - assertion (not using assert()) checks on the arguments being passed to > setenv and putenv because both with core if any of the const char *'s are > NULL. > - assertion checks on values being passed to setenv() from putenv(). > > I was kind of uncertain as to whether or not such assertion checks should > be done in the libc code, but I found some sanity checks in other > functions so I figured it was "OK." > > Anyway, the diff is attached, but can also be found at: > http://www.watson.org/~arr/fbsd-audit/lib/libc/stdlib/ > > Thoughts? > > Andrew > > *-------------................................................. > | Andrew R. Reiter > | arr@fledge.watson.org > | "It requires a very unusual mind > | to undertake the analysis of the obvious" -- A.N. Whitehead > *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 18: 6:55 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 1641637B422 for ; Thu, 26 Apr 2001 18:06:28 -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 BA0873E2A for ; Thu, 26 Apr 2001 18:06:27 -0700 (PDT) To: audit@freebsd.org Subject: Patch to add snapshots to last(1) Date: Thu, 26 Apr 2001 18:06:27 -0700 From: Dima Dorfman Message-Id: <20010427010627.BA0873E2A@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG OpenBSD's last(1) has a nice snapshot feature which allows one to get a list of users logged in at a certain date and time. Attached is a patch which implements this functionality in FreeBSD's last(1). Although the majority of the patch is from OpenBSD, the delta is quite large; our last(1) has other features that theirs doesn't. I'd appreciate it if someone could please review and/or test the patch. Thanks, Dima Dorfman dima@unixfreak.org Index: last.1 =================================================================== RCS file: /st/src/FreeBSD/src/usr.bin/last/last.1,v retrieving revision 1.8 diff -u -r1.8 last.1 --- last.1 2001/04/26 06:10:46 1.8 +++ last.1 2001/04/26 23:50:43 @@ -41,6 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl Ns Ar n +.Op Fl d Ar [[CC]YY][MMDD]hhmm[.SS] .Op Fl f Ar file .Op Fl h Ar host .Op Fl s @@ -49,12 +50,13 @@ .Op user ... .Sh DESCRIPTION .Nm Last -will list the sessions of specified +will either list the sessions of specified .Ar users , .Ar ttys , and .Ar hosts , -in reverse time order. +in reverse time order, +or list the users logged in at a specified date and time. Each line of output contains the user name, the tty from which the session was conducted, any hostname, the start and stop times for the session, and the duration @@ -69,6 +71,60 @@ Limits the report to .Ar n lines. +.It Fl d Ar date +Specify the snapshot date and time. +All users logged in at the snapshot date and time will +be reported. +This may be used with the +.Fl f +option to derive the results from stored wtmp files. +When this argument is provided, all other options except for +.Fl f +and +.Fl Ar n +are ignored. +The argument should be in the form +.Dq [[CC]YY][MMDD]hhmm[.SS] +where each pair of letters represents the following: +.Pp +.Bl -tag -width Ds -compact -offset indent +.It Ar CC +The first two digits of the year (the century). +.It Ar YY +The second two digits of the year. +If +.Dq YY +is specified, but +.Dq CC +is not, a value for +.Dq YY +between 69 and 99 results in a +.Dq CC +value of 19. +Otherwise, a +.Dq CC +value of 20 is used. +.It Ar MM +Month of the year, from 1 to 12. +.It Ar DD +Day of the month, from 1 to 31. +.It Ar hh +Hour of the day, from 0 to 23. +.It Ar mm +Minute of the hour, from 0 to 59. +.It Ar SS +Second of the minute, from 0 to 61. +.El +.Pp +If the +.Dq CC +and +.Dq YY +letter pairs are not specified, the values default to the current +year. +If the +.Dq SS +letter pair is not specified, the value defaults to 0. .It Fl f Ar file .Nm Last reads the file @@ -94,8 +150,9 @@ default days, hours and minutes. .El .Pp -If -multiple arguments are given, the information which applies to any of the +If multiple arguments are given, +and a snapshot time is not specified, +the information which applies to any of the arguments is printed, e.g., .Dq Li "last root -t console" would list all of Index: last.c =================================================================== RCS file: /st/src/FreeBSD/src/usr.bin/last/last.c,v retrieving revision 1.16 diff -u -r1.16 last.c --- last.c 2001/03/21 19:08:01 1.16 +++ last.c 2001/04/26 23:50:43 @@ -62,6 +62,7 @@ #define NO 0 /* false/no */ #define YES 1 /* true/yes */ +#define ATOI2(ar) ((ar)[0] - '0') * 10 + ((ar)[1] - '0'); (ar) += 2; static struct utmp buf[1024]; /* utmp read buffer */ @@ -89,11 +90,16 @@ static int sflag = 0; /* show delta in seconds */ static int width = 5; /* show seconds in delta */ static int d_first; +static time_t snaptime; /* if != 0, we will only + * report users logged in + * at this snapshot time + */ void addarg __P((int, char *)); void hostconv __P((char *)); void onintr __P((int)); char *ttyconv __P((char *)); +time_t dateconv __P((char *)); int want __P((struct utmp *)); void wtmp __P((void)); @@ -117,7 +123,8 @@ d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); maxrec = -1; - while ((ch = getopt(argc, argv, "0123456789f:h:st:w")) != -1) + snaptime = 0; + while ((ch = getopt(argc, argv, "0123456789d:f:h:st:w")) != -1) switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': @@ -135,6 +142,9 @@ exit(0); } break; + case 'd': + snaptime = dateconv(optarg); + break; case 'f': file = optarg; break; @@ -189,6 +199,7 @@ char *crmsg; char ct[80]; struct tm *tm; + int snapfound = 0; /* found snapshot entry? */ LIST_INIT(&ttylist); @@ -220,7 +231,19 @@ currentout = -bp->ut_time; crmsg = strncmp(bp->ut_name, "shutdown", UT_NAMESIZE) ? "crash" : "shutdown"; - if (want(bp)) { + /* + * if we're in snapshot mode, we want to + * exit if this shutdown/reboot appears + * while we we are tracking the active + * range + */ + if (snaptime && snapfound) + return; + /* + * don't print shutdown/reboot entries + * unless flagged for + */ + if (!snaptime && want(bp)) { tm = localtime(&bp->ut_time); (void) strftime(ct, sizeof(ct), d_first ? "%a %e %b %R" : @@ -243,7 +266,7 @@ */ if ((bp->ut_line[0] == '{' || bp->ut_line[0] == '|') && !bp->ut_line[1]) { - if (want(bp)) { + if (want(bp) && !snaptime) { tm = localtime(&bp->ut_time); (void) strftime(ct, sizeof(ct), d_first ? "%a %e %b %R" : @@ -259,77 +282,82 @@ } continue; } - if (bp->ut_name[0] == '\0' || want(bp)) { - /* find associated tty */ - LIST_FOREACH(tt, &ttylist, list) - if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE)) - break; - - if (tt == NULL) { - /* add new one */ - tt = malloc(sizeof(struct ttytab)); - if (tt == NULL) - err(1, "malloc failure"); - tt->logout = currentout; - strncpy(tt->tty, bp->ut_line, UT_LINESIZE); - LIST_INSERT_HEAD(&ttylist, tt, list); - } - - if (bp->ut_name[0]) { - /* - * when uucp and ftp log in over a network, the entry in - * the utmp file is the name plus their process id. See - * etc/ftpd.c and usr.bin/uucp/uucpd.c for more information. - */ - if (!strncmp(bp->ut_line, "ftp", sizeof("ftp") - 1)) - bp->ut_line[3] = '\0'; - else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1)) - bp->ut_line[4] = '\0'; - tm = localtime(&bp->ut_time); - (void) strftime(ct, sizeof(ct), - d_first ? "%a %e %b %R" : - "%a %b %e %R", - tm); - printf("%-*.*s %-*.*s %-*.*s %s ", - UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, - UT_LINESIZE, UT_LINESIZE, bp->ut_line, - UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, - ct); - if (!tt->logout) - puts(" still logged in"); + /* find associated tty */ + LIST_FOREACH(tt, &ttylist, list) + if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE)) + break; + + if (tt == NULL) { + /* add new one */ + tt = malloc(sizeof(struct ttytab)); + if (tt == NULL) + err(1, "malloc failure"); + tt->logout = currentout; + strncpy(tt->tty, bp->ut_line, UT_LINESIZE); + LIST_INSERT_HEAD(&ttylist, tt, list); + } + + /* + * print record if not in snapshot mode and wanted + * or in snapshot mode and in snapshot range + */ + if (bp->ut_name[0] && (want(bp) || + (bp->ut_time < snaptime && + (tt->logout > snaptime || tt->logout < 1)))) { + snapfound = 1; + /* + * when uucp and ftp log in over a network, the entry in + * the utmp file is the name plus their process id. See + * etc/ftpd.c and usr.bin/uucp/uucpd.c for more information. + */ + if (!strncmp(bp->ut_line, "ftp", sizeof("ftp") - 1)) + bp->ut_line[3] = '\0'; + else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1)) + bp->ut_line[4] = '\0'; + tm = localtime(&bp->ut_time); + (void) strftime(ct, sizeof(ct), + d_first ? "%a %e %b %R" : + "%a %b %e %R", + tm); + printf("%-*.*s %-*.*s %-*.*s %s ", + UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, + UT_LINESIZE, UT_LINESIZE, bp->ut_line, + UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, + ct); + if (!tt->logout) + puts(" still logged in"); + else { + if (tt->logout < 0) { + tt->logout = -tt->logout; + printf("- %s", crmsg); + } else { - if (tt->logout < 0) { - tt->logout = -tt->logout; - printf("- %s", crmsg); - } - else { - tm = localtime(&tt->logout); - (void) strftime(ct, sizeof(ct), "%R", tm); - printf("- %s", ct); - } - delta = tt->logout - bp->ut_time; - if ( sflag ) { - printf(" (%8lu)\n", - delta); - } else { - tm = gmtime(&delta); - (void) strftime(ct, sizeof(ct), - width >= 8 ? "%T" : "%R", - tm); - if (delta < 86400) + tm = localtime(&tt->logout); + (void) strftime(ct, sizeof(ct), "%R", tm); + printf("- %s", ct); + } + delta = tt->logout - bp->ut_time; + if ( sflag ) { + printf(" (%8lu)\n", + delta); + } else { + tm = gmtime(&delta); + (void) strftime(ct, sizeof(ct), + width >= 8 ? "%T" : "%R", + tm); + if (delta < 86400) printf(" (%s)\n", ct); - else + else printf(" (%ld+%s)\n", delta / 86400, ct); - } } - LIST_REMOVE(tt, list); - free(tt); - if (maxrec != -1 && !--maxrec) - return; - } else { - tt->logout = bp->ut_time; } + LIST_REMOVE(tt, list); + free(tt); + if (maxrec != -1 && !--maxrec) + return; + } else { + tt->logout = bp->ut_time; } } } @@ -348,6 +376,9 @@ { ARG *step; + if (snaptime) + return (NO); + if (!arglist) return (YES); @@ -444,6 +475,80 @@ return (arg + 5); return (arg); } + +/* + * dateconv -- + * Convert the snapshot time in command line given in the format + * [[CC]YY]MMDDhhmm[.SS]] to a time_t. + * Derived from atime_arg1() in usr.bin/touch/touch.c + */ +time_t +dateconv(arg) + char *arg; +{ + time_t timet; + struct tm *t; + int yearset; + char *p; + + /* Start with the current time. */ + if (time(&timet) < 0) + err(1, "time"); + if ((t = localtime(&timet)) == NULL) + err(1, "localtime"); + + /* [[CC]YY]MMDDhhmm[.SS] */ + if ((p = strchr(arg, '.')) == NULL) + t->tm_sec = 0; /* Seconds defaults to 0. */ + else { + if (strlen(p + 1) != 2) + goto terr; + *p++ = '\0'; + t->tm_sec = ATOI2(p); + } + + yearset = 0; + switch (strlen(arg)) { + case 12: /* CCYYMMDDhhmm */ + t->tm_year = ATOI2(arg); + t->tm_year *= 100; + yearset = 1; + /* FALLTHOUGH */ + case 10: /* YYMMDDhhmm */ + if (yearset) { + yearset = ATOI2(arg); + t->tm_year += yearset; + } else { + yearset = ATOI2(arg); + if (yearset < 69) + t->tm_year = yearset + 2000; + else + t->tm_year = yearset + 1900; + } + t->tm_year -= 1900; /* Convert to UNIX time. */ + /* FALLTHROUGH */ + case 8: /* MMDDhhmm */ + t->tm_mon = ATOI2(arg); + --t->tm_mon; /* Convert from 01-12 to 00-11 */ + t->tm_mday = ATOI2(arg); + t->tm_hour = ATOI2(arg); + t->tm_min = ATOI2(arg); + break; + case 4: /* hhmm */ + t->tm_hour = ATOI2(arg); + t->tm_min = ATOI2(arg); + break; + default: + goto terr; + } + t->tm_isdst = -1; /* Figure out DST. */ + timet = mktime(t); + if (timet == -1) +terr: errx(1, + "out of range or illegal time specification: [[CC]YY]MMDDhhmm[.SS]"); + return timet; +} + /* * onintr -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 18:45: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 628EC37B423 for ; Thu, 26 Apr 2001 18:45: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 266B63E2A for ; Thu, 26 Apr 2001 18:45:22 -0700 (PDT) To: audit@freebsd.org Subject: allscreens_flags for kbdcontrol patch Date: Thu, 26 Apr 2001 18:45:22 -0700 From: Dima Dorfman Message-Id: <20010427014522.266B63E2A@bazooka.unixfreak.org> Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG The attached patch adds an rc.conf option, allscreenskbd_flags, which does the same thing as allscreens_flags except it runs kbdcontrol instead of vidcontrol. I'm not really sure why these programs were separated, but that's another story. This patch allows one to stick 'allscreenskbd_flags="-h 200"' in rc.conf and automatically have the scrollback buffer size set to 200 lines for all the virtual terminals. Comments? Reviews? (Or I'll have to file a PR about it!) Thanks in advance, Dima Dorfman dima@unixfreak.org Index: rc.syscons =================================================================== RCS file: /st/src/FreeBSD/src/etc/rc.syscons,v retrieving revision 1.1 diff -u -r1.1 rc.syscons --- rc.syscons 2001/01/09 22:28:17 1.1 +++ rc.syscons 2001/04/25 03:55:46 @@ -173,4 +173,13 @@ done fi +# set this mode for all virtual screens, but use kbdcontrol +# +if [ -n "${allscreenskbd_flags}" ]; then + echo -n ' allscreenskbd' + for ttyv in /dev/ttyv*; do + kbdcontrol ${allscreenskbd_flags} < ${ttyv} > ${ttyv} 2>&1 + done +fi + echo '.' Index: defaults/rc.conf =================================================================== RCS file: /st/src/FreeBSD/src/etc/defaults/rc.conf,v retrieving revision 1.99 diff -u -r1.99 rc.conf --- defaults/rc.conf 2001/04/04 16:48:56 1.99 +++ defaults/rc.conf 2001/04/25 03:55:47 @@ -293,6 +293,7 @@ moused_port="/dev/psm0" # Set to your mouse port. moused_flags="" # Any additional flags to moused. allscreens_flags="" # Set this vidcontrol mode for all virtual screens +allscreenskbd_flags="" # Set this kbdcontrol mode for all virtual screens ############################################################## To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Thu Apr 26 19:44:21 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 4E7D437B424 for ; Thu, 26 Apr 2001 19:44: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 f3R2iGu13337; Thu, 26 Apr 2001 22:44:16 -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 <0GCF00LIRJLSNW@gkar.cc.vt.edu>; Thu, 26 Apr 2001 22:44:16 -0400 (EDT) Date: Thu, 26 Apr 2001 22:42:56 -0400 (EDT) From: Mike Heffner Subject: RE: some mbox fixes In-reply-to: <0D4982E5B3BED411910A00034708D24D31B6F2@hsaloumx01.hsacorp.net> To: "Kellerman, Bert" Cc: "freebsd-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:20010426224256:436=_"; 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:20010426224256:436=_ Content-Type: text/plain; charset=us-ascii On 26-Apr-2001 Kellerman, Bert wrote: | Hello, | | Here are some patches using obsd fixes from Kris' mbox. I am new so | let me know if everything looks good. For consistency, I am using the same | filename format as Andrew Reiter. These look fine, keep up the good work :) Thanks, Mike -- Mike Heffner Blacksburg, VA http://filebox.vt.edu/users/mheffner --_=XFMail.1.4.7.FreeBSD:20010426224256:436=_ Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE66NywFokZQs3sv5kRAmnCAJ9KXy/cpicBSjFAwGVtaZEs8uIr/gCfaLGt vzm7hMAtx/DJ0cD53r76yTI= =KxmJ -----END PGP SIGNATURE----- --_=XFMail.1.4.7.FreeBSD:20010426224256:436=_-- 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 Thu Apr 26 20:50:37 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 3890037B42C for ; Thu, 26 Apr 2001 20:50:34 -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 NAA13576; Fri, 27 Apr 2001 13:50:26 +1000 Date: Fri, 27 Apr 2001 13:49:23 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: "Andrew R. Reiter" Cc: freebsd-audit@FreeBSD.ORG Subject: Re: audit work: libc's setenv() and putenv() In-Reply-To: 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 Thu, 26 Apr 2001, Andrew R. Reiter wrote: > Although, the actions of putenv("=blah"); returning 0 seems weird and > after talking to Theo a bit.. I've kind of decided to retract this patch > :-) > > Basically, the sanity checks should not be there.. which I was questioning > anyway (check below). Yes, they are like sanity checks for strlen(NULL). Returning an error code is worse than dumping core. I prefer a core dump for setenv("=blah") too. The behaviour is currently non-deterministic. > Also, since openbsd, solaris _and_ freebsd all do > the returning of 0 on the above call, then I think it would be bad to > change this functionality. Hardly anything checks for errors from setenv() of course. E.g., the not unimportant login utility "handles" errors from setenv() by explicitly ignoring them. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 0: 3: 0 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 53D8837B422 for ; Fri, 27 Apr 2001 00:02:56 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3R73LO67455; Fri, 27 Apr 2001 03:03:21 -0400 (EDT) (envelope-from arr@watson.org) Date: Fri, 27 Apr 2001 03:03:20 -0400 (EDT) From: "Andrew R. Reiter" To: Bruce Evans Cc: freebsd-audit@FreeBSD.ORG Subject: Re: audit work: libc's setenv() and putenv() In-Reply-To: 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 Fri, 27 Apr 2001, Bruce Evans wrote: > Hardly anything checks for errors from setenv() of course. E.g., the > not unimportant login utility "handles" errors from setenv() by explicitly > ignoring them. > Ya, Im actually going through some code now for -audit for having some code check the return values... :-/ Andrew *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 6: 4:51 2001 Delivered-To: freebsd-audit@freebsd.org Received: from nebula.cybercable.fr (d217.dhcp212-198-126.noos.fr [212.198.126.217]) by hub.freebsd.org (Postfix) with ESMTP id 0628B37B423 for ; Fri, 27 Apr 2001 06:04:45 -0700 (PDT) (envelope-from mux@qualys.com) Received: (from mux@localhost) by nebula.cybercable.fr (8.11.3/8.11.3) id f3RD4b301323 for audit@FreeBSD.org; Fri, 27 Apr 2001 15:04:37 +0200 (CEST) (envelope-from mux) Date: Fri, 27 Apr 2001 15:04:36 +0200 From: Maxime Henrion To: audit@FreeBSD.org Subject: [PATCH] wall.c changes from OpenBSD Message-ID: <20010427150436.A1170@nebula.cybercable.fr> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, This patch makes wall open the file with the egid, as taken from the OpenBSD mbox of Kris. I changed several err() to errx() and added some dots to end of sentences to match OpenBSD and reduce the diffs. I hope this patch is correct. Maxime -- Don't be fooled by cheap finnish imitations ; BSD is the One True Code Key fingerprint = F9B6 1D5A 4963 331C 88FC CA6A AB50 1EF2 8CBE 99D6 Public Key : http://www.epita.fr/~henrio_m/ --FCuugMFkClbJLl1L Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="wall.c.diff" *** wall.c.old Fri Apr 27 14:58:30 2001 --- wall.c Fri Apr 27 14:58:09 2001 *************** *** 135,141 **** makemsg(*argv); if (!(fp = fopen(_PATH_UTMP, "r"))) ! err(1, "cannot read %s", _PATH_UTMP); iov.iov_base = mbuf; iov.iov_len = mbufsize; /* NOSTRICT */ --- 135,141 ---- makemsg(*argv); if (!(fp = fopen(_PATH_UTMP, "r"))) ! errx(1, "cannot read %s.", _PATH_UTMP); iov.iov_base = mbuf; iov.iov_len = mbufsize; /* NOSTRICT */ *************** *** 192,198 **** (void)snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP); if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) ! err(1, "can't open temporary file"); (void)unlink(tmpname); if (!nobanner) { --- 192,198 ---- (void)snprintf(tmpname, sizeof(tmpname), "%s/wall.XXXXXX", _PATH_TMP); if ((fd = mkstemp(tmpname)) == -1 || !(fp = fdopen(fd, "r+"))) ! errx(1, "can't open temporary file."); (void)unlink(tmpname); if (!nobanner) { *************** *** 225,232 **** } (void)fprintf(fp, "%79s\r\n", " "); ! if (fname && !(freopen(fname, "r", stdin))) ! err(1, "can't read %s", fname); while (fgets(lbuf, sizeof(lbuf), stdin)) for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { if (ch == '\r') { --- 225,238 ---- } (void)fprintf(fp, "%79s\r\n", " "); ! if (fname) { ! gid_t egid = getegid(); ! ! setegid(getgid()); ! if (freopen(fname, "r", stdin) == NULL) ! errx(1, "can't read %s.", fname); ! setegid(egid); ! } while (fgets(lbuf, sizeof(lbuf), stdin)) for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { if (ch == '\r') { *************** *** 275,285 **** rewind(fp); if (fstat(fd, &sbuf)) ! err(1, "can't stat temporary file"); mbufsize = sbuf.st_size; if (!(mbuf = malloc((u_int)mbufsize))) ! err(1, "out of memory"); if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) ! err(1, "can't read temporary file"); (void)close(fd); } --- 281,291 ---- rewind(fp); if (fstat(fd, &sbuf)) ! errx(1, "can't stat temporary file."); mbufsize = sbuf.st_size; if (!(mbuf = malloc((u_int)mbufsize))) ! errx(1, "out of memory."); if (fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize) ! errx(1, "can't read temporary file."); (void)close(fd); } --FCuugMFkClbJLl1L-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 6:24: 7 2001 Delivered-To: freebsd-audit@freebsd.org Received: from peitho.fxp.org (peitho.fxp.org [209.26.95.40]) by hub.freebsd.org (Postfix) with ESMTP id 4BFF937B422 for ; Fri, 27 Apr 2001 06:24:04 -0700 (PDT) (envelope-from cdf.lists@fxp.org) Received: by peitho.fxp.org (Postfix, from userid 1501) id 176B31360C; Fri, 27 Apr 2001 09:24:04 -0400 (EDT) Date: Fri, 27 Apr 2001 09:24:03 -0400 From: Chris Faulhaber To: Maxime Henrion Cc: audit@FreeBSD.org Subject: Re: [PATCH] wall.c changes from OpenBSD Message-ID: <20010427092403.A32859@peitho.fxp.org> References: <20010427150436.A1170@nebula.cybercable.fr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="Dxnq1zWXvFF0Q93v" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010427150436.A1170@nebula.cybercable.fr>; from mux@qualys.com on Fri, Apr 27, 2001 at 03:04:36PM +0200 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --Dxnq1zWXvFF0Q93v Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 27, 2001 at 03:04:36PM +0200, Maxime Henrion wrote: > Hello, >=20 >=20 > This patch makes wall open the file with the egid, as taken from the > OpenBSD mbox of Kris. I changed several err() to errx() and added some > dots to end of sentences to match OpenBSD and reduce the diffs. >=20 I disagree with the err() -> errx() changes. Since err() prints the error message from strerror() whereas errx() does not, this patch removes this reporting ensuring the user will not be informed of the actual error. The other change(s) look ok, though. --=20 Chris D. Faulhaber - jedgar@fxp.org - jedgar@FreeBSD.org -------------------------------------------------------- FreeBSD: The Power To Serve - http://www.FreeBSD.org --Dxnq1zWXvFF0Q93v Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: FreeBSD: The Power To Serve iEYEARECAAYFAjrpcvMACgkQObaG4P6BelCMFwCfYGhAMyR7yair7fJJaWwqz2rT uWgAnRwDMAL5RJYghegGql8E0C1x7zml =fcve -----END PGP SIGNATURE----- --Dxnq1zWXvFF0Q93v-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 9: 6:25 2001 Delivered-To: freebsd-audit@freebsd.org Received: from nebula.cybercable.fr (d217.dhcp212-198-126.noos.fr [212.198.126.217]) by hub.freebsd.org (Postfix) with ESMTP id 55A4A37B422 for ; Fri, 27 Apr 2001 09:06:22 -0700 (PDT) (envelope-from mux@qualys.com) Received: (from mux@localhost) by nebula.cybercable.fr (8.11.3/8.11.3) id f3RG6Fq03428; Fri, 27 Apr 2001 18:06:15 +0200 (CEST) (envelope-from mux) Date: Fri, 27 Apr 2001 18:06:09 +0200 From: Maxime Henrion To: audit@FreeBSD.org Cc: Chris Faulhaber Subject: Re: [PATCH] wall.c changes from OpenBSD Message-ID: <20010427180609.A1371@nebula.cybercable.fr> References: <20010427150436.A1170@nebula.cybercable.fr> <20010427092403.A32859@peitho.fxp.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010427092403.A32859@peitho.fxp.org>; from jedgar@fxp.org on Fri, Apr 27, 2001 at 09:24:03AM -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Chris Faulhaber wrote: > On Fri, Apr 27, 2001 at 03:04:36PM +0200, Maxime Henrion wrote: > > Hello, > > > > This patch makes wall open the file with the egid, as taken from the > > OpenBSD mbox of Kris. I changed several err() to errx() and added some > > dots to end of sentences to match OpenBSD and reduce the diffs. > I disagree with the err() -> errx() changes. Since err() prints the > error message from strerror() whereas errx() does not, this patch > removes this reporting ensuring the user will not be informed of the > actual error. Agreed. Throw these changed then :-) > The other change(s) look ok, though. Thanks. Maxime -- Don't be fooled by cheap finnish imitations ; BSD is the One True Code Key fingerprint = F9B6 1D5A 4963 331C 88FC CA6A AB50 1EF2 8CBE 99D6 Public Key : http://www.epita.fr/~henrio_m/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 16: 4:49 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 E1D3937B424 for ; Fri, 27 Apr 2001 16:04:45 -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 JAA20758; Sat, 28 Apr 2001 09:04:29 +1000 Date: Sat, 28 Apr 2001 09:03:25 +1000 (EST) From: Bruce Evans X-Sender: bde@besplex.bde.org To: Chris Faulhaber Cc: Maxime Henrion , audit@FreeBSD.ORG Subject: Re: [PATCH] wall.c changes from OpenBSD In-Reply-To: <20010427092403.A32859@peitho.fxp.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 Fri, 27 Apr 2001, Chris Faulhaber wrote: > On Fri, Apr 27, 2001 at 03:04:36PM +0200, Maxime Henrion wrote: > > This patch makes wall open the file with the egid, as taken from the > > OpenBSD mbox of Kris. I changed several err() to errx() and added some > > dots to end of sentences to match OpenBSD and reduce the diffs. > > I disagree with the err() -> errx() changes. Since err() prints the > error message from strerror() whereas errx() does not, this patch > removes this reporting ensuring the user will not be informed of the > actual error. > > The other change(s) look ok, though. The err() changes are also wrong because they add "."s to the messages. Error messages are not normally terminated with a ".". (I could only find one involving err[x]() in /usr/src/bin/*/*.c.) > *** wall.c.old Fri Apr 27 14:58:30 2001 > --- wall.c Fri Apr 27 14:58:09 2001 > *************** > *** 225,232 **** > } > (void)fprintf(fp, "%79s\r\n", " "); > > ! if (fname && !(freopen(fname, "r", stdin))) > ! err(1, "can't read %s", fname); > while (fgets(lbuf, sizeof(lbuf), stdin)) > for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { > if (ch == '\r') { > --- 225,238 ---- > } > (void)fprintf(fp, "%79s\r\n", " "); > > ! if (fname) { > ! gid_t egid = getegid(); Style bugs: 1) declaration in inner block. 2) initializer in auto declaration. Explicitly forbidden in style(9) since it calls a function. > ! > ! setegid(getgid()); > ! if (freopen(fname, "r", stdin) == NULL) > ! errx(1, "can't read %s.", fname); errx() and "." in new code. > ! setegid(egid); > ! } > while (fgets(lbuf, sizeof(lbuf), stdin)) > for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { > if (ch == '\r') { Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 17:10:42 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id A5F9F37B422 for ; Fri, 27 Apr 2001 17:10:40 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3S0AqU79909; Fri, 27 Apr 2001 20:10:52 -0400 (EDT) (envelope-from arr@watson.org) Date: Fri, 27 Apr 2001 20:10:51 -0400 (EDT) From: "Andrew R. Reiter" X-Sender: arr@localhost To: Bruce Evans Cc: Chris Faulhaber , Maxime Henrion , audit@FreeBSD.ORG Subject: Re: [PATCH] wall.c changes from OpenBSD In-Reply-To: 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 > Style bugs: > 1) declaration in inner block. > 2) initializer in auto declaration. Explicitly forbidden in style(9) since > it calls a function. Isn't style(9) for kernel code? I don't really think this is kernel code :-) > Bruce > > *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 17:18: 3 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 DA63137B422 for ; Fri, 27 Apr 2001 17:18:00 -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 f3S0HXR10953; Fri, 27 Apr 2001 18:17:33 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200104280017.f3S0HXR10953@harmony.village.org> To: "Andrew R. Reiter" Subject: Re: [PATCH] wall.c changes from OpenBSD Cc: Bruce Evans , Chris Faulhaber , Maxime Henrion , audit@FreeBSD.ORG In-reply-to: Your message of "Fri, 27 Apr 2001 20:10:51 EDT." References: Date: Fri, 27 Apr 2001 18:17:33 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message "Andrew R. Reiter" writes: : > Style bugs: : > 1) declaration in inner block. : > 2) initializer in auto declaration. Explicitly forbidden in style(9) since : > it calls a function. : : Isn't style(9) for kernel code? I don't really think this is kernel code : :-) Style(9) is also for userland code. Don't argue with Bruce about this, as he's been enforcing this for at least 5 years. :-) Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Fri Apr 27 18:26:26 2001 Delivered-To: freebsd-audit@freebsd.org Received: from fledge.watson.org (fledge.watson.org [204.156.12.50]) by hub.freebsd.org (Postfix) with ESMTP id 0E18E37B422 for ; Fri, 27 Apr 2001 18:26:24 -0700 (PDT) (envelope-from arr@watson.org) Received: from localhost (arr@localhost) by fledge.watson.org (8.11.3/8.11.3) with SMTP id f3S1Pak80587; Fri, 27 Apr 2001 21:25:36 -0400 (EDT) (envelope-from arr@watson.org) Date: Fri, 27 Apr 2001 21:25:35 -0400 (EDT) From: "Andrew R. Reiter" X-Sender: arr@localhost To: Warner Losh Cc: Bruce Evans , Chris Faulhaber , Maxime Henrion , audit@FreeBSD.ORG Subject: Re: [PATCH] wall.c changes from OpenBSD In-Reply-To: <200104280017.f3S0HXR10953@harmony.village.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 Fri, 27 Apr 2001, Warner Losh wrote: > > Style(9) is also for userland code. Don't argue with Bruce about > this, as he's been enforcing this for at least 5 years. :-) > > Warner /me runs... ;-) *-------------................................................. | Andrew R. Reiter | arr@fledge.watson.org | "It requires a very unusual mind | to undertake the analysis of the obvious" -- A.N. Whitehead To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Apr 28 8:36:22 2001 Delivered-To: freebsd-audit@freebsd.org Received: from green.bikeshed.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 6FA8337B422; Sat, 28 Apr 2001 08:36:19 -0700 (PDT) (envelope-from green@green.bikeshed.org) Received: from localhost (green@localhost) by green.bikeshed.org (8.11.2/8.11.1) with ESMTP id f3SFaHJ30047; Sat, 28 Apr 2001 11:36:18 -0400 (EDT) (envelope-from green@green.bikeshed.org) Message-Id: <200104281536.f3SFaHJ30047@green.bikeshed.org> X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: Bruce Evans Cc: Chris Faulhaber , Maxime Henrion , audit@FreeBSD.ORG Subject: Re: [PATCH] wall.c changes from OpenBSD In-Reply-To: Message from Bruce Evans of "Sat, 28 Apr 2001 09:03:25 +1000." From: "Brian F. Feldman" Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sat, 28 Apr 2001 11:36:16 -0400 Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Bruce Evans wrote: > On Fri, 27 Apr 2001, Chris Faulhaber wrote: > > *** wall.c.old Fri Apr 27 14:58:30 2001 > > --- wall.c Fri Apr 27 14:58:09 2001 > > *************** > > *** 225,232 **** > > } > > (void)fprintf(fp, "%79s\r\n", " "); > > > > ! if (fname && !(freopen(fname, "r", stdin))) > > ! err(1, "can't read %s", fname); > > while (fgets(lbuf, sizeof(lbuf), stdin)) > > for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) { > > if (ch == '\r') { > > --- 225,238 ---- > > } > > (void)fprintf(fp, "%79s\r\n", " "); > > > > ! if (fname) { > > ! gid_t egid = getegid(); > > Style bugs: > 1) declaration in inner block. > 2) initializer in auto declaration. Explicitly forbidden in style(9) since > it calls a function. What was the justification for disallowing usage of proper variable block scoping? -- Brian Fundakowski Feldman \ FreeBSD: The Power to Serve! / green@FreeBSD.org `------------------------------' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Apr 28 9: 6:36 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 C6E1C37B422; Sat, 28 Apr 2001 09:06:32 -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 f3SG6QR19732; Sat, 28 Apr 2001 10:06:27 -0600 (MDT) (envelope-from imp@harmony.village.org) Message-Id: <200104281606.f3SG6QR19732@harmony.village.org> To: "Brian F. Feldman" Subject: Re: [PATCH] wall.c changes from OpenBSD Cc: Bruce Evans , Chris Faulhaber , Maxime Henrion , audit@FreeBSD.ORG In-reply-to: Your message of "Sat, 28 Apr 2001 11:36:16 EDT." <200104281536.f3SFaHJ30047@green.bikeshed.org> References: <200104281536.f3SFaHJ30047@green.bikeshed.org> Date: Sat, 28 Apr 2001 10:06:26 -0600 From: Warner Losh Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <200104281536.f3SFaHJ30047@green.bikeshed.org> "Brian F. Feldman" writes: : What was the justification for disallowing usage of proper variable block : scoping? It makes the code harder to understand, many compilers (at one time) produce worse code and they violate the idea that you can look for the variables in one place. It is also easier to introduce shadow variables at inner scopes which mades the code harder to debug. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message From owner-freebsd-audit Sat Apr 28 9:44:56 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 A654C37B423 for ; Sat, 28 Apr 2001 09:44:49 -0700 (PDT) (envelope-from roam@ringworld.nanolink.com) Received: (qmail 33019 invoked by uid 1000); 28 Apr 2001 16:42:59 -0000 Date: Sat, 28 Apr 2001 19:42:59 +0300 From: Peter Pentchev To: audit@FreeBSD.org Subject: du(1) -I option to ignore files/dirs Message-ID: <20010428194259.J415@ringworld.oblivion.bg> Mail-Followup-To: audit@FreeBSD.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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. G'luck, Peter -- I am jealous of the first word in this sentence. Index: src/usr.bin/du/du.1 =================================================================== RCS file: /home/ncvs/src/usr.bin/du/du.1,v retrieving revision 1.18 diff -u -r1.18 du.1 --- src/usr.bin/du/du.1 2000/11/20 19:20:41 1.18 +++ src/usr.bin/du/du.1 2001/04/28 16:42:25 @@ -41,6 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl P | Fl H | Fl L +.Op Fl I Ar mask .Op Fl a | s | d Ar depth .Op Fl c .Op Fl h | k @@ -72,6 +73,9 @@ hierarchies are not followed. .It Fl L Symbolic links on the command line and in file hierarchies are followed. +.It Fl I Ar mask +Ignore files and directories matching the specified +.Ar mask . .It Fl a Display an entry for each file in a file hierarchy. .It Fl h Index: src/usr.bin/du/du.c =================================================================== RCS file: /home/ncvs/src/usr.bin/du/du.c,v retrieving revision 1.19 diff -u -r1.19 du.c --- src/usr.bin/du/du.c 2000/03/26 14:21:57 1.19 +++ src/usr.bin/du/du.c 2001/04/28 16:42:26 @@ -50,10 +50,12 @@ #include +#include #include #include #include +#include #include #include #include @@ -88,10 +90,19 @@ int unitp [] = { NONE, KILO, MEGA, GIGA, TERA, PETA }; +SLIST_HEAD(ignhead, ignentry) ignores; +struct ignentry { + char *mask; + SLIST_ENTRY(ignentry) next; +}; + int linkchk __P((FTSENT *)); static void usage __P((void)); void prthumanval __P((double)); unit_t unit_adjust __P((double *)); +void ignoreadd __P((const char *)); +void ignoreclean __P((void)); +int ignorep __P((FTSENT *)); int main(argc, argv) @@ -112,12 +123,16 @@ save = argv; ftsoptions = 0; depth = INT_MAX; + SLIST_INIT(&ignores); - while ((ch = getopt(argc, argv, "HLPasd:chkrx")) != -1) + while ((ch = getopt(argc, argv, "HI:LPasd:chkrx")) != -1) switch (ch) { case 'H': Hflag = 1; break; + case 'I': + ignoreadd(optarg); + break; case 'L': if (Pflag) usage(); @@ -224,8 +239,13 @@ while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { case FTS_D: /* Ignore. */ + if (ignorep(p)) + fts_set(fts, p, FTS_SKIP); break; case FTS_DP: + if (ignorep(p)) + break; + p->fts_parent->fts_number += p->fts_number += p->fts_statp->st_blocks; @@ -249,6 +269,9 @@ rval = 1; break; default: + if (ignorep(p)) + break; + if (p->fts_statp->st_nlink > 1 && linkchk(p)) break; @@ -281,6 +304,7 @@ } } + ignoreclean(); exit(rval); } @@ -366,6 +390,48 @@ usage() { (void)fprintf(stderr, - "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k] [-x] [file ...]\n"); + "usage: du [-H | -L | -P] [-a | -s | -d depth] [-c] [-h | -k] [-x] [-I mask] [file ...]\n"); exit(EX_USAGE); +} + +void +ignoreadd(mask) + const char *mask; +{ + struct ignentry *ign; + + ign = calloc(1, sizeof(*ign)); + if (ign == NULL) + errx(1, "cannot allocate memory"); + ign->mask = strdup(mask); + if (ign->mask == NULL) + errx(1, "cannot allocate memory"); + SLIST_INSERT_HEAD(&ignores, ign, next); +} + +void +ignoreclean() +{ + struct ignentry *ign; + + while (!SLIST_EMPTY(&ignores)) { + ign = SLIST_FIRST(&ignores); + SLIST_REMOVE_HEAD(&ignores, next); + free(ign->mask); + free(ign); + } +} + +int +ignorep(ent) + FTSENT *ent; +{ + struct ignentry *ign; + + if (SLIST_EMPTY(&ignores)) + return 0; + SLIST_FOREACH(ign, &ignores, next) + if (fnmatch(ign->mask, ent->fts_name, 0) != FNM_NOMATCH) + return 1; + return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message