dslm4515 / Musl-LFS

Linux From Scratch using Musl as Libc
GNU General Public License v3.0
167 stars 21 forks source link

utmp implementation #33

Open dslm4515 opened 3 years ago

dslm4515 commented 3 years ago

The Musl Libc does not have utmp functionality built-in like glibc.

Perhaps skarnet’s utmps should be built before coreutils? Without it, some commands like last will report /dev/null/utmp is not a directory

firasuke commented 3 years ago

Well here's the thing with utmp, utmpx and skarnet's utmps:

From the musl wiki FAQ:

Q: Why is the utmp/wtmp functionality only implemented as stubs?

  • if the feature is implemented, you need to take additional measures to protect your user’s privacy
  • in order to use the utmp/wtmp feature, you need a suid/sgid binary to modify the database, which opens the door for security issues:
  • if you compromise those binaries, you can inject arbitrary data into the db, that other programs might interpret in exploitable ways
  • that’s a HUGE risk to pay for the sake of a basically-useless and possibly-harmful “feature”

The only distribution I know of that has utmps fully working with s6, musl and many other packages is Adélie Linux, so be sure to check their patches and the way they're implementing it.

For further reading:

Hope that helps.

dslm4515 commented 3 years ago

@firasuke , oh no, that helps a lot!

I just stumbled into an APKBUILD from Adélie Linux that shows utmps and skarnet being used while building shadow:

LIBS="-lutmps -lskarnet" ./configure ...

Its good to know I can check Adélie Linux to see how can get a utmpx implementation working.

Now I know why when build utmps after MLFS, it's not used at all.

firasuke commented 3 years ago

Yup, there's also that.

Don't forget to examine the resulting executables using your ldd.

dslm4515 commented 3 years ago

Looks like I found my first hurdle: inetutils.

Can't decide if i should drop inetutils. Personally, I use ifconfig instead of ip... maybe its time for me to learn to use ip

make[2]: Entering directory '/sources/inetutils-1.9.4/libinetutils'
  CC       logwtmpko.o
logwtmpko.c:35:1: error: conflicting types for 'logwtmp'
   35 | logwtmp (char *line, char *name, char *host)
      | ^~~~~~~
In file included from /usr/include/utmpx.h:11,
                 from logwtmpko.c:24:
/usr/include/utmps/utmpx.h:64:13: note: previous declaration of 'logwtmp' was here
   64 | extern void logwtmp (char const *, char const *, char const *) ;
      |             ^~~~~~~
make[2]: *** [Makefile:1468: logwtmpko.o] Error 1
make[2]: Leaving directory '/sources/inetutils-1.9.4/libinetutils'
make[1]: *** [Makefile:1491: all-recursive] Error 1
make[1]: Leaving directory '/sources/inetutils-1.9.4'
make: *** [Makefile:1428: all] Error 2

Created a patch to fix mismatch of types. Compile error goes away. Patch will be featured in MLFS-8.00

dslm4515 commented 3 years ago

Completed mlfs-8.00 with utmp/utmpx implementation. Not sure how to test. elogind now no longer has error Failed to create inotify on /dev/null/utmp, ignoring: Not a directory

firasuke commented 3 years ago

Nice, now hit w and see if it reports back any user(s).

firasuke commented 3 years ago

Any updates on this? Did you try what I mentioned in the previous comment?

dslm4515 commented 3 years ago

Sorry, I had some strange issues: I am currently rebuilding mlfs-8.00 on i686, since I decided not only to add utmps, but also replace pkg-config with pkgconf and gettext with gettext-tiny... and building mlfs-8.00 on x86_64. I built musl-1.2.1fine on the i686 system, but had compile time errors on the x86_64 system. Both systems are using a copy of the same patches, scripts, and sources.

The i686 system had already built the final system Musl libc and working on bzip2. The x86_64 system just finished it's tool chain and entered chroot. When building musl, one of the patches from Adelie Linux failed. Strange as same patch was used in the i686 build... So i try to compile Muslon the i686 system and patch also failed. Not sure why hours ago, patch did not fail. In the end, i had to modify the patch from Adelie Linux to salvage the build.

Now back to your question:

# w
 23:11:25 up 6 days, 11:44,  0 users,  load average: 0.41, 0.29, 0.25
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT

^ is this expected output?

dslm4515 commented 3 years ago

... same output if i try same command on my Samsung Chromebook3 (GalliumOS 3.1)

firasuke commented 3 years ago

That's the known issue, w doesn't show available users.

Try running w on any working Linux system (also on Adélie) and compare outputs.

dslm4515 commented 3 years ago

Just for reference, I booted an Artix Linux LiveCD and got a different output:

artix:[artix]:~$ w
 22:10:10 up 14 min, 1 user, load average:0.00, 0.22, 0.43
USER     TTY        LOGIN@    IDLE    JCPU    PCPU    WHAT
artix    tty1      21:59      0.00s   0.12s   0.01s   w

Artix uses Glibc though.

I'll try a liveCD of Adelie Linux next

dslm4515 commented 3 years ago

