NetBSD Problem Report #56387

From www@netbsd.org  Fri Sep  3 17:32:05 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 045081A9239
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  3 Sep 2021 17:32:05 +0000 (UTC)
Message-Id: <20210903173204.1A1721A923A@mollari.NetBSD.org>
Date: Fri,  3 Sep 2021 17:32:04 +0000 (UTC)
From: rdanilov75@gmail.com
Reply-To: rdanilov75@gmail.com
To: gnats-bugs@NetBSD.org
Subject: Wrong uptime output: returns all but the uptime
X-Send-Pr-Version: www-1.0

>Number:         56387
>Category:       bin
>Synopsis:       Wrong uptime output: returns all but the uptime
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 03 17:35:00 +0000 2021
>Last-Modified:  Sun Sep 19 04:15:01 +0000 2021
>Originator:     Roman Danilov
>Release:        9.2
>Organization:
>Environment:
NetBSD inw-vm039.i-hn.loc 9.2 NetBSD 9.2 (GENERIC) #0: Wed May 12 13:15:55 UTC 2021  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
If run uptime command, I get all, but the uptime:

inw-vm039$ uptime
 8:08PM  1 user, load averages: 0.00, 0.00, 0.00

On my regular user:

inw-vm039$ echo $SHELL
/bin/ksh
inw-vm039$ which uptime
/usr/bin/uptime
inw-vm039$

On my superuser:

inw-vm039$ su -
Password:
inw-vm039# echo $SHELL
/bin/sh
inw-vm039# which uptime
/usr/bin/uptime

In both environments, bug is reproducing.

In the /proc filesystem, uptime is readable on both of users:

inw-vm039# cat /proc/uptime
1065.82 1041.66
inw-vm039# exit
inw-vm039$ cat /proc/uptime
1095.38 1073.78

>How-To-Repeat:
1.Login to your shell
2. Run 'uptime' command
>Fix:

>Audit-Trail:
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/56387: Wrong uptime output: returns all but the uptime
Date: Sun, 19 Sep 2021 04:12:03 +0000

 On Fri, Sep 03, 2021 at 05:35:01PM +0000, rdanilov75@gmail.com wrote:
  > If run uptime command, I get all, but the uptime:
  > 
  > inw-vm039$ uptime
  >  8:08PM  1 user, load averages: 0.00, 0.00, 0.00

 Looking at the code, there are only three ways to not get the "up"
 print: (1) up less than one minute (not the case), (2) boot time is
 Jan 1, 1970 (unlikely), or (3) sysctl() fails (also fairly unlikely).

 Can you run it under ktrace (ktrace uptime; kdump | less) and check if
 the call to sysctl is failing? There should be one call fairly early
 (before it opens utmp or utmpx) which is irrelevant, and one near the
 end, which is the important one. If that's failing, the question is
 why.

 Also, check the boot time in case that's 0. If so, the question is
 why...

 -- 
 David A. Holland
 dholland@netbsd.org

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.