mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 10:20:29 +00:00
Cannot use KERN_PROC_PATHNAME with set-id loader
This commit is contained in:
parent
091e0ab1ca
commit
c721e70bb1
1 changed files with 12 additions and 7 deletions
|
@ -118,13 +118,18 @@ static inline void InitProgramExecutableNameImpl(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issetugid() && __program_executable_name &&
|
if (issetugid() && __program_executable_name) {
|
||||||
(IsNetbsd() || IsOpenbsd() || IsXnu()) &&
|
if ((IsNetbsd() || IsOpenbsd() || IsXnu()) /* any others? */ &&
|
||||||
!strncmp(DEV_FD, __program_executable_name, sizeof(DEV_FD) - 1) &&
|
!strncmp(DEV_FD, __program_executable_name, sizeof(DEV_FD) - 1) &&
|
||||||
isdigit(__program_executable_name[sizeof(DEV_FD)]) &&
|
isdigit(__program_executable_name[sizeof(DEV_FD)]) &&
|
||||||
!strchr(__program_executable_name + sizeof(DEV_FD) + 1, '/')) {
|
!strchr(__program_executable_name + sizeof(DEV_FD) + 1, '/')) {
|
||||||
/* loader passed us a secure path */
|
/* loader passed us a secure path */
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
/* we cannot use KERN_PROC_PATHNAME or its ilk in the loader case. they
|
||||||
|
will report the path of the loader, not the path of the binary. */
|
||||||
|
goto UseEmpty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
b = g_prog.u.buf;
|
b = g_prog.u.buf;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue