From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/4363 Path: news.gmane.org!not-for-mail From: Raphael Cohn Newsgroups: gmane.linux.lib.musl.general Subject: Re: Patch to musl to provide wtmp for Linux PAM Date: Wed, 4 Dec 2013 16:40:51 +0000 Message-ID: References: <20131204162046.GX1685@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11330af2773ea904ecb813ee X-Trace: ger.gmane.org 1386175259 16190 80.91.229.3 (4 Dec 2013 16:40:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 4 Dec 2013 16:40:59 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-4367-gllmg-musl=m.gmane.org@lists.openwall.com Wed Dec 04 17:41:06 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1VoFVZ-0006WN-8V for gllmg-musl@plane.gmane.org; Wed, 04 Dec 2013 17:41:05 +0100 Original-Received: (qmail 28498 invoked by uid 550); 4 Dec 2013 16:41:04 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 28490 invoked from network); 4 Dec 2013 16:41:04 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=zSHrToUeO6kcMGrDl8kkRAckfDvF7IxHBpyuRT6Don4=; b=WpY3NxhBcp/S5PXSsUtglNdhVgVautL6c4ivtt7GVgtnNvcTfVFjj5digttMvUqyzU xqO4VZD5CP7XGHYb+U6IrMEleti+UrTyODSWhLfn+iOalzmq0UhYcvYbd5kXdsMlzf4I +rZZkYS/0QsA4+8Ekwroh0l5IDkVJRjnld80C924HJb6oS/IuP+hSfhOMqihywGq5k/E 7wUaXZMaJ1jwM9C1vchADSy5wpCbJpwqXjzZ+A73+v5MrCpZNRBu2KZATKtBMYBI/sBk 00y5bcKZqPDQYR+1sFZag3IenEFz/xJ2zMMCNS13VY+a06/4sZmzwB0cIO8tUYsD0zFe ML4w== X-Gm-Message-State: ALoCoQnArRYpKF3xT1H0Qg+bLAZP4zX9p1cPOBgrzFKAd+CHHz//5QhRioWDlkJCJJZeXNjfQx6f X-Received: by 10.60.68.83 with SMTP id u19mr1365575oet.74.1386175251556; Wed, 04 Dec 2013 08:40:51 -0800 (PST) X-Originating-IP: [2001:8b0:862:b944:5e8:bd81:6ce5:582e] In-Reply-To: <20131204162046.GX1685@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:4363 Archived-At: --001a11330af2773ea904ecb813ee Content-Type: text/plain; charset=UTF-8 Thanks for the reply - I realise udpwtmp is a stub, but if it ever changes... although policy would seem to make that unlikely. The only reason I can really see to deviate from this policy is to support the various security / monitoring tools. From memory, things like splunk might use it. As an aside, I actually used the *tmp files to debug random restarts of Azure linux instances earlier this year... (for the list, the problem was with Azure). Given the policy I'm minded to write a private patch for updwtmp captures some of these details and sends them to authpriv. Other things are more pressing though... On 4 December 2013 16:20, Szabolcs Nagy wrote: > * Raphael Cohn [2013-12-04 14:49:32 +0000]: > > By the way, are there any plans to support writing to lastlog / wtmp / > etc? > > If not, I might create a private patch to redirect the writes to syslog. > In > > my view, this is where information like this belongs... > > http://www.openwall.com/lists/musl/2012/03/04/4 > > i think the policy hasn't changed since > > > --- musl-0.9.14.orig/include/utmpx.h 2013-09-23 22:01:11.000000000 > +0100 > > +++ musl-0.9.14/include/utmpx.h 2013-12-04 10:32:20.000000000 +0000 > > @@ -13,6 +13,8 @@ > > #include > > > > #define UT_LINESIZE 32 > > +#define UT_NAMESIZE 32 > > +#define UT_HOSTSIZE 256 > > > > note that utmpx.h is defined in posix (part of the XSI option) > and UT_ is not reserved prefix for it so even the UT_LINESIZE > is a namespace violation (although a rather harmless one) > > i attach a current list of namespace violations in musl based on > http://port70.net/~nsz/c/posix/reserved.txt > > > +++ musl-0.9.14/src/legacy/utmp.c 2013-12-04 14:25:40.000000000 +0000 > > @@ -0,0 +1,20 @@ > > +#include > > +#include > > +#include > > +#include > > +#include "libc.h" > > + > > +void logwtmp(const char * line, const char * name, const char * host) > > +{ > > + struct utmp u; > > + memset(&u, 0, sizeof(u)); > > + > > + u.ut_pid = getpid(); > > + u.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS; > > + strncpy(u.ut_line, line, sizeof(u.ut_line)); > > + strncpy(u.ut_name, name, sizeof(u.ut_name)); > > + strncpy(u.ut_host, host, sizeof(u.ut_host)); > > + gettimeofday(&(u.ut_tv), NULL); > > + > > + updwtmp(_PATH_WTMP, &u); > > +} > > note that updwtmp is just a stub so this logwtmp does not do much > --001a11330af2773ea904ecb813ee Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks for the reply - I realise udpwtmp is a st= ub, but if it ever changes... although policy would seem to make that unlik= ely. The only reason I can really see to deviate from this policy is to sup= port the various security / monitoring tools. From memory, things like splu= nk might use it.

