From owner-freebsd-audit Sat Aug 17 2:15: 4 2002 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 047C637B400 for ; Sat, 17 Aug 2002 02:14:59 -0700 (PDT) Received: from mail.tgd.net (mail.tgd.net [209.81.25.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBA2743E4A for ; Sat, 17 Aug 2002 02:14:58 -0700 (PDT) (envelope-from sean@mail.tgd.net) Received: by mail.tgd.net (Postfix, from userid 1001) id 40E9420F05; Fri, 16 Aug 2002 11:36:44 -0700 (PDT) Date: Fri, 16 Aug 2002 11:36:44 -0700 From: Sean Chittenden To: audit@FreeBSD.org Subject: [sean@chittenden.org: w/uptime warning inappropriately under xdm/kdm [patch]...] Message-ID: <20020816183644.GL15682@ninja1.internal> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nhYGnrYv1PEJ5gA2" Content-Disposition: inline User-Agent: Mutt/1.4i X-PGP-Key: finger seanc@FreeBSD.org X-PGP-Fingerprint: 6CEB 1B06 BFD3 70F6 95BE 7E4D 8E85 2E0A 5F5B 3ECB X-Web-Homepage: http://sean.chittenden.org/ Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --nhYGnrYv1PEJ5gA2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline [This is a repost from a current@ posting] When logging into a system via xdm/kdm, the wtmp/utmp entries aren't being set correctly. As a result, when you call w(1), you get a nice pair of warnings: $ w w: /dev/:0: No such file or directory w: /dev/:0: No such file or directory 11:33AM up 5 days, 17:02, 0 users, load averages: 0.08, 0.07, 0.08 USER TTY FROM LOGIN@ IDLE WHAT The attached (tiny) patch suppresses the warning and deals with it in the same way that who(1) does. -sc -- Sean Chittenden --nhYGnrYv1PEJ5gA2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I've switched one of my desktops to using kdm and I've noticed that w(1) creates suprious warnings because it can't find the tty entry. $ w w: /dev/:0: No such file or directory w: /dev/:0: No such file or directory 2:41AM up 49 mins, 0 users, load averages: 0.05, 0.04, 0.04 USER TTY FROM LOGIN@ IDLE WHAT $ I've included a patch that quiets this. The attached patch is inline with the behavior from who(1). Are there any objections to it? What should be the correct behaviour when loggin in via xdm/kdm? Is there a better way to detect that you're logged in via xdm/kdm? Should w(1) iterate through utmp/wtmp to get user info? -sc -- Sean Chittenden --nhYGnrYv1PEJ5gA2 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Index: w.c =================================================================== RCS file: /home/ncvs/src/usr.bin/w/w.c,v retrieving revision 1.54 diff -u -r1.54 w.c --- w.c 2002/06/07 01:41:54 1.54 +++ w.c 2002/08/09 09:57:17 @@ -491,11 +491,10 @@ char ttybuf[MAXPATHLEN]; (void)snprintf(ttybuf, sizeof(ttybuf), "%s%.*s", _PATH_DEV, sz, line); - if (stat(ttybuf, &sb)) { - warn("%s", ttybuf); + if (stat(ttybuf, &sb) == 0) { + return (&sb); + } else return (NULL); - } - return (&sb); } static void --nhYGnrYv1PEJ5gA2-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message