diff options
author | LAN-TW <lantw44@sonytest.tfcis.org> | 2012-11-12 12:22:12 +0800 |
---|---|---|
committer | LAN-TW <lantw44@sonytest.tfcis.org> | 2012-11-12 12:22:12 +0800 |
commit | d7f706956e0c4914879d2d08c24227ba0bb6ef0f (patch) | |
tree | 4ca7a46f180ebbf13d26aa32f643d3867b45bbb1 /src/mkchild.c | |
parent | cfa4b4203be3761bf37ec8cf7d394028ebd24e82 (diff) | |
download | sctjudge-d7f706956e0c4914879d2d08c24227ba0bb6ef0f.tar.gz sctjudge-d7f706956e0c4914879d2d08c24227ba0bb6ef0f.tar.zst sctjudge-d7f706956e0c4914879d2d08c24227ba0bb6ef0f.zip |
修正在 #undef _POSIX_SAVED_IDS 的環境下發生的問題
原先使用 getuid() 判斷 UID 會導致在 disable_setuid() 後 real UID 有誤,導致只
有 root 可以強制執行這支程式。
Diffstat (limited to 'src/mkchild.c')
-rw-r--r-- | src/mkchild.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mkchild.c b/src/mkchild.c index 2876a92..3325632 100644 --- a/src/mkchild.c +++ b/src/mkchild.c @@ -539,7 +539,7 @@ void* sctjudge_makechild(void* arg){ #ifndef HAVE_CONF_CAP enable_setuid(); #endif - fchown(fdoutput, getuid(), -1); + fchown(fdoutput, procrealuid, -1); /* 再來就是 stderr 了 */ if(mcopt.flags & SCTMC_REDIR_STDERR){ @@ -619,7 +619,7 @@ void* sctjudge_makechild(void* arg){ #ifndef HAVE_CONF_CAP else{ /* 確保 setuid 可執行檔所造成的 effective UID 改變不會傳給子程序 */ - setuid(getuid()); + setuid(procrealuid); } #endif |