gopsutil icon indicating copy to clipboard operation
gopsutil copied to clipboard

host.Users() cannot get information on arm64

Open xhsky opened this issue 4 years ago • 4 comments
trafficstars

Describe the bug Host.user() cannot get information on arm64

To Reproduce

import "github.com/shirou/gopsutil/v3/host"
host.Users()   // get: []

Environment (please complete the following information): cpu_arch: aarch64 os: Centos7/Ubuntu 20

Additional context Get information error here: unexpected EOF host_linux.go err := binary.Read(br, binary.LittleEndian, &u)

xhsky avatar Sep 04 '21 08:09 xhsky

host.Users() is defined here and retrieves its information from /var/run/utmp, could you upload this file here?

Lomanic avatar Sep 05 '21 14:09 Lomanic

Can load and read the content.

Get information error here: unexpected EOF host_linux.go err := binary.Read(br, binary.LittleEndian, &u) br: &{[66 10 0 0 0 0 0 0 253 197 36 97 0 0 0 0 103 32 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 40 58 0 0 112 116 115 47 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 116 115 47 48 114 111 111 116 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 49 57 50 46 49 54 56 46 48 46 49 50 51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 384 -1} u err: unexpected EOF

xhsky avatar Sep 06 '21 02:09 xhsky

It seems that Debian aarch64 writes 400 bytes utmp entries (https://github.com/raspberrypi/Raspberry-Pi-OS-64bit/issues/140). sizeOfUtmp is hardcoded in host_linux_arm64.go to 384. Using C.sizeof_struct_utmp as sizeOfUtmp fixes reading the entries.

aperum avatar Feb 06 '22 16:02 aperum

I get the same error, Is there a fix for this?

radu-boboc avatar May 21 '22 13:05 radu-boboc