glibc: seteuid/setuid 和 LD_LIBRARY_PATH的关系;不要感觉太奇怪;

https://bugzilla.redhat.com/show_bug.cgi?id=129682
由于安全的考量,在发现运行程序的uid/gid != real uid/gid,此时ld.so 会将下面的环境变量置空

This is of course a security measure, there are many env variables
removed from the environment and disregarded for setuid or setgid apps, including LD_PRELOAD, LD_LIBRARY_PATH, LD_ORIGIN_PATH, LD_DEBUG_OUTPUT, LD_PROFILE, LD_USE_LOAD_BIAS, GCONV_PATH, HOSTALIASES, LOCALDOMAIN, LOCPATH, MALLOC_TRACE, NLSPATH, RESOLV_HOST_CONF, RES_OPTIONS, TMPDIR and TZDIR.All Unices I know of behave this way.

所以在程序里如果设置了seteuid,然后再做execve的拉起程序的时候,这些个变量都会置空。不要感觉太奇怪。

从man ld.so 里看,有安全执行模式:Secure-execution mode
For security reasons, the effects of some environment variables are voided or modified if the dynamic linker determines that the binary should be run in secure-execution mode. (For details, see the discussion of individual environment variables below.) A binary is e

猜你喜欢

转载自blog.csdn.net/qq_36428903/article/details/132034082