NetBSD Problem Report #56013
From www@netbsd.org Tue Feb 23 14:48:45 2021
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id 48F4C1A921F
for <gnats-bugs@gnats.NetBSD.org>; Tue, 23 Feb 2021 14:48:45 +0000 (UTC)
Message-Id: <20210223144843.C840D1A9249@mollari.NetBSD.org>
Date: Tue, 23 Feb 2021 14:48:43 +0000 (UTC)
From: hashikaw@mail.ru
Reply-To: hashikaw@mail.ru
To: gnats-bugs@NetBSD.org
Subject: systat vm reports incorrect number of users, when user login/logout
X-Send-Pr-Version: www-1.0
>Number: 56013
>Category: bin
>Synopsis: systat vm reports incorrect number of users, when user login/logout
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Feb 23 14:50:00 +0000 2021
>Closed-Date: Fri Apr 19 02:36:51 +0000 2024
>Last-Modified: Fri Apr 19 02:36:51 +0000 2024
>Originator: Kouichi Hashikawa
>Release: NetBSD-9.99.80
>Organization:
>Environment:
NetBSD 9.99.80 (GENERIC64) #0: Sat Feb 20 22:18:32 UTC 2021
mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/evbarm/compile/GENERIC64
>Description:
systat vm reports incorrect number of users, when user login/logout.
o move setutxent(),setutent() to just before getutxent(),getutent().
o copy struct by memcpy.
o line 220 if ((etype & (1 << USER_PROCESS)) != 0) is always true
(line 73 int etype = 1 << USER_PROCESS), and USER_PROCESS is for
utmpx(defined in utmpx.h).
>How-To-Repeat:
>Fix:
diff -u src/usr.bin/who/utmpentry.c-dist src/usr.bin/who/utmpentry.c
--- utmpentry.c-dist 2019-10-06 08:35:57.000000000 +0900
+++ utmpentry.c 2021-02-23 23:08:18.109425752 +0900
@@ -95,14 +95,7 @@
struct stat st;
const char *sfname;
- if (fname == NULL) {
-#ifdef SUPPORT_UTMPX
- setutxent();
-#endif
-#ifdef SUPPORT_UTMP
- setutent();
-#endif
- } else {
+ if (fname != NULL) {
size_t len = strlen(fname);
if (len == 0)
errx(1, "Filename cannot be 0 length.");
@@ -133,9 +126,10 @@
what &= ~1;
} else {
if (timespeccmp(&st.st_mtimespec, &utmpxtime, >))
- utmpxtime = st.st_mtimespec;
+ memcpy(&utmpxtime, &st.st_mtimespec,
+ sizeof(struct timespec));
else
- what &= ~1;
+ what &= ~1;
}
}
#endif
@@ -147,7 +141,8 @@
what &= ~2;
} else {
if (timespeccmp(&st.st_mtimespec, &utmptime, >))
- utmptime = st.st_mtimespec;
+ memcpy(&utmptime, &st.st_mtimespec,
+ sizeof(struct timespec));
else
what &= ~2;
}
@@ -204,6 +199,7 @@
#endif
#ifdef SUPPORT_UTMPX
+ setutxent();
while ((what & 1) && (utx = getutxent()) != NULL) {
if (fname == NULL && ((1 << utx->ut_type) & etype) == 0)
continue;
@@ -218,27 +214,26 @@
#endif
#ifdef SUPPORT_UTMP
- if ((etype & (1 << USER_PROCESS)) != 0) {
- while ((what & 2) && (ut = getutent()) != NULL) {
- if (fname == NULL && (*ut->ut_name == '\0' ||
- *ut->ut_line == '\0'))
- continue;
- /* Don't process entries that we have utmpx for */
- for (ep = ehead; ep != NULL; ep = ep->next) {
- if (strncmp(ep->line, ut->ut_line,
- sizeof(ut->ut_line)) == 0)
- break;
- }
- if (ep != NULL)
- continue;
- if ((ep = calloc(1, sizeof(*ep))) == NULL) {
- warn(NULL);
- return 0;
- }
- getentry(ep, ut);
- *nextp = ep;
- nextp = &(ep->next);
+ setutent();
+ while ((what & 2) && (ut = getutent()) != NULL) {
+ if (fname == NULL && (*ut->ut_name == '\0' ||
+ *ut->ut_line == '\0'))
+ continue;
+ /* Don't process entries that we have utmpx for */
+ for (ep = ehead; ep != NULL; ep = ep->next) {
+ if (strncmp(ep->line, ut->ut_line,
+ sizeof(ut->ut_line)) == 0)
+ break;
}
+ if (ep != NULL)
+ continue;
+ if ((ep = calloc(1, sizeof(struct utmpentry))) == NULL) {
+ warn(NULL);
+ return 0;
+ }
+ getentry(ep, ut);
+ *nextp = ep;
+ nextp = &(ep->next);
}
#endif
numutmp = 0;
@@ -318,7 +313,7 @@
memcpy(e->line, up->ut_line, sizeof(up->ut_line));
memcpy(e->host, up->ut_host, sizeof(up->ut_host));
- e->tv = up->ut_tv;
+ memcpy(&e->tv, &up->ut_tv, sizeof(struct timeval));
e->pid = up->ut_pid;
e->term = up->ut_exit.e_termination;
e->exit = up->ut_exit.e_exit;
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56013 CVS commit: src/usr.bin/who
Date: Thu, 25 Feb 2021 21:45:43 -0500
Module Name: src
Committed By: christos
Date: Fri Feb 26 02:45:43 UTC 2021
Modified Files:
src/usr.bin/who: utmpentry.c
Log Message:
PR/56013: Kouichi Hashikawa: Move setutent/setutxent right before the loops.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/who/utmpentry.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Christos Zoulas <christos@zoulas.com>
To: gnats-bugs@netbsd.org
Cc: gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: bin/56013: systat vm reports incorrect number of users, when user
login/logout
Date: Thu, 25 Feb 2021 21:48:01 -0500
--Apple-Mail=_79D49B66-0FDD-477F-AFF8-615478C3D12E
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
Thanks!
1. struct assignment works fine, I am not changing them to memcpy()
2. etype is global and can be set by a caller to something else aside =
USER_PROCESS; in that case we should not count any of the utmp entries =
(since they are only USER_PROCESS).
christos
--Apple-Mail=_79D49B66-0FDD-477F-AFF8-615478C3D12E
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=signature.asc
Content-Type: application/pgp-signature;
name=signature.asc
Content-Description: Message signed with OpenPGP
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
iF0EARECAB0WIQS+BJlbqPkO0MDBdsRxESqxbLM7OgUCYDhhYQAKCRBxESqxbLM7
Og/xAJ9odXjb9wdm2v7DdqY2iHuajerIigCeKAjwRSHFADTQZCPs7tDc3Lei+Rk=
=hSM0
-----END PGP SIGNATURE-----
--Apple-Mail=_79D49B66-0FDD-477F-AFF8-615478C3D12E--
State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Fri, 26 Feb 2021 06:34:01 +0000
State-Changed-Why:
christos committed a change, does it fix the problem?
From: Kouichi Hashikawa <hashikaw@mail.ru>
To: gnats-bugs@netbsd.org
Cc: christos@netbsd.org, wiz@netbsd.org
Subject: Re: bin/56013 (systat vm reports incorrect number of users, when user login/logout)
Date: Sat, 27 Feb 2021 16:49:58 +0900
> State-Changed-Why:
> christos committed a change, does it fix the problem?
The problem is fixed. Thank you.
Please pull-up to netbsd-9 branch.
(also bin/56009, lib/56010, lib/56012).
--
Kouichi Hashikawa
State-Changed-From-To: feedback->needs-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 09 Jun 2021 03:52:24 +0000
State-Changed-Why:
pullup to -9 desired
also note that the submitter's mailhost is rejecting gnats mails as spam,
so getting feedback may be difficult in general.
State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Thu, 04 Apr 2024 23:02:58 +0000
State-Changed-Why:
pullup-9 #1833
pullup-8 #1958
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56013 CVS commit: [netbsd-9] src/usr.bin/who
Date: Thu, 18 Apr 2024 16:09:09 +0000
Module Name: src
Committed By: martin
Date: Thu Apr 18 16:09:09 UTC 2024
Modified Files:
src/usr.bin/who [netbsd-9]: utmpentry.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1833):
usr.bin/who/utmpentry.c: revision 1.22
PR/56013: Kouichi Hashikawa: Move setutent/setutxent right before the loops.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.18.1 src/usr.bin/who/utmpentry.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/56013 CVS commit: [netbsd-8] src/usr.bin/who
Date: Thu, 18 Apr 2024 16:10:17 +0000
Module Name: src
Committed By: martin
Date: Thu Apr 18 16:10:17 UTC 2024
Modified Files:
src/usr.bin/who [netbsd-8]: utmpentry.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1958):
usr.bin/who/utmpentry.c: revision 1.22
PR/56013: Kouichi Hashikawa: Move setutent/setutxent right before the loops.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.18.8.1 src/usr.bin/who/utmpentry.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Fri, 19 Apr 2024 02:36:51 +0000
State-Changed-Why:
fixed and pulled up
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2024
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.