mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-06 18:00:28 +00:00
secure set-id shell script support
This commit is contained in:
parent
3c7ad0eab2
commit
88fbcebb08
1 changed files with 10 additions and 0 deletions
|
@ -37,6 +37,7 @@
|
|||
#define KERN_PROC 14
|
||||
#define KERN_PROC_PATHNAME_FREEBSD 12
|
||||
#define KERN_PROC_PATHNAME_NETBSD 5
|
||||
#define DEV_FD "/dev/fd/"
|
||||
|
||||
static struct {
|
||||
atomic_uint once;
|
||||
|
@ -114,6 +115,15 @@ 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;
|
||||
}
|
||||
|
||||
b = g_prog.u.buf;
|
||||
n = sizeof(g_prog.u.buf) - 1;
|
||||
if (IsFreebsd() || IsNetbsd()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue