shadow/src
Serge Hallyn 6974df39a7 newuidmap and newgidmap: support passing pid as fd
Closes #635

newuidmap and newgidmap currently take an integner pid as
the first argument, determining the process id on which to
act.  Accept also "fd:N", where N must be an open file
descriptor to the /proc/pid directory for the process to
act upon.  This way, if you

exec 10</proc/99
newuidmap fd:10 100000 0 65536

and pid 99 dies and a new process happens to take pid 99 before
newuidmap happens to do its work, then since newuidmap will use
openat() using fd 10, it won't change the mapping for the new
process.

Example:

// terminal 1:
serge@jerom ~/src/nsexec$ ./nsexec -W -s 0 -S 0 -U
about to unshare with 10000000
Press any key to exec (I am 129176)

// terminal 2:
serge@jerom ~/src/shadow$ exec 10</proc/129176
serge@jerom ~/src/shadow$ sudo chown root src/newuidmap src/newgidmap
serge@jerom ~/src/shadow$ sudo chmod u+s src/newuidmap
serge@jerom ~/src/shadow$ sudo chmod u+s src/newgidmap
serge@jerom ~/src/shadow$ ./src/newuidmap fd:10 0 100000 10
serge@jerom ~/src/shadow$ ./src/newgidmap fd:10 0 100000 10

// Terminal 1:
uid=0(root) gid=0(root) groups=0(root)

Signed-off-by: Serge Hallyn <serge@hallyn.com>
2023-02-24 12:35:49 -06:00
..
.gitignore getsubids: system binary for user's sub*ids 2021-11-17 16:35:50 +01:00
.indent.pro
chage.c libmisc: Move xmalloc.c to alloc.c 2023-02-23 20:28:43 -06:00
check_subid_range.c Make shadow_logfd and Prog not extern 2021-12-23 15:18:07 -06:00
chfn.c libmisc: Move xmalloc.c to alloc.c 2023-02-23 20:28:43 -06:00
chgpasswd.c Use the noreturn attribute, rather than comments 2023-02-08 22:01:01 -06:00
chpasswd.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
chsh.c libmisc: Move xmalloc.c to alloc.c 2023-02-23 20:28:43 -06:00
expiry.c Use the noreturn attribute, rather than comments 2023-02-08 22:01:01 -06:00
faillog.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
free_subid_range.c Declare file local functions static 2022-01-03 15:09:17 +01:00
get_subid_owners.c Declare file local functions static 2022-01-03 15:09:17 +01:00
getsubids.c Declare file local functions static 2022-01-03 15:09:17 +01:00
gpasswd.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
groupadd.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
groupdel.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
groupmems.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
groupmod.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
groups.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
grpck.c Use the noreturn attribute, rather than comments 2023-02-08 22:01:01 -06:00
grpconv.c Merge pull request #451 from hallyn/2021-12-05/license 2022-01-02 18:38:42 -06:00
grpunconv.c Merge pull request #451 from hallyn/2021-12-05/license 2022-01-02 18:38:42 -06:00
id.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
lastlog.c Fix typos 2023-02-16 13:23:08 -06:00
login_nopam.c Fix typos 2023-02-16 13:23:08 -06:00
login.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
logoutd.c Cosmetic fixes 2022-12-22 10:31:43 +01:00
Makefile.am Fix VPATH build 2023-02-13 10:01:17 +01:00
new_subid_range.c Declare file local functions static 2022-01-03 15:09:17 +01:00
newgidmap.c newuidmap and newgidmap: support passing pid as fd 2023-02-24 12:35:49 -06:00
newgrp.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
newuidmap.c newuidmap and newgidmap: support passing pid as fd 2023-02-24 12:35:49 -06:00
newusers.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
nologin.c Update licensing info 2021-12-23 19:36:50 -06:00
passwd.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
pwck.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
pwconv.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
pwunconv.c Merge pull request #451 from hallyn/2021-12-05/license 2022-01-02 18:38:42 -06:00
su.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
suauth.c Remove superfluous casts 2023-02-09 10:03:03 -06:00
sulogin.c Call NULL by its name 2023-02-02 13:08:30 -06:00
useradd.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
userdel.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
usermod.c Use safer allocation macros 2023-02-23 20:28:43 -06:00
vipw.c Use safer allocation macros 2023-02-23 20:28:43 -06:00