From d7f706956e0c4914879d2d08c24227ba0bb6ef0f Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Mon, 12 Nov 2012 12:22:12 +0800 Subject: 修正在 #undef _POSIX_SAVED_IDS 的環境下發生的問題 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原先使用 getuid() 判斷 UID 會導致在 disable_setuid() 後 real UID 有誤,導致只 有 root 可以強制執行這支程式。 --- src/mkchild.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/mkchild.c') 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 -- cgit