shadow-maint / shadow

Upstream shadow tree
Other
290 stars 228 forks source link

Typo in newuidmap newgidmap man pages file descriptor sections #977

Closed igo95862 closed 3 months ago

igo95862 commented 4 months ago

https://github.com/shadow-maint/shadow/blob/f7fe4c59781fde33e112be2cfdec44b84fda6497/man/newuidmap.1.xml#L122-L124

https://github.com/shadow-maint/shadow/blob/f7fe4c59781fde33e112be2cfdec44b84fda6497/man/newgidmap.1.xml#L122-L124

Both man pages when explaining passing the file descriptors mention that the descriptor has to be opened file /proc/[pid[. It is supposed to be /proc/[pid]/ directory? Is it supposed to be /proc/[pid]/uid_map? Or is it a pidfd?

hallyn commented 4 months ago

It's meant to be a pidfd or an fd to the directory /proc/pid. (per https://man7.org/linux/man-pages/man2/pidfd_open.2.html ,

       The pidfd_open() system call is the preferred way of obtaining a
       PID file descriptor for an already existing process.  The
       alternative is to obtain a file descriptor by opening a /proc/pid
       directory. 

)

hallyn commented 4 months ago

Having said that, I see that the result of pidfd_open will have a different device type, and therefore pidfd_open result actually won't work here.

igo95862 commented 4 months ago

So the issue here is that first one of the square brackets is in wrong direction and second is that it should spell that it should be the directory that file descriptor should refer to.

hallyn commented 4 months ago

And the third is that right now it won't actually work with a pidfd. The code should be fixed to try check for and handle a pidfd. Or, the docs updated to specify that only open(/proc/pid, O_RDONLY) result is valid right now.

For fixing it to work with pidfd, @brauner suggested (thanks!):

hallyn commented 4 months ago

@igo95862 I assume based on your last comment that you are not interested in posting a pr for this, right?

igo95862 commented 4 months ago

@igo95862 I assume based on your last comment that you are not interested in posting a pr for this, right?

I can if you want. (but it will have to wait until weekend)

I stumbled on this while working on my Python namespaces library.