aboutsummaryrefslogtreecommitdiffstats
path: root/src/mkchild.c
diff options
context:
space:
mode:
authorLAN-TW <lantw44@sonytest.tfcis.org>2012-11-12 12:22:12 +0800
committerLAN-TW <lantw44@sonytest.tfcis.org>2012-11-12 12:22:12 +0800
commitd7f706956e0c4914879d2d08c24227ba0bb6ef0f (patch)
tree4ca7a46f180ebbf13d26aa32f643d3867b45bbb1 /src/mkchild.c
parentcfa4b4203be3761bf37ec8cf7d394028ebd24e82 (diff)
downloadsctjudge-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.c4
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