Bug 829 - Cannot compile sudo in a container LXC
Cannot compile sudo in a container LXC
Status: RESOLVED FIXED
Product: Sudo
Classification: Unclassified
Component: Sudoers
1.8.22
PC Linux
: low normal
Assigned To: Todd C. Miller
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-04-04 10:34 MDT by Alessandro Perucchi
Modified: 2018-05-01 07:04 MDT (History)
0 users

See Also:


Attachments
Use btime in /proc/stat to determine system start time instead of /proc/uptime (1.74 KB, patch)
2018-04-04 11:26 MDT, Todd C. Miller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Perucchi 2018-04-04 10:34:24 MDT
Hello,
I don't know if the error should be open here or to LXC (v2.0.7).
Nevertheless I open it here.

I am trying to compile sudo 1.8.22 (and even tried the latest 1.8.23b2) and the compilation works without any problems, until I do the "make check", and at that moment, I get that everything is ok except for one test:

check_starttime: test 2: unexpected start time for pid 691525: Mon Mar 16 07:51:39 1970
check_starttime: 3 tests run, 1 errors, 66% success rate

After trying to figure out the problem, I have found that the check_starttime.c is using /proc/uptime to check the uptime of the container (and it is correct), but the function in starttime.c is using /proc/$$/stat (field 22) to get the time when the process was started.

Unfortunately the this field is not relative to the start of the container, but from the start of the physical host. And the delta is of course not 30 seconds, but a lot more!

So I don't know if there are other ways to calculate the start of a process without using /proc/$$/stat, like the 'ps' command which seems to work correctly...
Comment 1 Todd C. Miller 2018-04-04 10:53:28 MDT
Looks like procps-ng uses the btime field of/proc/stat instead of /proc/uptime.  Can you verify that this value is the boot time of the physical host and not the container?
Comment 2 Alessandro Perucchi 2018-04-04 11:15:10 MDT
Yes I can confirm that.

on the host:

$ grep btime /proc/stat
btime 1516440869

on the container

$ grep btime /proc/stat
btime 1516440869
Comment 3 Todd C. Miller 2018-04-04 11:26:31 MDT
Created attachment 507 [details]
Use btime in /proc/stat to determine system start time instead of /proc/uptime
Comment 4 Alessandro Perucchi 2018-04-04 11:34:05 MDT
I can confirm that it works :-)

Thank you!
Comment 5 Todd C. Miller 2018-05-01 07:04:33 MDT
Fixed in sudo 1.8.23