From: Максим <herobrine135111@gmail.com>
To: Oliver Kiddle <opk@zsh.org>
Cc: zsh-workers@zsh.org
Subject: Re: $watch, log and Cyrillic usernames
Date: Sun, 8 Oct 2023 09:20:08 +0300 [thread overview]
Message-ID: <CAHJ=x4ah2U+xejoHed0GQPmSCEOZEjY0LCfFxNQFMtdcWR1XaA@mail.gmail.com> (raw)
In-Reply-To: <4465-1696724666.376518@Uh7s.ZzUp.FcHY>
[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]
Tested:
% watch=(all); log
root has logged on /proc/10045/fd/2 from .
Студент has logged on pts/29 from 127.0.0.1.
% watch=(notme); log
root has logged on /proc/10045/fd/2 from .
% watch=(Студент); log
Студент has logged on pts/29 from 127.0.0.1.
Everything works now, thanks
Sent via Gmail
вс, 8 окт. 2023 г., 03:24 Oliver Kiddle <opk@zsh.org>:
> Максим 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=(notme); log # Broken
> > root has logged on /proc/10045/fd/2 from .
> > Студент has logged on pts/29 from 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 = 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 = 0;
>
[-- Attachment #2: Type: text/html, Size: 3471 bytes --]
next prev parent reply other threads:[~2023-10-08 6:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 21:29 Максим
2023-10-05 21:42 ` Bart Schaefer
2023-10-07 2:05 ` Oliver Kiddle
2023-10-07 16:49 ` Максим
2023-10-08 0:24 ` Oliver Kiddle
2023-10-08 6:20 ` Максим [this message]
2023-10-08 21:47 ` metafy() (was Re: $watch, log and Cyrillic usernames) Oliver Kiddle
2023-10-09 2:01 ` Bart Schaefer
2023-10-10 21:46 ` Oliver Kiddle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHJ=x4ah2U+xejoHed0GQPmSCEOZEjY0LCfFxNQFMtdcWR1XaA@mail.gmail.com' \
--to=herobrine135111@gmail.com \
--cc=opk@zsh.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).