From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7460 invoked from network); 8 Oct 2023 06:20:42 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Oct 2023 06:20:42 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1696746042; b=JtQZhei9em4Zqup4jf76FkChWJ7kQCMBDRmqVDX7pEVmpQWKg1Fb393YMiOnzn4PgMhZSNor/H X2awnN+1EwttBqPbApPJM+awBxHZhXM5QP3wk34bXyvpgR6WKlL6sgJqsBJAMexvLTf9D8FlaG slQs4mPoDqMVK8u1BMAB5t6VFo2lFAlfipm0C5YNkdsYGkU57s2D7n1kvzqOcyMI+CDdhRA8/E PQoc9G9STOT7Af3x+ReeYYrR3WgavYhgWftwHFy4XpImXyOZ9YR7LQlA02WXn4qYwVwTwBbvCl M9cPV1Y8veo4Qr1KHn21IZx8BRuql+Y2/QTQu/e9gMYW/g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f42.google.com) smtp.remote-ip=209.85.167.42; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1696746042; bh=rvNgWU9fNc0sXuonQ7IRv9J5D+jBXRjyVfekANf0Kag=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=PiyiY0fTZM493obYxaIN0sqxY90aqJeg+Hl+Y7Bm/yBkej296jXZqYEPePlL8xjf7lnPoUvrcB oqdrT5/e4ck7w72nTWLSbk6r24FH1XJ5LOIAn0E/kXLtmvmOE0r3X7ZdQL4/at/HoLNichfG08 P1EiVY0HLhgAISgN1MV2Ze6XFaRV/Y04H4EG+1IJvtPZkuJUm9JSbNviBJwdUoWorYX25JfR1R fXjv7IBglVantN/LwQ3exJornBpSNcZcFyygOMStjBuJ6LjisNf/VfI3SCMwMbSoBb4rri6uzf uaCiqk+kcafeY/ulnYSeGz1VvbtaiE5FlT/A6+AP4AjnGQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=u4NWUk8yzLfGkdpi6gCln1P3qMCG5TJA81++drUpmMs=; b=TwJdpr7U2Cvoamxrh4igChoqlR 7+izwtg/yxkFGgzBrn0qjBDv3r0vmZtWSYpN/VYkpaoIY2/i8RaEB544Gt3XHomThZkghmhm6AU9h K6NZT9MCg1PyAbHz82uJfjFXWETaSgXaFTfOCIaIEy0gbbLSTVzpft4KeTEbilriRMIvw47busGdf ekoU2z6yl1TjSF0gdAC+QdrUskakc+w7gMv2P2dr9gdZCttuci4m6HNmWoFQ3dBp7pAs5GNlEnPc2 Gssk1SH5+uVxYRwKwyEQDuKEkKXs3s1PlDbZprRaMRGN1F7z0NEKn0nt+VZkcmlGwlVp05wc0PAh1 mBRvrF9g==; Received: by zero.zsh.org with local id 1qpN9d-00051t-OK; Sun, 08 Oct 2023 06:20:41 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f42.google.com) smtp.remote-ip=209.85.167.42; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f42.google.com ([209.85.167.42]:55304) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qpN9K-0004m4-BM; Sun, 08 Oct 2023 06:20:23 +0000 Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-505a62d24b9so4206531e87.2; Sat, 07 Oct 2023 23:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696746021; x=1697350821; darn=zsh.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=u4NWUk8yzLfGkdpi6gCln1P3qMCG5TJA81++drUpmMs=; b=aAuDFqZuZMo3h+yb6Sl9iQBILAcyjKJExC1GIFqmdSDsjoHbonlx7lbQYi2HFCPa9L EfyMsb6P6DkhqKbkJo1FHCNyJIIVsnEvw4jXKnYXl3g17x6BlNCilaxx99CziL8OzTsw 5OU+8kJScghK8pKiPAnQa2Rco7mGBlgRpZcn1hY7V/i4vhtvCgLTJnKjrKVNuGv7pcdM BtgWKLEg9PAD3a5ECTnRzdckQ21/8TDtYPQPMkLW4dI+MjYFyAxP/D4qlz3aIWpb749w AXSE9rp9C6I4puI4bLAJIa7iXrhqFn9Hzm5tdOpkKPcnBEftciZBy6HoiOh2BCOUwZqK 4GRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696746021; x=1697350821; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=u4NWUk8yzLfGkdpi6gCln1P3qMCG5TJA81++drUpmMs=; b=JfVgM9MgC7hAA6HOM+d7R8wuiYJorVNxIarwmWr+pgbjk9fH4zOtbjy+b8Zy9aHYfP Oy8C/ku0y3kl26vxYxVz7vPVzYwSJR4GoouLsV1ayGvdlnTsndrPp/Q3DeYCCtCDdpOK V5m0+hmavdbTP8OwB3jEY44s8lNScw7NOLSO+fMkXzwiiCsKb4MHqx4eWCAPCoU0/An1 MSkE7OthuQtwTq1zAJrdjVmOdDZIFkR/4iS5PEzKZQCvo4s1mjr/o0ZczNcvcJ1A13W6 NxtOhxclVq075ldcZLznU6fAj3hZ192X5RBbI5RuE1OzUP8ZAxpN+O1DXuS2kXm+UgN7 JCUw== X-Gm-Message-State: AOJu0Yy/GzHCeo8QdXUTTjbPAhIO7cIk+7Fgp+nhfnHCSCNF4dUfWR6j PuzetX7ftBgbstMAwwgGJ18Fz7PTBab4gyK6ihCALi7leZfAhA== X-Google-Smtp-Source: AGHT+IEXhQ2QOTTEAM+vl/9MtmfouTC+EKwzPAnX7oLCMkoXOTyxoKn47q/eflVfCsdE/nV7IfcE8NmhyQekMIvNd4Q= X-Received: by 2002:a19:5004:0:b0:503:3245:6eda with SMTP id e4-20020a195004000000b0050332456edamr10524665lfb.40.1696746020569; Sat, 07 Oct 2023 23:20:20 -0700 (PDT) MIME-Version: 1.0 References: <51326-1696644317.959346@Oqom.p2Z_.86FS> <4465-1696724666.376518@Uh7s.ZzUp.FcHY> In-Reply-To: <4465-1696724666.376518@Uh7s.ZzUp.FcHY> From: =?UTF-8?B?0JzQsNC60YHQuNC8?= Date: Sun, 8 Oct 2023 09:20:08 +0300 Message-ID: Subject: Re: $watch, log and Cyrillic usernames To: Oliver Kiddle Cc: zsh-workers@zsh.org Content-Type: multipart/alternative; boundary="000000000000d48ab206072e77dd" X-Seq: 52212 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --000000000000d48ab206072e77dd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Tested: % watch=3D(all); log root has logged on /proc/10045/fd/2 from . =D0=A1=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82 has logged on pts/29 from 12= 7.0.0.1. % watch=3D(notme); log root has logged on /proc/10045/fd/2 from . % watch=3D(=D0=A1=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82); log =D0=A1=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82 has logged on pts/29 from 12= 7.0.0.1. Everything works now, thanks Sent via Gmail =D0=B2=D1=81, 8 =D0=BE=D0=BA=D1=82. 2023 =D0=B3., 03:24 Oliver Kiddle : > =D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC wrote: > > Found out that there is no need in bypassing "adduser", as this command > works > > just fine: > > These utilities can be quite distribution specific. There is no adduser > command on my system but the old manual approach is always possible. I > also looked into how last is able to print longer usernames and it's > using sqlite and a library for access. The 32 char limit is specific to > the getutxent() interface and could be different on other systems. > > > % watch=3D(notme); log # Broken > > root has logged on /proc/10045/fd/2 from . > > =D0=A1=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82 has logged on pts/29 fro= m 127.0.0.1. > > Thanks for testing. "notme" is handled separately and the patch below > should be applied on top of the previous one. > > The w++ line is a minor change from the old behaviour - moving on from > a notme entry. An alternative would be to move the return from just > above to that line. > > The code is arguably now wasting time and memory metafying the same > strings multiple times. We could convert the whole utmp structure > up-front. Not sure that's worth the bother, though (?). > > Oliver > > diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c > index 2ad962fb6..d30f5ff98 100644 > --- a/Src/Modules/watch.c > +++ b/Src/Modules/watch.c > @@ -458,10 +458,14 @@ watchlog(int inout, WATCH_STRUCT_UTMP *u, char **w, > char *fmt) > (void)watchlog2(inout, u, fmt, 1, 0); > return; > } > - if (*w && !strcmp(*w, "notme") && > - strncmp(u->ut_name, get_username(), sizeof(u->ut_name))) { > - (void)watchlog2(inout, u, fmt, 1, 0); > - return; > + if (*w && !strcmp(*w, "notme")) { > + char *username =3D metafy(u->ut_name, > + strnlen(u->ut_name, sizeof(u->ut_name)), META_USEHEAP); > + if (strcmp(username, get_username())) { > + (void)watchlog2(inout, u, fmt, 1, 0); > + return; > + } > + w++; > } > for (; *w; w++) { > bad =3D 0; > --000000000000d48ab206072e77dd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Tested:
% watch=3D(all); log
=C2=A0 =C2=A0 root has logged on /proc/10045/fd/2 from .<= /font>
=C2=A0 =C2=A0 =D0=A1= =D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82 has logged on pts/29 from 127.0.0.1.

% watch=3D(notme);= log
=C2=A0 =C2=A0 root has = logged on /proc/10045/fd/2 from .

<= div dir=3D"auto">% watch=3D(=D0=A1=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82); lo= g
=C2=A0 =C2=A0 =D0=A1=D1=82= =D1=83=D0=B4=D0=B5=D0=BD=D1=82 has logged on pts/29 from 127.0.0.1.<= /div>

Everything works now, th= anks

Sent via Gmail
<= br>
=D0=B2= =D1=81, 8 =D0=BE=D0=BA=D1=82. 2023 =D0=B3., 03:24 Oliver Kiddle <opk@zsh.org>:
=D0=9C=D0=B0=D0=BA=D1=81=D0= =B8=D0=BC wrote:
> Found out that there is no need in bypassing "adduser", as t= his command works
> just fine:

These utilities can be quite distribution specific. There is no adduser
command on my system but the old manual approach is always possible. I
also looked into how last is able to print longer usernames and it's using sqlite and a library for access. The 32 char limit is specific to
the getutxent() interface and could be different on other systems.

> % watch=3D(notme); log # Broken
> =C2=A0 =C2=A0 root has logged on /proc/10045/fd/2 from .
> =C2=A0 =C2=A0 =D0=A1=D1=82=D1=83=D0=B4=D0=B5=D0=BD=D1=82 has logged on= pts/29 from 127.0.0.1.

Thanks for testing. "notme" is handled separately and the patch b= elow
should be applied on top of the previous one.

The w++ line is a minor change from the old behaviour - moving on from
a notme entry. An alternative would be to move the return from just
above to that line.

The code is arguably now wasting time and memory metafying the same
strings multiple times. We could convert the whole utmp structure
up-front. Not sure that's worth the bother, though (?).

Oliver

diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c
index 2ad962fb6..d30f5ff98 100644
--- a/Src/Modules/watch.c
+++ b/Src/Modules/watch.c
@@ -458,10 +458,14 @@ watchlog(int inout, WATCH_STRUCT_UTMP *u, char **w, c= har *fmt)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (void)watchlog2(inout, u, fmt, 1, 0);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 return;
=C2=A0 =C2=A0 =C2=A0}
-=C2=A0 =C2=A0 if (*w && !strcmp(*w, "notme") &&<= br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0strncmp(u->ut_name, get_username(), sizeof(u= ->ut_name))) {
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(void)watchlog2(inout, u, fmt, 1, 0);
-=C2=A0 =C2=A0 =C2=A0 =C2=A0return;
+=C2=A0 =C2=A0 if (*w && !strcmp(*w, "notme")) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 char *username =3D metafy(u->ut_name,
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0strnlen(u->ut_na= me, sizeof(u->ut_name)), META_USEHEAP);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0if (strcmp(username, get_username())) {
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(void)watchlog2(inout, u, fmt, 1,= 0);
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return;
+=C2=A0 =C2=A0 =C2=A0 =C2=A0}
+=C2=A0 =C2=A0 =C2=A0 =C2=A0w++;
=C2=A0 =C2=A0 =C2=A0}
=C2=A0 =C2=A0 =C2=A0for (; *w; w++) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 bad =3D 0;
--000000000000d48ab206072e77dd--