As an aside, I actually used the *tmp files to debug random resta= rts of Azure linux instances earlier this year... (for the list, the proble= m was with Azure).

Given the policy I'm minded to write a = private patch for updwtmp captures some of these details and sends them to = authpriv. Other things are more pressing though...

On= 4 December 2013 16:20, Szabolcs Nagy <nsz@port70.net> wrote:
* Raphael Cohn <raphael.cohn= @stormmq.com> [2013-12-04 14:49:32 +0000]:
> By the way, are there any plans to support writing t= o lastlog / wtmp / etc?
> If not, I might create a private patch to redirect the writes to syslo= g. In
> my view, this is where information like this belongs...

http://www.openwall.com/lists/musl/2012/03/04/4

i think the policy hasn't changed since

> --- musl-0.9.14.orig/include/utmpx.h =C2=A0 =C2=A02013-09-23 22:01:11.= 000000000 +0100
> +++ musl-0.9.14/include/utmpx.h =C2=A0 =C2=A02013-12-04 10:32:20.00000= 0000 +0000
> @@ -13,6 +13,8 @@
> =C2=A0#include <bits/alltypes.h>
>
> =C2=A0#define UT_LINESIZE 32
> +#define UT_NAMESIZE 32
> +#define UT_HOSTSIZE 256
>

note that utmpx.h is defined in posix (part of the XSI option)
and UT_ is not reserved prefix for it so even the UT_LINESIZE
is a namespace violation (although a rather harmless one)

i attach a current list of namespace violations in musl based on
h= ttp://port70.net/~nsz/c/posix/reserved.txt

> +++ musl-0.9.14/src/legacy/utmp.c =C2=A0 =C2=A02013-12-04 14:25:40.000= 000000 +0000
> @@ -0,0 +1,20 @@
> +#include <utmp.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/time.h>
> +#include "libc.h"
> +
> +void logwtmp(const char * line, const char * name, const char * host)=
> +{
> + =C2=A0 =C2=A0struct utmp u;
> + =C2=A0 =C2=A0memset(&u, 0, sizeof(u));
> +
> + =C2=A0 =C2=A0u.ut_pid =3D getpid();
> + =C2=A0 =C2=A0u.ut_type =3D name[0] ? USER_PROCESS : DEAD_PROCESS; > + =C2=A0 =C2=A0strncpy(u.ut_line, line, sizeof(u.ut_line));
> + =C2=A0 =C2=A0strncpy(u.ut_name, name, sizeof(u.ut_name));
> + =C2=A0 =C2=A0strncpy(u.ut_host, host, sizeof(u.ut_host));
> + =C2=A0 =C2=A0gettimeofday(&(u.ut_tv), NULL);
> +
> + =C2=A0 =C2=A0updwtmp(_PATH_WTMP, &u);
> +}

note that updwtmp is just a stub so this logwtmp does not do much

--001a11330af2773ea904ecb813ee--