From owner-freebsd-arch@FreeBSD.ORG Sun May 2 03:50:21 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 325151065670 for ; Sun, 2 May 2010 03:50:21 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id E88988FC14 for ; Sun, 2 May 2010 03:50:20 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o423o92t041180; Sat, 1 May 2010 21:50:09 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 01 May 2010 21:50:23 -0600 (MDT) Message-Id: <20100501.215023.353672579433532204.imp@bsdimp.com> To: ed@80386.nl From: "M. Warner Losh" In-Reply-To: <20100501235846.GU56080@hoeg.nl> References: <20100501203244.GT56080@hoeg.nl> <20100501205625.GB36980@server.vk2pj.dyndns.org> <20100501235846.GU56080@hoeg.nl> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: Alexander@Leidinger.net, freebsd-arch@freebsd.org Subject: Re: [Extension] utmpx and LOGIN_FAILURE X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 03:50:21 -0000 In message: <20100501235846.GU56080@hoeg.nl> Ed Schouten writes: : * Peter Jeremy wrote: : > On 2010-May-01 22:32:44 +0200, Ed Schouten wrote: : > >* Alexander Leidinger wrote: : > >> Does this default to on or off or is this always on? If the later: some : > >> kind of a switch (no matter what the default is) would be highly : > >> desired. : > > : > >What about adding a switch to last(1) to (un)hide the entries? : > : > That doesn't cover the DoS potential of logging this data in the : > firstplace. : : So how is this covered right now? As far as I know, all of our existing : login services write messages to /var/log/*. newsyslog rotates those files when they get too big... Warner From owner-freebsd-arch@FreeBSD.ORG Sun May 2 04:23:20 2010 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 067B01065670 for ; Sun, 2 May 2010 04:23:20 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id ED50C8FC08 for ; Sun, 2 May 2010 04:23:19 +0000 (UTC) Received: by elvis.mu.org (Postfix, from userid 1192) id 91D961A3E38; Sat, 1 May 2010 21:23:14 -0700 (PDT) Date: Sat, 1 May 2010 21:23:14 -0700 From: Alfred Perlstein To: Ed Schouten Message-ID: <20100502042314.GV36233@elvis.mu.org> References: <20100501124544.GR56080@hoeg.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100501124544.GR56080@hoeg.nl> User-Agent: Mutt/1.4.2.3i Cc: freebsd-arch@FreeBSD.org Subject: Re: [Extension] utmpx and LOGIN_FAILURE X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 04:23:20 -0000 * Ed Schouten [100501 06:05] wrote: > Hi all, > > Some time ago I noticed some operating systems offer an interface called > btmp, which is essentially a wtmp for logging failed login attempts. > Instead of taking the same approach, I'd rather do something as follows: > > http://80386.nl/pub/utmpx-login_failure.diff.txt > > This patch adds a new utmpx log entry type called LOGIN_FAILURE. > Unfortunately we are the only operating system that does it this way, > but I suspect if we can already get OpenSSH and PAM to use this > interface, we've got reasonable coverage. The patch only has the > modifications for OpenSSH. > > An example of what this looks like: > > | $ last | grep failed > | sdlfkjdf mekker.80386.nl Sat May 1 14:14 login failed > > The idea behind having this, is to make logging of such failed attempts > more generic and easier to obtain. It would be quite nice if > applications like DenyHosts can simply harvest this database using > getutxent(3), instead of using all sorts of regular expressions on the > log files. > > Any thoughts on this subject? I am obviously not too familiar with this code, but I am worried that unless done properly we could be vulnerable to DoS or obliterating records by flooding the logging facility. I'm also wondering why we're going to diverge from other *nix, is there added value to diverging from what others do? -- - Alfred Perlstein .- AMA, VMOA #5191, 03 vmax, 92 gs500, 85 ch250, 07 zx10 .- FreeBSD committer From owner-freebsd-arch@FreeBSD.ORG Sun May 2 04:55:16 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 38BB3106564A for ; Sun, 2 May 2010 04:55:16 +0000 (UTC) (envelope-from julianelischer@gmail.com) Received: from mail-px0-f182.google.com (mail-px0-f182.google.com [209.85.212.182]) by mx1.freebsd.org (Postfix) with ESMTP id 057F48FC14 for ; Sun, 2 May 2010 04:55:15 +0000 (UTC) Received: by pxi17 with SMTP id 17so855122pxi.13 for ; Sat, 01 May 2010 21:55:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=ZLMaz+r1Iz5nk/Fd5xnxH9ka4b5hEGGCg6ZP3UJmcLw=; b=jk+and1jOO62vlbfGGOy9n9QO5GYxW+gLvSTNzcVvOeOkG6ybL7WaDK82Bfc1rCF8A FbnPCIVyZWGdcCgIzL0A3a5maoxujuXCVdfJqsxcTJNwT9lsozLARWAGZ+1sxW/Lc+Rx 8UkTdJiUH7LBQQZnXGCsIfm2RHKP4g5ziioz8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=kHHx5VKVhk3f/E1kmqHhyz6sBwFpeWmSGzpLukFv4TD31+TcKOKeyqNPu2uaCoGWkf JU4KvqPZkDm6Oy3oxpFBUfvegSFBXW4NuLY6esFlmxSphEf71Uk/Is1aegYd3V/9TZxR uHVo4n3Hc3V4LgnTOrqkh8gRlXOnwS2837BWo= Received: by 10.114.2.25 with SMTP id 25mr8681593wab.100.1272776106742; Sat, 01 May 2010 21:55:06 -0700 (PDT) Received: from julian-mac.elischer.org (h-67-100-89-137.snfccasy.static.covad.net [67.100.89.137]) by mx.google.com with ESMTPS id g30sm17378405wag.4.2010.05.01.21.55.04 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 01 May 2010 21:55:05 -0700 (PDT) Sender: Julian Elischer Message-ID: <4BDD05A6.1090709@elischer.org> Date: Sat, 01 May 2010 21:55:02 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: "M. Warner Losh" References: <20100501203244.GT56080@hoeg.nl> <20100501205625.GB36980@server.vk2pj.dyndns.org> <20100501235846.GU56080@hoeg.nl> <20100501.215023.353672579433532204.imp@bsdimp.com> In-Reply-To: <20100501.215023.353672579433532204.imp@bsdimp.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: ed@80386.nl, freebsd-arch@freebsd.org, Alexander@Leidinger.net Subject: Re: [Extension] utmpx and LOGIN_FAILURE X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 04:55:16 -0000 On 5/1/10 8:50 PM, M. Warner Losh wrote: > In message:<20100501235846.GU56080@hoeg.nl> > Ed Schouten writes: > : * Peter Jeremy wrote: > :> On 2010-May-01 22:32:44 +0200, Ed Schouten wrote: > :> >* Alexander Leidinger wrote: > :> >> Does this default to on or off or is this always on? If the later: some > :> >> kind of a switch (no matter what the default is) would be highly > :> >> desired. > :> > > :> >What about adding a switch to last(1) to (un)hide the entries? > :> > :> That doesn't cover the DoS potential of logging this data in the > :> firstplace. > : > : So how is this covered right now? As far as I know, all of our existing > : login services write messages to /var/log/*. successful and unsuccessful attempts need to be in different files or an attacker can effectively flush the record of successful attempts by filling up the files with unsuccessful attempts. This is also a DOS method. > > newsyslog rotates those files when they get too big... > > Warner > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" From owner-freebsd-arch@FreeBSD.ORG Sun May 2 08:20:59 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7EF491065673; Sun, 2 May 2010 08:20:59 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 3F7358FC12; Sun, 2 May 2010 08:20:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.3/8.14.1) with ESMTP id o428EotX042858; Sun, 2 May 2010 02:14:50 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 02 May 2010 02:15:04 -0600 (MDT) Message-Id: <20100502.021504.821837081304738288.imp@bsdimp.com> To: alfred@freebsd.org From: "M. Warner Losh" In-Reply-To: <20100502042314.GV36233@elvis.mu.org> References: <20100501124544.GR56080@hoeg.nl> <20100502042314.GV36233@elvis.mu.org> X-Mailer: Mew version 6.3 on Emacs 22.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: ed@80386.nl, freebsd-arch@freebsd.org Subject: Re: [Extension] utmpx and LOGIN_FAILURE X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 May 2010 08:20:59 -0000 In message: <20100502042314.GV36233@elvis.mu.org> Alfred Perlstein writes: : * Ed Schouten [100501 06:05] wrote: : > Hi all, : > : > Some time ago I noticed some operating systems offer an interface called : > btmp, which is essentially a wtmp for logging failed login attempts. : > Instead of taking the same approach, I'd rather do something as follows: : > : > http://80386.nl/pub/utmpx-login_failure.diff.txt : > : > This patch adds a new utmpx log entry type called LOGIN_FAILURE. : > Unfortunately we are the only operating system that does it this way, : > but I suspect if we can already get OpenSSH and PAM to use this : > interface, we've got reasonable coverage. The patch only has the : > modifications for OpenSSH. : > : > An example of what this looks like: : > : > | $ last | grep failed : > | sdlfkjdf mekker.80386.nl Sat May 1 14:14 login failed : > : > The idea behind having this, is to make logging of such failed attempts : > more generic and easier to obtain. It would be quite nice if : > applications like DenyHosts can simply harvest this database using : > getutxent(3), instead of using all sorts of regular expressions on the : > log files. : > : > Any thoughts on this subject? : : I am obviously not too familiar with this code, but I am worried : that unless done properly we could be vulnerable to DoS or obliterating : records by flooding the logging facility. : : I'm also wondering why we're going to diverge from other *nix, is : there added value to diverging from what others do? Also, we don't want to log usernames that failed to login, I don't think. Or at least make it optional. Otherwise, you'll get records like: sdlfkjdf mekker.80386.nl Sat May 1 14:14 login failed ed mekker.80386.nl Sat May 1 14:14 which makes it a safe bet that ed's password is sdkfkjdf. Warner From owner-freebsd-arch@FreeBSD.ORG Mon May 3 11:08:00 2010 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D983D1065670 for ; Mon, 3 May 2010 11:08:00 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.freebsd.org (Postfix) with ESMTP id AF0768FC15 for ; Mon, 3 May 2010 11:08:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o43B80Cl033535 for ; Mon, 3 May 2010 11:08:00 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o43B80dH033533 for freebsd-arch@FreeBSD.org; Mon, 3 May 2010 11:08:00 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 3 May 2010 11:08:00 GMT Message-Id: <201005031108.o43B80dH033533@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-arch@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 May 2010 11:08:00 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o kern/120749 arch [request] Suggest upping the default kern.ps_arg_cache 1 problem total. From owner-freebsd-arch@FreeBSD.ORG Tue May 4 09:17:53 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 64770106564A for ; Tue, 4 May 2010 09:17:53 +0000 (UTC) (envelope-from peterjeremy@acm.org) Received: from mail17.syd.optusnet.com.au (mail17.syd.optusnet.com.au [211.29.132.198]) by mx1.freebsd.org (Postfix) with ESMTP id ECB558FC1E for ; Tue, 4 May 2010 09:17:52 +0000 (UTC) Received: from server.vk2pj.dyndns.org (c122-106-253-149.belrs3.nsw.optusnet.com.au [122.106.253.149]) by mail17.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o449Ho1E012477 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 4 May 2010 19:17:51 +1000 X-Bogosity: Ham, spamicity=0.000000 Received: from server.vk2pj.dyndns.org (localhost.vk2pj.dyndns.org [127.0.0.1]) by server.vk2pj.dyndns.org (8.14.4/8.14.4) with ESMTP id o449HnS8058632 for ; Tue, 4 May 2010 19:17:49 +1000 (EST) (envelope-from peter@server.vk2pj.dyndns.org) Received: (from peter@localhost) by server.vk2pj.dyndns.org (8.14.4/8.14.4/Submit) id o449Hnc0058631 for freebsd-arch@freebsd.org; Tue, 4 May 2010 19:17:49 +1000 (EST) (envelope-from peter) Date: Tue, 4 May 2010 19:17:49 +1000 From: Peter Jeremy To: freebsd-arch@freebsd.org Message-ID: <20100504091749.GA58464@server.vk2pj.dyndns.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline X-PGP-Key: http://members.optusnet.com.au/peterjeremy/pubkey.asc User-Agent: Mutt/1.5.20 (2009-06-14) Subject: Style question: writing multi-line usage messages X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 09:17:53 -0000 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable I would appreciate some input on the preferred style for writing multi-line usage messages. Should: 1) printf() print a series of 1-line strings 2) should string gluing be used to turn multiple strings into one for print= ing 3) should continuation lines be used to create a single string I can't see anything in style(9) to cover this. Variants of the tunefs(8) usage() function follow as examples: void usage(void) { fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n", "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]", " [-J enable | disable] [-j enable | disable]",=20 " [-L volname] [-l enable | disable] [-m minfree]", " [-N enable | disable] [-n enable | disable]", " [-o space | time] [-p] [-S size] [-s avgfpdir]", " special | filesystem"); exit(2); } void usage(void) { fprintf(stderr, "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n" " [-J enable | disable] [-j enable | disable]\n" " [-L volname] [-l enable | disable] [-m minfree]\n" " [-N enable | disable] [-n enable | disable]\n" " [-o space | time] [-p] [-S size] [-s avgfpdir]\n" " special | filesystem\n"); exit(2); } void usage(void) { fprintf(stderr, "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n\ [-J enable | disable] [-j enable | disable]\n\ [-L volname] [-l enable | disable] [-m minfree]\n\ [-N enable | disable] [-n enable | disable]\n\ [-o space | time] [-p] [-S size] [-s avgfpdir]\n\ special | filesystem\n"); exit(2); } --=20 Peter Jeremy --YZ5djTAD1cGYuMQK Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkvf5j0ACgkQ/opHv/APuIeH5wCfd7hzjrnV+K7E4W52xILuvmmx 9MQAoLLSIT/LSRpJ/tSR3lVuBj1FqfdG =VVAd -----END PGP SIGNATURE----- --YZ5djTAD1cGYuMQK-- From owner-freebsd-arch@FreeBSD.ORG Tue May 4 10:58:16 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C69A61065678 for ; Tue, 4 May 2010 10:58:16 +0000 (UTC) (envelope-from gljennjohn@googlemail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 50D118FC1A for ; Tue, 4 May 2010 10:58:15 +0000 (UTC) Received: by fxm15 with SMTP id 15so3460535fxm.13 for ; Tue, 04 May 2010 03:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:reply-to:x-mailer:mime-version :content-type:content-transfer-encoding; bh=gbJ0hDjWB0F5IUZZ79vNPBDLT9DHpTFw5OWYGEFdmwg=; b=K//HuJXgDxf6qMJitip9sGCZ2qkDKCYq0hY+8EdpJEvgGvfhnrNOvDSvHIZnJrt0Ai epvBY9tI4Y9l3RUx6uuk2xJTdoEbCWKEdGdf7MOCiyo6lu2yHaIgGZz5fq+6fZ3WxR31 cVMDHlrTLzdVn9dtRS0QugIDZjvZnVL6/dIJw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :x-mailer:mime-version:content-type:content-transfer-encoding; b=OW60Ofsu3j2WoKjU7SCb0ODXKdjQ7qd29LW8Ji9XNHlsabX2ObijynkZuN6LkaD7md iGqjSFo9q8EeU1OdHzMoDM5WlPDCmxKeA9DfZHBVvN6bk+a2EpoY4KrR9uQlotdnliPN edAMeowXKqbId/1rjegVZEUjIho41ZfXi+BLw= Received: by 10.223.97.149 with SMTP id l21mr3979615fan.91.1272968791526; Tue, 04 May 2010 03:26:31 -0700 (PDT) Received: from ernst.jennejohn.org (p57AE21EB.dip0.t-ipconnect.de [87.174.33.235]) by mx.google.com with ESMTPS id 35sm11131921fkt.37.2010.05.04.03.26.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 May 2010 03:26:31 -0700 (PDT) Date: Tue, 4 May 2010 12:26:29 +0200 From: Gary Jennejohn To: Peter Jeremy Message-ID: <20100504122629.0aa4c2dc@ernst.jennejohn.org> In-Reply-To: <20100504091749.GA58464@server.vk2pj.dyndns.org> References: <20100504091749.GA58464@server.vk2pj.dyndns.org> X-Mailer: Claws Mail 3.7.5 (GTK+ 2.18.7; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: Style question: writing multi-line usage messages X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gljennjohn@googlemail.com List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 10:58:16 -0000 On Tue, 4 May 2010 19:17:49 +1000 Peter Jeremy wrote: > I would appreciate some input on the preferred style for writing > multi-line usage messages. Should: > 1) printf() print a series of 1-line strings > 2) should string gluing be used to turn multiple strings into one for printing > 3) should continuation lines be used to create a single string > > I can't see anything in style(9) to cover this. > > Variants of the tunefs(8) usage() function follow as examples: > > void > usage(void) > { > > fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n", > "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]", > " [-J enable | disable] [-j enable | disable]", > " [-L volname] [-l enable | disable] [-m minfree]", > " [-N enable | disable] [-n enable | disable]", > " [-o space | time] [-p] [-S size] [-s avgfpdir]", > " special | filesystem"); > exit(2); > } > This version requires you to remmeber to add %s\n to the format if you add a new line, something which I personally forget to do all the time. > void > usage(void) > { > > fprintf(stderr, > "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n" > " [-J enable | disable] [-j enable | disable]\n" > " [-L volname] [-l enable | disable] [-m minfree]\n" > " [-N enable | disable] [-n enable | disable]\n" > " [-o space | time] [-p] [-S size] [-s avgfpdir]\n" > " special | filesystem\n"); > exit(2); > } > > void > usage(void) > { > > fprintf(stderr, > "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n\ > [-J enable | disable] [-j enable | disable]\n\ > [-L volname] [-l enable | disable] [-m minfree]\n\ > [-N enable | disable] [-n enable | disable]\n\ > [-o space | time] [-p] [-S size] [-s avgfpdir]\n\ > special | filesystem\n"); > exit(2); > } > I personally don't see all that much difference between these. The first variant has the advantage that it's very clear that you're looking at strings, which might be a good thing. I vote for 2. Couldn't you replace all the leading spaces with \t's? -- Gary Jennejohn From owner-freebsd-arch@FreeBSD.ORG Wed May 5 21:46:07 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 26FC51065674 for ; Wed, 5 May 2010 21:46:07 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail03.syd.optusnet.com.au (mail03.syd.optusnet.com.au [211.29.132.184]) by mx1.freebsd.org (Postfix) with ESMTP id B65278FC19 for ; Wed, 5 May 2010 21:46:06 +0000 (UTC) Received: from c122-106-171-133.carlnfd1.nsw.optusnet.com.au (c122-106-171-133.carlnfd1.nsw.optusnet.com.au [122.106.171.133]) by mail03.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o45Ljrn9006927 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 6 May 2010 07:45:54 +1000 Date: Thu, 6 May 2010 07:45:54 +1000 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Gary Jennejohn In-Reply-To: <20100504122629.0aa4c2dc@ernst.jennejohn.org> Message-ID: <20100506064823.G18787@delplex.bde.org> References: <20100504091749.GA58464@server.vk2pj.dyndns.org> <20100504122629.0aa4c2dc@ernst.jennejohn.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-arch@freebsd.org Subject: Re: Style question: writing multi-line usage messages X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2010 21:46:07 -0000 On Tue, 4 May 2010, Gary Jennejohn wrote: > On Tue, 4 May 2010 19:17:49 +1000 > Peter Jeremy wrote: > >> I would appreciate some input on the preferred style for writing >> multi-line usage messages. Should: I have strong opinions about this of course. >> 1) printf() print a series of 1-line strings I prefer 1 printf per output line in most cases, but for printing several lines of literals as in some usage messages, I prefer (2), since (2) allows making the source string look like the output messsage only in simple cases with literal strings. >> 2) should string gluing be used to turn multiple strings into one for printing I prefer to only use string gluing at newline boundaries. >> 3) should continuation lines be used to create a single string I prefer to avoid using continuation lines. >> I can't see anything in style(9) to cover this. The examples of printfs in style(9) are only for usage(), and they are too simple to cover the multi-line case. >> Variants of the tunefs(8) usage() function follow as examples: >> >> void >> usage(void) >> { >> >> fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n", >> "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]", >> " [-J enable | disable] [-j enable | disable]", >> " [-L volname] [-l enable | disable] [-m minfree]", >> " [-N enable | disable] [-n enable | disable]", >> " [-o space | time] [-p] [-S size] [-s avgfpdir]", >> " special | filesystem"); >> exit(2); >> } > > This version requires you to remmeber to add %s\n to the format if you > add a new line, something which I personally forget to do all the time. This is OK (except for the line splitting -- see below) if pre-StandardC compilers are to be supported. I might prefer a version with harder newlines: fprintf("\ first line\n\ second line\n\ ... " ); > >> void >> usage(void) >> { >> >> fprintf(stderr, >> "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n" >> " [-J enable | disable] [-j enable | disable]\n" >> " [-L volname] [-l enable | disable] [-m minfree]\n" >> " [-N enable | disable] [-n enable | disable]\n" >> " [-o space | time] [-p] [-S size] [-s avgfpdir]\n" >> " special | filesystem\n"); >> exit(2); >> } This is best now, except it splits some lines too early. The correct splitting is the same as the one produced by nroff for formatting the man page -- there is no need to split before "[-L volname]" to fit in 80 columns at either the source or output level. Hopefully the addition of "\n" to the source strings doesn't make them long enough to need reformatting, though it might. The source strings were already 5 columns takes wider than the man page output and the usage() output remains 2 columns wider than the man page output (since man page output is indented 5 columns with spaces, while usage() output is indented 7 columns with "usage: " or spaces, and usage() source takes 3 more columns for 2 quotes and 1 comma, and now 2 more columns for the quoted newline. If the man page output were wider than 78 columns, then the usage() output format should be different to avoid long lines in the output, and if the man page output were wider than 75 or now 73 columns, then the usage source format should be different to avoid long lines in the source. >> >> void >> usage(void) >> { >> >> fprintf(stderr, >> "usage: tunefs [-A] [-a enable | disable] [-e maxbpg] [-f avgfilesize]\n\ >> [-J enable | disable] [-j enable | disable]\n\ >> [-L volname] [-l enable | disable] [-m minfree]\n\ >> [-N enable | disable] [-n enable | disable]\n\ >> [-o space | time] [-p] [-S size] [-s avgfpdir]\n\ >> special | filesystem\n"); >> exit(2); >> } >> > > I personally don't see all that much difference between these. The first variant > has the advantage that it's very clear that you're looking at strings, which might > be a good thing. > > I vote for 2. I agree. > > Couldn't you replace all the leading spaces with \t's? That would: - add a gratuitous dependency on the output file being a terminal configured with 8-column tabs - require the programmer to count the spaces needed after expansion of these tabs - make it harder to see that the results of the previous step are correct. Bruce From owner-freebsd-arch@FreeBSD.ORG Thu May 6 20:07:33 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A1E59106564A for ; Thu, 6 May 2010 20:07:33 +0000 (UTC) (envelope-from mm@FreeBSD.org) Received: from mail.vx.sk (core.vx.sk [188.40.32.143]) by mx1.freebsd.org (Postfix) with ESMTP id 329CC8FC08 for ; Thu, 6 May 2010 20:07:27 +0000 (UTC) Received: from core.vx.sk (localhost [127.0.0.1]) by mail.vx.sk (Postfix) with ESMTP id 561D095681 for ; Thu, 6 May 2010 21:50:28 +0200 (CEST) X-Virus-Scanned: amavisd-new at mail.vx.sk Received: from mail.vx.sk ([127.0.0.1]) by core.vx.sk (mail.vx.sk [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TDhfXhkTlbNb for ; Thu, 6 May 2010 21:50:26 +0200 (CEST) Received: from [127.0.0.1] (chello089173000055.chello.sk [89.173.0.55]) by mail.vx.sk (Postfix) with ESMTPSA id 0CB6A95675 for ; Thu, 6 May 2010 21:50:25 +0200 (CEST) Message-ID: <4BE31D84.3040903@FreeBSD.org> Date: Thu, 06 May 2010 21:50:28 +0200 From: Martin Matuska User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; sk; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: freebsd-arch@freebsd.org X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=windows-1250 Content-Transfer-Encoding: 7bit Subject: RFC: liblzma and xz to FreeBSD base X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 May 2010 20:07:33 -0000 Dear fellow devleopers, I would like to propose an import of liblzma and the utilities xz, xzdec and lzmainfo to base (vendor -> contrib). As I was informed, libarchive is already lzma-ready, some of our existing code could take advantage of liblzma instantly. The source code is imported from: http://tukaani.org/xz/xz-4.999.9beta.tar.gz All GPLv2, LGPLv2.1 and GPLv3 parts are stripped from the code (they cover only the build system and unimportant scripts). liblzma, xz, xzdec, lzmainfo are public domain licensed. A working patchset against HEAD (includes modified lesspipe.sh): http://people.freebsd.org/~mm/patches/xz/ The only patched file is src/common/bswap.h, with the patch from the archivers/xz port. Comments and suggestions are welcome. Thanks, mm From owner-freebsd-arch@FreeBSD.ORG Fri May 7 03:54:46 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B4A61106567C for ; Fri, 7 May 2010 03:54:46 +0000 (UTC) (envelope-from kientzle@freebsd.org) Received: from monday.kientzle.com (kientzle.com [66.166.149.50]) by mx1.freebsd.org (Postfix) with ESMTP id 896EC8FC2A for ; Fri, 7 May 2010 03:54:46 +0000 (UTC) Received: (from root@localhost) by monday.kientzle.com (8.14.3/8.14.3) id o473t1Ir007035; Fri, 7 May 2010 03:55:01 GMT (envelope-from kientzle@freebsd.org) Received: from horton.x.kientzle.com (fw2.kientzle.com [10.123.1.2]) by kientzle.com with SMTP id vutwhbipmdfp954kha6shuj5ja; Fri, 07 May 2010 03:55:01 +0000 (UTC) (envelope-from kientzle@freebsd.org) Message-ID: <4BE38F02.1000802@freebsd.org> Date: Thu, 06 May 2010 20:54:42 -0700 From: Tim Kientzle User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.23) Gecko/20100314 SeaMonkey/1.1.18 MIME-Version: 1.0 To: Martin Matuska References: <4BE31D84.3040903@FreeBSD.org> In-Reply-To: <4BE31D84.3040903@FreeBSD.org> Content-Type: text/plain; charset=windows-1250; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: RFC: liblzma and xz to FreeBSD base X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2010 03:54:46 -0000 This has already been discussed and the consensus was to go ahead with it. I was going to do it myself, but what you have here looks much more complete than what I have locally right now. Go for it. Cheers, Tim Martin Matuska wrote: > Dear fellow devleopers, > > I would like to propose an import of liblzma and the utilities xz, xzdec > and lzmainfo to base (vendor -> contrib). > As I was informed, libarchive is already lzma-ready, some of our > existing code could take advantage of liblzma instantly. > > The source code is imported from: > http://tukaani.org/xz/xz-4.999.9beta.tar.gz > > All GPLv2, LGPLv2.1 and GPLv3 parts are stripped from the code (they > cover only the build system and unimportant scripts). > liblzma, xz, xzdec, lzmainfo are public domain licensed. > > A working patchset against HEAD (includes modified lesspipe.sh): > http://people.freebsd.org/~mm/patches/xz/ > > The only patched file is src/common/bswap.h, with the patch from the > archivers/xz port. > > Comments and suggestions are welcome. > > Thanks, > mm > > > > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" > >