mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +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;
|
||||
}
|
||||
|
||||
if (issetugid() && __program_executable_name &&
|
||||
(IsNetbsd() || IsOpenbsd() || IsXnu()) &&
|
||||
!strncmp(DEV_FD, __program_executable_name, sizeof(DEV_FD) - 1) &&
|
||||
isdigit(__program_executable_name[sizeof(DEV_FD)]) &&
|
||||
!strchr(__program_executable_name + sizeof(DEV_FD) + 1, '/')) {
|
||||
/* loader passed us a secure path */
|
||||
return;
|
||||
if (issetugid() && __program_executable_name) {
|
||||
if ((IsNetbsd() || IsOpenbsd() || IsXnu()) /* any others? */ &&
|
||||
!strncmp(DEV_FD, __program_executable_name, sizeof(DEV_FD) - 1) &&
|
||||
isdigit(__program_executable_name[sizeof(DEV_FD)]) &&
|
||||
!strchr(__program_executable_name + sizeof(DEV_FD) + 1, '/')) {
|
||||
/* loader passed us a secure path */
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue