From owner-freebsd-ports@FreeBSD.ORG Mon May 23 08:31:07 2011 Return-Path: Delivered-To: freebsd-ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E30A8106566B for ; Mon, 23 May 2011 08:31:06 +0000 (UTC) (envelope-from utisoft@gmail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 6E6148FC19 for ; Mon, 23 May 2011 08:31:06 +0000 (UTC) Received: by bwz12 with SMTP id 12so6312135bwz.13 for ; Mon, 23 May 2011 01:31:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-type; bh=msN/BR6APiuwY1Z4VYlK+aGEhkWZehW26DPUieRGPIk=; b=rzqouLa1r7KcszRGzaxBXrIdn0cLTx8r5brNmDn2sf/zfyvxKZqWVO/gDZvo+0yuFj A3h06PM4067ZV+18AdBPh4oSmPVdqnh9mEsFYQvl6Uc7DD4MAo5wbV34IM5YcM6X05MD QtdghDTdSaWkpubnseCC779A5s309zWOlPhic= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; b=THoECc5jH5Dz7M83NoZrrtULDwsI63/kNqWcjmEhVvDWrrKwBFUeryO7jjXCSsU8Ty VsQ/wm/6zJuA2Xh1zccJEvv1ZSA9qew7oiXaB60X2Ep+IhWrC0apqY9YhVuVfXbwtHr6 NkD9nTlvB1eMEaci9I8uiwvzZqcUMqguS67N8= Received: by 10.204.151.204 with SMTP id d12mr1796491bkw.127.1306139465089; Mon, 23 May 2011 01:31:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.205.65.198 with HTTP; Mon, 23 May 2011 01:30:35 -0700 (PDT) In-Reply-To: <20110522205003.GH59496@hoeg.nl> References: <20110522205003.GH59496@hoeg.nl> From: Chris Rees Date: Mon, 23 May 2011 09:30:35 +0100 Message-ID: To: Ed Schouten Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-ports@freebsd.org Subject: Re: Utmpx usage X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: utisoft@gmail.com List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 May 2011 08:31:07 -0000 On 22 May 2011 21:50, Ed Schouten wrote: > Hi Chris! > > * Chris Rees , 20110522 09:29: >> Hi all, >> >> After removing all kittens from Ed's reach, I'm disclosing that >> sysutils/runit tried to use utmpx to directly read() and write() the >> utmpx files directly... >> >> I've replaced the offending code with a patch to the port [1], but I >> wonder if anyone would please review the patch? I don't have a CURRENT >> machine to try it on... I may have also made some terrible mistakes -- >> I'm not hugely familiar with utmpx. >> >> Thanks! >> >> Chris >> >> [1] http://www.bayofrum.net/~crees/patches/runit-utmpx.patch > > As promised, I would look at your patch this evening. I've changed the > cc to ports@, since it's likely a better place to discuss this. > > First of all, you can remove the getutxent()/endutxent() calls; at least > on FreeBSD (but even on Solaris -- the first OS to implement utmpx) > pututxline() is implemented separately from the read-functions. There is > no need to open the database for reading. > > Secondly, please make sure you set the proper fields of the utmpx > structure. Always zero it (e.g. with memset()) before calling > pututxline() to prevent random junk from ending up in the log files. > Also, for DEAD_PROCESS must we set ut_id, but not ut_line. ut_id must be > set to one of the identifiers of an existing session. These identifiers > can be set to arbitrary values by the application that added the entry. > Some apps are lazy and just put the TTY name in there, but you cannot > assume that that's the case. Run `getent utmpx active' to see what the > identifiers look like. For example, pam_lastlog(8) uses random > identifiers. You must also set ut_tv, even though our implementation > does it for you. > > Finally, I'm not really sure what the code is trying to solve here. > What's the use of implementing an utmp_logout(), to simulate logouts on > the utmp database, without actually providing code to perform logins? > Maybe we should just patch runit to leave utmp(x) alone. So far I don't > have a feeling it's trying to do something useful with it. > Thanks for the pointers! I'll get those in. The code is for a utility for recording logouts in utmp(x) [1] -- there's no facility provided for utmp logins. Perhaps we should just comment out the code and leave utmpset as unimplemented. Chris [1] http://smarden.org/runit/utmpset.8.html