diff options
author | Changyeon Lee <cyeon.lee@samsung.com> | 2014-04-17 14:39:58 +0900 |
---|---|---|
committer | Changyeon Lee <cyeon.lee@samsung.com> | 2014-04-17 14:46:41 +0900 |
commit | ba6c5bef58d88aab1584107543b81a2930451a1f (patch) | |
tree | aa0e1ab02744850352e42ecbd629ad5a8f5c98d8 /launchd/privileged_startx/10-tmpdirs.cpp | |
parent | d7fbb5c11b41bb71b9173daea2f48d855bc61316 (diff) | |
parent | 8d5e38de0819168970669f24379c21338616184e (diff) | |
download | xinit-submit/tizen/20140819.234625.tar.gz xinit-submit/tizen/20140819.234625.tar.bz2 xinit-submit/tizen/20140819.234625.zip |
Merge branch 'devel/upgrade' into tizentizen_3.0.2014.q3_common_releasesubmit/tizen_mobile/20141120.000000submit/tizen/20140819.234625submit/tizen/20140818.144456submit/tizen/20140818.084211submit/tizen/20140417.073530submit/devel/x11/20140718.035926accepted/tizen/mobile/20140519.083048tizen_3.0.2015.q2_commontizen_3.0.2015.q1_commontizen_3.0.2014.q4_commontizen_3.0.2014.q3_commondevel/x11accepted/tizen_wearableaccepted/tizen_tvaccepted/tizen_mobileaccepted/tizen_commonaccepted/tizen_3.0.2014.q3_common
Change-Id: Ibe6f53547397a2beaf4747ef8a442b43e41544fb
Signed-off-by: Changyeon Lee <cyeon.lee@samsung.com>
Diffstat (limited to 'launchd/privileged_startx/10-tmpdirs.cpp')
-rwxr-xr-x | launchd/privileged_startx/10-tmpdirs.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/launchd/privileged_startx/10-tmpdirs.cpp b/launchd/privileged_startx/10-tmpdirs.cpp index 8012597..4366696 100755 --- a/launchd/privileged_startx/10-tmpdirs.cpp +++ b/launchd/privileged_startx/10-tmpdirs.cpp @@ -1,5 +1,5 @@ XCOMM!/bin/sh -XCOMM Copyright (c) 2008 Apple Inc. +XCOMM Copyright (c) 2008-2012 Apple Inc. XCOMM XCOMM Permission is hereby granted, free of charge, to any person XCOMM obtaining a copy of this software and associated documentation files @@ -36,11 +36,33 @@ else MKTEMP=mktemp fi +STAT=/usr/bin/stat + for dir in /tmp/.ICE-unix /tmp/.X11-unix /tmp/.font-unix ; do - XCOMM Use mktemp rather than mkdir to avoid possible security issue - XCOMM if $dir exists and is a symlink - if ${MKTEMP} -d ${dir} >& /dev/null ; then - chmod 1777 $dir - chown root:wheel $dir + success=0 + for attempt in 1 2 3 4 5 ; do + check=`${STAT} -f '%#p %u %g' ${dir} 2> /dev/null` + if [ "${check}" = "041777 0 0" ] ; then + success=1 + break + elif [ -n "${check}" ] ; then + saved=$(${MKTEMP} -d ${dir}-XXXXXXXX) + mv ${dir} ${saved} + echo "${dir} exists but is insecure. It has been moved into ${saved}" >&2 + fi + + # Use mktemp rather than mkdir to avoid possible security issue + # if $dir exists and is a symlink (ie protect against a race + # against the above check) + if ${MKTEMP} -d ${dir} >& /dev/null ; then + chmod 1777 $dir + chown root:wheel $dir + success=1 + break + fi + done + + if [ "${success}" -eq 0 ] ; then + echo "Could not successfully create ${dir}" >&2 fi done |