Skip to content

Commit f551ae2

Browse files
refactor: add MAXKB_SANDBOX_PYTHON_ALLOW_DL_PATH_CONTAINMENT env to allow sandbox to open dynamic link files in specific path.
1 parent e71ba49 commit f551ae2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

installer/sandbox.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,11 +496,17 @@ long syscall(long number, ...) {
496496
case SYS_setgid:
497497
case SYS_reboot:
498498
case SYS_mount:
499+
#ifdef SYS_chown
499500
case SYS_chown:
501+
#endif
502+
#ifdef SYS_chmod
500503
case SYS_chmod:
504+
#endif
501505
case SYS_fchmodat:
502506
case SYS_mprotect:
507+
#ifdef SYS_open
503508
case SYS_open:
509+
#endif
504510
case SYS_openat:
505511
case SYS_swapon:
506512
case SYS_swapoff:
@@ -525,6 +531,7 @@ long syscall(long number, ...) {
525531
* 限制加载动态链接库
526532
*/
527533
static int dl_path_allowed(const char *filename) {
534+
if (!filename || !*filename) return 1;
528535
if (!dl_path_containment || !*dl_path_containment) return 0;
529536
char *rules = strdup(dl_path_containment);
530537
if (!rules) return 0;
@@ -544,7 +551,7 @@ static int dl_path_allowed(const char *filename) {
544551
void *dlopen(const char *filename, int flag) {
545552
RESOLVE_REAL(dlopen);
546553
ensure_config_loaded();
547-
if (is_sandbox_user() && filename && !dl_path_allowed(filename)) {
554+
if (is_sandbox_user() && !dl_path_allowed(filename)) {
548555
fprintf(stderr, "Permission denied to access file %s.\n", filename);
549556
errno = EACCES;
550557
_exit(126);

0 commit comments

Comments
 (0)