I didnt want to waste a blank DVD to burn a 719MB LiveCD of Adelie Linux, so installed Adelie Linux on an old Thinkpad x61s. Yes, Adelie does output users when try w.

Looks like, my bootscripts are not correctly running utmps?

firasuke commented 3 years ago

Unfortunately, that seems to be the case.

firasuke commented 3 years ago

Any updates to this issue?

dslm4515 commented 3 years ago

Its still on my to-do list.

For my MLFS builds, i use pkgtools. I'm currently creating build scripts because some packages, like bzip2 have a broken install target. As a workaround, I manually copy files to my DESTDIR directory.

Once i get the scripts done, I will just quickly update the scripts as I update MLFS repo. This should speed up building and testing. So far I'm at 54 scripts done with 39 to go.

firasuke commented 3 years ago

In my honest opinion, and based on my experience, Artix currently has the best s6 + s6-rc implementation, and I'd suggest that you spend some time understanding how they've implemented it. They also seem to have the closest vanilla implementation compared to the likes of Adelie (which uses OpenRC) and Obarun (which literally added an entire layer over s6/s6-rc).

The only thing that Artix lacks is musl and utmps, and I think combining the knowledge gained from understanding both implemenations can get a working s6/s6+rc on musl with utmps fully working.

The first glaucus release also used s6/s6+rc on musl (with utmps available and being linked to, but still not working), but I'm working on fixing that now.

dslm4515 commented 3 years ago

I tried to look into Obarun's 66 toolset/utilities but... couldn't figure out where the sources are and how to extract 66 from Obarun to use in in MLFS. It boasts that it makes it easier to work with S6+S6-rc.

If I remembered correctly, my bootscripts are loosely based on what I understood from Obarun.

I might scrap the Adelie Linux install on my x61 and install Artix for more s6+s6-rc research.

If curious: One of the reasons I abandoned runit was I could never boot with my own boot scripts from scratch. Last time I build MLFS with runit, I had to use inthecloud247's repo [https://github.com/inthecloud247/runit-for-lfs] which has not been updated since 2014. It was like runit would only read scripts made by inthecloud247 or by Void Linux devs.... then again, s6+s6-rc boots in parallel and i could never find a way to do the same with runit

firasuke commented 3 years ago

I'd say Obarun's implementation is kinda their own thing now, even their s6/s6-rc stuff were archived and are no longer maintained in favor of 66.

I recommend you study Artix's and Adelie's implementations more carefully. I think even alpine has s6/s6-rc packages now (but I believe they're not intended to be run as PID 1, but they're still considered valuable resources.

Both Adelie's and Alpine's s6/s6-rc packages are maintained by Laurent Bercot himself as well.

dslm4515 commented 3 years ago

I rewrote my bootscripts by copying and modifying bootscripts form Artix and service scripts from Adelie Linux.

My MLFS build boots after so many attempts but still no users listed for w.

dslm4515 commented 3 years ago

Ugh. I forgot to check apkbuilds of Adelie ! I missed a configuration option —enable-utmps

Adelie Linux stores the utmps ‘server socket’ in /run/utmps...for my build is empty but i forgot to check under Adelie Linux

firasuke commented 3 years ago

Oh it's a good thing that you checked.

Artix doesn't use utmps (because it has glibc), and w grabs its information from /run/utmp which is created via the cleanup oneshot from s6-scripts (/etc/s6/sv/cleanup/up):

install -m0664 -o root -g utmp /dev/null /run/utmp

But this shouldn't be needed with utmps because utmpd/wtmpd are provided.

dslm4515 commented 3 years ago

For Adelie, /run/utmps has .utmpd-socket And .wtmpd .socketAnd utmp (Which holds the data for w?)

My build boots with that directory empty. I will check the configure options for all s6 packages and try again... current state of bootscripts does yield an error with udevadm so I might just rewrite from scratch instead of merging Artix’s boot scripts and Adelie’s utmps service scripts

dslm4515 commented 3 years ago

Turns out when s6-Linux-init with —enable-utmps and s6-linux-init-maker Is used to create the /etc/s6/current... utmpd and wtmpd services are also created for early boot!

Rewriting my bootscripts as I made s6-portable-utils static to use in the bootscripts... scripts imported from artix Linux now have issues with paths and unable to find execline in /usr/bin ... easy fix would be a symlink to /bin/execlineb... my new bootscripts will pretty much follow the same design.

firasuke commented 3 years ago

Cool, lemme know if you managed to get utmps (and w) to work.

dslm4515 commented 3 years ago

Finished rewriting my bootscripts. System boots fine, except only one virtual terminal. Other five VT’s are not set. I will remove the VT setup I copied from Artix and reuse the one from my old bootscripts.

UGH. Still no users listed after executing w. But now I have sockets in /run/utmps!

I will upload my bootscripts in my other repo soon as version 4.00

firasuke commented 3 years ago

UGH. Still no users listed after executing w. But now I have sockets in /run/utmps!

Yup, last time I checked that was the most you could do, and still w won't work. w reads info from /var/run/utmp (or /run/utmp, and it's even better to have /var/run symlinked to /run but that still won't fix the issue).

firasuke commented 3 years ago

Ok, I've contacted skarnet and he advised me to run an strace on w inside glaucus (thanks to a static strace binary he provided which can be easily used in the bootstrap of Musl-LFS as well (here's another static strace binary)), this is the output of strace w:

execve("/bin/w", ["w"], 0x7ffeddfcee20 /* 11 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7fb8e7649ba8) = 0
set_tid_address(0x7fb8e764a00c)         = 259
brk(NULL)                               = 0xa29000
brk(0xa2b000)                           = 0xa2b000
mmap(0xa29000, 4096, PROT_NONE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xa29000
open("/etc/ld-musl-x86_64.path", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7645000
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "/usr/lib\n", 1024)             = 9
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0x7fb8e7645000, 4096)            = 0
open("/usr/lib/libprocps.so.8", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=83744, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p:\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2260992, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7fb8e718c000
mmap(0x7fb8e739e000, 90112, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x12000) = 0x7fb8e739e000
mmap(0x7fb8e73a1000, 77824, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb8e73a1000
close(3)                                = 0
open("/usr/lib/libutmps.so.0.0", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=9632, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\n\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2109440, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7fb8e6f89000
mmap(0x7fb8e718a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x1000) = 0x7fb8e718a000
close(3)                                = 0
open("/usr/lib/libskarnet.so.2.9", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=334912, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000\275\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2486272, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7fb8e6d2a000
mmap(0x7fb8e6f79000, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x4f000) = 0x7fb8e6f79000
mmap(0x7fb8e6f7c000, 53248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fb8e6f7c000
close(3)                                = 0
mprotect(0x7fb8e739e000, 8192, PROT_READ) = 0
mprotect(0x7fb8e7646000, 4096, PROT_READ) = 0
mprotect(0x7fb8e718a000, 4096, PROT_READ) = 0
mprotect(0x7fb8e6f79000, 8192, PROT_READ) = 0
mprotect(0x603000, 4096, PROT_READ)     = 0
open("/proc/self/auxv", O_RDONLY)       = 3
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7645000
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7641000
readv(3, [{iov_base="!\0\0\0\0\0\0\0\0000\3336\377\177\0", iov_len=15}, {iov_base="\0\20\0\0\0\0\0\0\0\377\373\213\17\0\0\0\0\6\0\0\0\0\0\0\0\0\20\0\0\0\0\0"..., iov_len=1024}], 2) = 320
close(3)                                = 0
munmap(0x7fb8e7645000, 4096)            = 0
munmap(0x7fb8e7641000, 16384)           = 0
open("/proc/sys/kernel/osrelease", O_RDONLY) = 3
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7645000
read(3, "5.9.10\n", 1024)               = 7
close(3)                                = 0
munmap(0x7fb8e7645000, 4096)            = 0
sched_getaffinity(0, 128, [0])          = 8
open("/proc/self/auxv", O_RDONLY)       = 3
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7645000
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7641000
readv(3, [{iov_base="!\0\0\0\0\0\0\0\0000\3336\377\177\0", iov_len=15}, {iov_base="\0\20\0\0\0\0\0\0\0\377\373\213\17\0\0\0\0\6\0\0\0\0\0\0\0\0\20\0\0\0\0\0"..., iov_len=1024}], 2) = 320
close(3)                                = 0
munmap(0x7fb8e7645000, 4096)            = 0
munmap(0x7fb8e7641000, 16384)           = 0
ioctl(1, TIOCGWINSZ, 0x7fff36d57198)    = -1 ENOTTY (Inappropriate ioctl for device)
stat("/proc/self/task", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc", O_RDONLY|O_CLOEXEC|O_DIRECTORY) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7644000
mmap(NULL, 131092, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7623000
mmap(NULL, 131092, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7602000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7601000
getdents64(3, /* 71 entries */, 2048)   = 2040
stat("/proc/1", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/1/stat", O_RDONLY)          = 4
read(4, "1 (s6-svscan) S 0 1 0 0 -1 42109"..., 1024) = 270
close(4)                                = 0
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
read(4, "root::0:0:root:/root:/usr/bin/ok"..., 1024) = 117
lseek(4, -82, SEEK_CUR)                 = 35
close(4)                                = 0
open("/proc/1/cmdline", O_RDONLY)       = 4
read(4, "s6-svscan\0-st0\0-X3\0--\0/run/servi"..., 2047) = 35
close(4)                                = 0
stat("/proc/2", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/2/stat", O_RDONLY)          = 4
read(4, "2 (kthreadd) S 0 0 0 0 -1 212998"..., 1024) = 149
close(4)                                = 0
open("/proc/2/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e7600000
stat("/proc/3", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/3/stat", O_RDONLY)          = 4
read(4, "3 (rcu_gp) I 2 0 0 0 -1 69238880"..., 1024) = 150
close(4)                                = 0
open("/proc/3/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/4", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/4/stat", O_RDONLY)          = 4
read(4, "4 (rcu_par_gp) I 2 0 0 0 -1 6923"..., 1024) = 154
close(4)                                = 0
open("/proc/4/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/5", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/5/stat", O_RDONLY)          = 4
read(4, "5 (kworker/0:0-ata_sff) I 2 0 0 "..., 1024) = 162
close(4)                                = 0
open("/proc/5/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75ff000
stat("/proc/6", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/6/stat", O_RDONLY)          = 4
read(4, "6 (kworker/0:0H-kblockd) I 2 0 0"..., 1024) = 164
close(4)                                = 0
open("/proc/6/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/7", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/7/stat", O_RDONLY)          = 4
read(4, "7 (kworker/u2:0-events_unbound) "..., 1024) = 170
close(4)                                = 0
open("/proc/7/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/8", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/8/stat", O_RDONLY)          = 4
read(4, "8 (mm_percpu_wq) I 2 0 0 0 -1 69"..., 1024) = 156
close(4)                                = 0
open("/proc/8/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75fe000
stat("/proc/9", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/9/stat", O_RDONLY)          = 4
read(4, "9 (ksoftirqd/0) S 2 0 0 0 -1 692"..., 1024) = 154
close(4)                                = 0
open("/proc/9/cmdline", O_RDONLY)       = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/10", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/10/stat", O_RDONLY)         = 4
read(4, "10 (rcu_sched) I 2 0 0 0 -1 2129"..., 1024) = 152
close(4)                                = 0
open("/proc/10/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/11", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/11/stat", O_RDONLY)         = 4
read(4, "11 (migration/0) S 2 0 0 0 -1 69"..., 1024) = 158
close(4)                                = 0
open("/proc/11/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75fc000
stat("/proc/12", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/12/stat", O_RDONLY)         = 4
read(4, "12 (cpuhp/0) S 2 0 0 0 -1 692388"..., 1024) = 151
close(4)                                = 0
open("/proc/12/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
getdents64(3, /* 57 entries */, 2048)   = 1368
stat("/proc/13", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/13/stat", O_RDONLY)         = 4
read(4, "13 (kdevtmpfs) S 2 0 0 0 -1 2130"..., 1024) = 152
close(4)                                = 0
open("/proc/13/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/14", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/14/stat", O_RDONLY)         = 4
read(4, "14 (netns) I 2 0 0 0 -1 69238880"..., 1024) = 150
close(4)                                = 0
open("/proc/14/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/15", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/15/stat", O_RDONLY)         = 4
read(4, "15 (kauditd) S 2 0 0 0 -1 107583"..., 1024) = 153
close(4)                                = 0
open("/proc/15/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/16", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/16/stat", O_RDONLY)         = 4
read(4, "16 (oom_reaper) S 2 0 0 0 -1 107"..., 1024) = 156
close(4)                                = 0
open("/proc/16/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/17", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/17/stat", O_RDONLY)         = 4
read(4, "17 (writeback) I 2 0 0 0 -1 6923"..., 1024) = 154
close(4)                                = 0
open("/proc/17/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/18", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/18/stat", O_RDONLY)         = 4
read(4, "18 (kcompactd0) S 2 0 0 0 -1 107"..., 1024) = 156
close(4)                                = 0
open("/proc/18/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75fa000
stat("/proc/38", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/38/stat", O_RDONLY)         = 4
read(4, "38 (kblockd) I 2 0 0 0 -1 692388"..., 1024) = 152
close(4)                                = 0
open("/proc/38/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/39", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/39/stat", O_RDONLY)         = 4
read(4, "39 (ata_sff) I 2 0 0 0 -1 692388"..., 1024) = 152
close(4)                                = 0
open("/proc/39/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/40", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/40/stat", O_RDONLY)         = 4
read(4, "40 (md) I 2 0 0 0 -1 69238880 0 "..., 1024) = 147
close(4)                                = 0
open("/proc/40/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/41", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/41/stat", O_RDONLY)         = 4
read(4, "41 (kworker/0:1-events) I 2 0 0 "..., 1024) = 162
close(4)                                = 0
open("/proc/41/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/42", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/42/stat", O_RDONLY)         = 4
read(4, "42 (rpciod) I 2 0 0 0 -1 6923888"..., 1024) = 152
close(4)                                = 0
open("/proc/42/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/43", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/43/stat", O_RDONLY)         = 4
read(4, "43 (kworker/u3:0) I 2 0 0 0 -1 6"..., 1024) = 158
close(4)                                = 0
open("/proc/43/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/44", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/44/stat", O_RDONLY)         = 4
read(4, "44 (xprtiod) I 2 0 0 0 -1 692388"..., 1024) = 153
close(4)                                = 0
open("/proc/44/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75f8000
stat("/proc/45", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/45/stat", O_RDONLY)         = 4
read(4, "45 (cfg80211) I 2 0 0 0 -1 69238"..., 1024) = 154
close(4)                                = 0
open("/proc/45/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/46", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/46/stat", O_RDONLY)         = 4
read(4, "46 (kswapd0) S 2 0 0 0 -1 106189"..., 1024) = 152
close(4)                                = 0
open("/proc/46/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/47", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/47/stat", O_RDONLY)         = 4
read(4, "47 (nfsiod) I 2 0 0 0 -1 6923888"..., 1024) = 152
close(4)                                = 0
open("/proc/47/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/49", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/49/stat", O_RDONLY)         = 4
read(4, "49 (acpi_thermal_pm) I 2 0 0 0 -"..., 1024) = 161
close(4)                                = 0
open("/proc/49/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/50", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/50/stat", O_RDONLY)         = 4
read(4, "50 (kworker/u2:1-events_unbound)"..., 1024) = 172
close(4)                                = 0
open("/proc/50/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/51", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/51/stat", O_RDONLY)         = 4
read(4, "51 (scsi_eh_0) S 2 0 0 0 -1 2129"..., 1024) = 153
close(4)                                = 0
open("/proc/51/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/52", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/52/stat", O_RDONLY)         = 4
read(4, "52 (scsi_tmf_0) I 2 0 0 0 -1 692"..., 1024) = 156
close(4)                                = 0
open("/proc/52/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75f6000
stat("/proc/53", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/53/stat", O_RDONLY)         = 4
read(4, "53 (scsi_eh_1) S 2 0 0 0 -1 2129"..., 1024) = 153
close(4)                                = 0
open("/proc/53/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/54", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/54/stat", O_RDONLY)         = 4
read(4, "54 (scsi_tmf_1) I 2 0 0 0 -1 692"..., 1024) = 156
close(4)                                = 0
open("/proc/54/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/55", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/55/stat", O_RDONLY)         = 4
read(4, "55 (kworker/u2:2) I 2 0 0 0 -1 6"..., 1024) = 157
close(4)                                = 0
open("/proc/55/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/56", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/56/stat", O_RDONLY)         = 4
read(4, "56 (kworker/u2:3) I 2 0 0 0 -1 6"..., 1024) = 157
close(4)                                = 0
open("/proc/56/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/57", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/57/stat", O_RDONLY)         = 4
read(4, "57 (kworker/0:1H-kblockd) I 2 0 "..., 1024) = 166
close(4)                                = 0
open("/proc/57/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/58", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/58/stat", O_RDONLY)         = 4
read(4, "58 (kworker/0:2-ata_sff) I 2 0 0"..., 1024) = 164
close(4)                                = 0
open("/proc/58/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/59", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/59/stat", O_RDONLY)         = 4
read(4, "59 (ipv6_addrconf) I 2 0 0 0 -1 "..., 1024) = 159
close(4)                                = 0
open("/proc/59/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75f4000
stat("/proc/64", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/64/stat", O_RDONLY)         = 4
read(4, "64 (jbd2/sda1-8) S 2 0 0 0 -1 23"..., 1024) = 157
close(4)                                = 0
open("/proc/64/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/65", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/65/stat", O_RDONLY)         = 4
read(4, "65 (ext4-rsv-conver) I 2 0 0 0 -"..., 1024) = 162
close(4)                                = 0
open("/proc/65/cmdline", O_RDONLY)      = 4
read(4, "", 2047)                       = 0
close(4)                                = 0
stat("/proc/68", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/68/stat", O_RDONLY)         = 4
read(4, "68 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/68/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6-linux-init-runle"..., 2047) = 37
close(4)                                = 0
stat("/proc/69", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/69/stat", O_RDONLY)         = 4
read(4, "69 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/69/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6-svscan-log\0", 2047) = 27
close(4)                                = 0
stat("/proc/70", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/70/stat", O_RDONLY)         = 4
read(4, "70 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/70/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0wtmpd\0", 2047)  = 19
close(4)                                = 0
stat("/proc/71", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/71/stat", O_RDONLY)         = 4
read(4, "71 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 268
close(4)                                = 0
open("/proc/71/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6-linux-init-early"..., 2047) = 39
close(4)                                = 0
stat("/proc/72", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/72/stat", O_RDONLY)         = 4
read(4, "72 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/72/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0utmpd\0", 2047)  = 19
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75f2000
stat("/proc/73", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/73/stat", O_RDONLY)         = 4
read(4, "73 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/73/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6-linux-init-logou"..., 2047) = 39
close(4)                                = 0
stat("/proc/74", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/74/stat", O_RDONLY)         = 4
read(4, "74 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/74/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6-linux-init-shutd"..., 2047) = 37
close(4)                                = 0
stat("/proc/75", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/75/stat", O_RDONLY)         = 4
read(4, "75 (s6-linux-init-s) S 74 75 75 "..., 1024) = 267
close(4)                                = 0
open("/proc/75/cmdline", O_RDONLY)      = 4
read(4, "s6-linux-init-shutdownd\0-c\0/etc/"..., 2047) = 51
close(4)                                = 0
stat("/proc/76", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/76/stat", O_RDONLY)         = 4
read(4, "76 (s6-ipcserverd) S 73 76 76 0 "..., 1024) = 270
close(4)                                = 0
open("/proc/76/cmdline", O_RDONLY)      = 4
read(4, "s6-ipcserverd\0-1\0-c\0001000\0-C\0001000"..., 2047) = 62
close(4)                                = 0
stat("/proc/78", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/78/stat", O_RDONLY)         = 4
read(4, "78 (s6-ipcserverd) S 72 78 78 0 "..., 1024) = 273
close(4)                                = 0
open("/proc/78/cmdline", O_RDONLY)      = 4
read(4, "s6-ipcserverd\0-1\0--\0utmps-utmpd\0", 2047) = 32
close(4)                                = 0
stat("/proc/79", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/79/stat", O_RDONLY)         = 4
read(4, "79 (s6-ipcserverd) S 70 79 79 0 "..., 1024) = 270
close(4)                                = 0
open("/proc/79/cmdline", O_RDONLY)      = 4
read(4, "s6-ipcserverd\0-1\0--\0utmps-wtmpd\0", 2047) = 32
close(4)                                = 0
stat("/proc/80", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/80/stat", O_RDONLY)         = 4
read(4, "80 (s6-log) S 69 80 80 0 -1 4210"..., 1024) = 263
close(4)                                = 0
open("/proc/80/cmdline", O_RDONLY)      = 4
read(4, "s6-log\0-bpd3\0--\0001\0t\0/run/uncaugh"..., 2047) = 39
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75f0000
stat("/proc/82", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/82/stat", O_RDONLY)         = 4
read(4, "82 (s6-ipcserverd) S 68 82 82 0 "..., 1024) = 270
close(4)                                = 0
open("/proc/82/cmdline", O_RDONLY)      = 4
read(4, "s6-ipcserverd\0-1\0-c\0001\0--\0s6-sudo"..., 2047) = 79
close(4)                                = 0
stat("/proc/88", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/88/stat", O_RDONLY)         = 4
read(4, "88 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/88/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6rc-fdholder\0", 2047) = 27
close(4)                                = 0
stat("/proc/89", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/89/stat", O_RDONLY)         = 4
read(4, "89 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/89/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0ttys\0", 2047)   = 18
close(4)                                = 0
stat("/proc/90", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/90/stat", O_RDONLY)         = 4
read(4, "90 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/90/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0udevd-log\0", 2047) = 23
close(4)                                = 0
stat("/proc/91", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/91/stat", O_RDONLY)         = 4
read(4, "91 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 265
close(4)                                = 0
open("/proc/91/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0s6rc-oneshot-runner"..., 2047) = 33
close(4)                                = 0
stat("/proc/92", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/92/stat", O_RDONLY)         = 4
read(4, "92 (s6-supervise) S 1 1 0 0 -1 4"..., 1024) = 268
close(4)                                = 0
open("/proc/92/cmdline", O_RDONLY)      = 4
read(4, "s6-supervise\0udevd-srv\0", 2047) = 23
close(4)                                = 0
stat("/proc/100", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/100/stat", O_RDONLY)        = 4
read(4, "100 (s6-fdholderd) S 88 100 100 "..., 1024) = 273
close(4)                                = 0
open("/proc/100/cmdline", O_RDONLY)     = 4
read(4, "s6-fdholderd\0-1\0-i\0data/rules\0", 2047) = 30
close(4)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75ee000
stat("/proc/101", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/101/stat", O_RDONLY)        = 4
read(4, "101 (s6-ipcserverd) S 91 101 101"..., 1024) = 277
close(4)                                = 0
open("/proc/101/cmdline", O_RDONLY)     = 4
read(4, "s6-ipcserverd\0-1\0--\0s6-ipcserver"..., 2047) = 128
close(4)                                = 0
stat("/proc/132", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/132/stat", O_RDONLY)        = 4
read(4, "132 (s6-log) S 90 132 132 0 -1 4"..., 1024) = 267
close(4)                                = 0
open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 4
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75ed000
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
read(4, "root::0:0:root:/root:/usr/bin/ok"..., 1024) = 117
close(4)                                = 0
munmap(0x7fb8e75ed000, 4096)            = 0
open("/proc/132/cmdline", O_RDONLY)     = 4
read(4, "s6-log\0-d3\0-b\0--\0n3\0s6000000\0T\0/"..., 2047) = 46
close(4)                                = 0
stat("/proc/152", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/152/stat", O_RDONLY)        = 4
read(4, "152 (udevd) S 1 152 152 0 -1 421"..., 1024) = 273
close(4)                                = 0
open("/proc/152/cmdline", O_RDONLY)     = 4
read(4, "udevd\0--daemon\0", 2047)      = 15
close(4)                                = 0
stat("/proc/160", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/160/stat", O_RDONLY)        = 4
read(4, "160 (forx) S 89 160 160 0 -1 421"..., 1024) = 260
close(4)                                = 0
open("/proc/160/cmdline", O_RDONLY)     = 4
read(4, "forx\0TTY\0 tty2\0 tty3\0 tty4\0 tty5"..., 2047) = 85
close(4)                                = 0
stat("/proc/164", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/164/stat", O_RDONLY)        = 4
read(4, "164 (agetty) S 160 160 160 0 -1 "..., 1024) = 261
close(4)                                = 0
open("/proc/164/cmdline", O_RDONLY)     = 4
read(4, "agetty\0-8\0-L\0tty2\000115200\0", 2047) = 25
close(4)                                = 0
stat("/proc/215", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/215/stat", O_RDONLY)        = 4
read(4, "215 (udevd) S 92 215 215 0 -1 42"..., 1024) = 272
close(4)                                = 0
open("/proc/215/cmdline", O_RDONLY)     = 4
read(4, "udevd\0--debug\0", 2047)       = 14
close(4)                                = 0
stat("/proc/218", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/218/stat", O_RDONLY)        = 4
read(4, "218 (oksh) S 71 218 218 1025 256"..., 1024) = 282
close(4)                                = 0
open("/proc/218/cmdline", O_RDONLY)     = 4
read(4, "-oksh\0", 2047)                = 6
close(4)                                = 0
mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fb8e75ea000
stat("/proc/256", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/256/stat", O_RDONLY)        = 4
read(4, "256 (strace) R 218 256 218 1025 "..., 1024) = 280
close(4)                                = 0
open("/proc/256/cmdline", O_RDONLY)     = 4
read(4, "strace\0w\0", 2047)            = 9
close(4)                                = 0
stat("/proc/259", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
open("/proc/259/stat", O_RDONLY)        = 4
read(4, "259 (w) R 256 256 218 1025 256 4"..., 1024) = 264
close(4)                                = 0
open("/proc/259/cmdline", O_RDONLY)     = 4
read(4, "w\0", 2047)                    = 2
close(4)                                = 0
getdents64(3, /* 0 entries */, 2048)    = 0
close(3)                                = 0
munmap(0x7fb8e7644000, 8192)            = 0
open("/etc/localtime", O_RDONLY|O_NONBLOCK|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/proc/uptime", O_RDONLY)          = 3
lseek(3, 0, SEEK_SET)                   = 0
read(3, "160.51 157.44\n", 8191)        = 14
open("/proc/loadavg", O_RDONLY)         = 4
lseek(4, 0, SEEK_SET)                   = 0
read(4, "0.00 0.00 0.00 2/69 259\n", 8191) = 24
ioctl(1, TIOCGWINSZ, 0x7fff36d57118)    = -1 ENOTTY (Inappropriate ioctl for device)
writev(1, [{iov_base=" 19:18:17 up 2 min,  0 users,  l"..., iov_len=61}, {iov_base="\n", iov_len=1}], 2 19:18:17 up 2 min,  0 users,  load average: 0.00, 0.00, 0.00
) = 62
writev(1, [{iov_base="USER     TTY        LOGIN@   IDL"..., iov_len=53}, {iov_base=NULL, iov_len=0}], 2USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
) = 53
close(1)                                = 0
close(2)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

skarnet said that:

w opens libutmps and libskarnet, so it understands it (it has been built against it), but the utmp functions are doing nothing

This means that there's something wrong with how w (aka procps-ng is being built) or with the utmp functionality being provided by the musl stub (or by alpine's utmp.h stub patch for utmps which I'm using).

This is becoming a hassle to debug tbh...

Let me know your thoughts on this.

dslm4515 commented 3 years ago

I remember applying patches for utmps for procps from Adelie... no change either.

I noticed in the musl source, include/paths.h that _PATH_UTMP and _PATH_WTMP are still set to /dev/null/wtmp and /dev/null/utmp.

but for Glibc, those paths are defined in sysdeps/unix/sysv/linux/path.h as /var/log/utmp and /var/log/wtmp

I wonder if I patch the paths.h of musl source to setup utmp/wtmp to /run/utmps, it will make w Look for data in /run/utmps

dslm4515 commented 3 years ago

Although I don’t see any patches to set such paths for musl Libc... yet Adelie has a working utmps daemon and w

firasuke commented 3 years ago

I ran an strace w on Artix's w and it seems that it's checking for the files /var/run/utmp and /var/run/utmpx (which are created at boot time, instead of relying on utmps).

I noticed in the musl source, include/paths.h that _PATH_UTMP and _PATH_WTMP are still set to /dev/null/wtmp and /dev/null/utmp.

I remember trying this previously and it didn't work unfortunately I'll double check again to see if it could be related.

dslm4515 commented 3 years ago

This is becoming a hassle to debug tbh...

This reminds me when I was having problems getting a toolchain to build against musl instead of glibc. After a few months, I got it to work with a small cross-compiling toolchain. It took so long I forgot how I arrived at the solution. It’s really annoying how setting —target=i686-linux -musl does not automatically build a tool chain against musl Libc.

firasuke commented 3 years ago

This reminds me when I was having problems getting a toolchain to build against musl instead of glibc. After a few months, I got it to work with a small cross-compiling toolchain. It took so long I forgot how I arrived at the solution. It’s really annoying how setting —target=i686-linux -musl does not automatically build a tool chain against musl Libc.

Actually constructing toolchains (at least the way I see it) is much easier than having to deal with multiple (sort of incompatible) software and trying to get them to work.

The reason why I said it may not be worth the hassle, is not because of that though, it's due to utmp (w, who, lastlog...) being not that needed of a feature to enable, then again that's debatable...

dslm4515 commented 3 years ago

Bootscripts finally complete and uploaded to my other repo.... boots nice. I am unable to test to see if w works as i do not have a working build with changes to musl.

firasuke commented 3 years ago

Bootscripts finally complete and uploaded to my other repo.... boots nice. I am unable to test to see if w works as i do not have a working build with changes to musl.

Cool, I'm still in the process of testing another build with changes to paths.h.

firasuke commented 3 years ago

Any updates?

I stumbled upon this nifty utmps section from Alpine, though it neither specifies how utmps will work after installation nor if the packages were prebuilt with utmps support in mind.

dslm4515 commented 3 years ago

I almost bricked my MLFS build when i tried to recompile Musl with define utmp/wtmp paths....Currently building another with proposed changes (define paths in Musl)

firasuke commented 3 years ago

You can try applying the following fix-paths patch for musl from glaucus and see if it'll work.

dslm4515 commented 3 years ago

@firasuke I GOT IT TO WORK!! W now shows users!

I just modified the musl source:

diff -uNr musl-1.2.1.orig/include/paths.h musl-1.2.1/include/paths.h
--- musl-1.2.1.orig/include/paths.h     2020-08-03 23:21:09.000000000 -0500
+++ musl-1.2.1/include/paths.h  2020-12-14 21:50:07.613214612 -0600
@@ -18,9 +18,9 @@
 #define        _PATH_SHADOW    "/etc/shadow"
 #define        _PATH_SHELLS    "/etc/shells"
 #define        _PATH_TTY       "/dev/tty"
-#define _PATH_UTMP     "/dev/null/utmp"
+#define _PATH_UTMP     "/run/utmps/utmp"
 #define        _PATH_VI        "/usr/bin/vi"
-#define _PATH_WTMP     "/dev/null/wtmp"
+#define _PATH_WTMP     "/run/utmps/wtmp"

 #define        _PATH_DEV       "/dev/"
 #define        _PATH_TMP       "/tmp/"

I still have to import changes from my MLFS-pkgtools repo (branch 1.00) to Musl-LFS repo (stable-8.00).

firasuke commented 3 years ago

Awesome work!

Looks like the problem was from musl after all.

Please proceed to document this thoroughly as it's a major accomplishment.

dslm4515 commented 3 years ago

utmp Implementation with skarnet.org's utmps

Requirements:

Musl Libc: Patch source to set _PATH_UTMP and _PATH_WTMP in include/paths.h

#define _PATH_UTMP     "/run/utmps/utmp"
#define _PATH_WTMP     "/run/utmps/wtmp"

Patch the following with utmps support

Bootscripts If using s6 + s6-rc, make sure s6-linux-init has utmps enabled (--enable-utmps). Use s6-linux-init-maker to automatically create a service to run the utmps server when creating the basedir which has the run-image directory (it is copied to /run at boot).

firasuke commented 3 years ago

I'm very pleased with what we've accomplished here.

Hopefully, we can tackle more problems in the future and come up with solutions for them.

dslm4515 commented 3 years ago

I enabled utmp in elogind and applied Adelie linux's patch to have source look for utmpx.h instead of utmp.h

Now I got this warning during logins: Failed to set utmp path to /run/utmps/utmp: function not implemented

Not sure if elogind needs more patching as w still functions as intended

firasuke commented 3 years ago

For future reference:

Apparently musl is planning on providing non-stub utmp backends (according to their roadmap).

dslm4515 commented 3 years ago

Strange. I forgot to patch the usr/include/paths.h of musl and w still functions correctly!

#define _PATH_UTMP     "/dev/null/utmp"
#define _PATH_WTMP     "/dev/null/wtmp"

System is using musl version 1.2.2

firasuke commented 3 years ago

Strange. I forgot to patch the usr/include/paths.h of musl and w still functions correctly!

What!? Are you sure about that?

dslm4515 commented 3 years ago

Yeah. While building elogind for CMLFS, I noticed elogind was attempting to access /dev/null/utmp instead of /run/utmps/utmp... and I confirmed it by checking /usr/include/paths.h.

I also know w was working because when I first booted a CMLFS build I had errors for utmps. W wasn’t working since utmps was using the wrong dynamic linker. After recompiling utmps, w was working.

firasuke commented 3 years ago

Apparently a WTMPX file was added:

https://www.mail-archive.com/skaware@list.skarnet.org/msg01560.html

Upon checking include/utmps/utmpx.h:

#define WTMPX_FILE "/var/log/wtmp"

What are your thoughts?

firasuke commented 3 years ago

According to the NEWS file it was added starting from 0.1.0.2:

WTMPX_FILE, which is unused by utmps, now points to /var/log/wtmp
so that programs that want to read that file (e.g. lastlog) can
access wtmp without patching. Or with less patching.
dslm4515 commented 3 years ago

I am currently building MLFS with updated sources.... including utmps-0.1.0.2.

So i will try to skip some patching and see how effective this change may be

firasuke commented 3 years ago

I am currently building MLFS with updated sources.... including utmps-0.1.0.2.

So i will try to skip some patching and see how effective this change may be

Good luck with that, I still think we need to patch src/include/utmps/utmpx.h though...