Commit 7a3b6d39 authored by fmg-sf's avatar fmg-sf

[ENH] new setup script: prepare permissions to be set - final debugging mode, almost production

parent f0744846
......@@ -4866,6 +4866,7 @@ permissioncheck/paranoia/check.php -text
permissioncheck/permission_granted.bin -text
permissioncheck/permission_granted.inc.php -text
permissioncheck/risky/check.php -text
permissioncheck/usecases.bin -text
permissioncheck/usecases.inc.php -text
permissioncheck/usecases.txt -text
permissioncheck/worry/check.php -text
......
......@@ -9,5 +9,6 @@ no.bin:444
permission_granted.bin:644
permission_granted.inc.php:644
usecases.inc.php:644
usecases.bin:644
usecases.txt:644
yes.bin:444
paranoia:700:600:700:600
paranoia-suphp:701:600:701:600
worry:701:604:703:606
moreworry:705:604:707:606
pain:701:606:703:606
morepain:705:606:707:606
mixed:770:660:770:660
risky:775:664:777:666
insane:777:777:777:777
......@@ -6,8 +6,9 @@
$default_file_name = 'check.php';
$uc_txt_file = 'usecases.txt';
$file = fopen($uc_txt_file, 'r') or exit('Unable to open file ' . $uc_txt_file . '!');
$uc_txt_file = 'usecases.txt'; // legacy
$uc_file = 'usecases.bin';
$file = fopen($uc_file, 'r') or exit('Unable to open file ' . $uc_file . '!');
while(!feof($file)) {
$line_of_file_orig = fgets($file);
......@@ -15,9 +16,11 @@ while(!feof($file)) {
$dummy = true;
} else {
$line_of_file_mod=str_replace(':', ' ', $line_of_file_orig);
list($usecase, $def_subdir_perm, $def_file_perm) = sscanf($line_of_file_mod, '%s %d %d');
list($usecase, $def_subdir_perm, $def_file_perm, $def_subdir_write_perm, $def_file_write_perm) = sscanf($line_of_file_mod, '%s %d %d %d %d');
$uc_perms_subdir[$usecase] = $def_subdir_perm;
$uc_perms_file[$usecase] = $def_file_perm;
$uc_perms_write_subdir[$usecase] = $def_subdir_write_perm; //redundant (2012-11-10), for later usage
$uc_perms_write_file[$usecase] = $def_file_write_perm; //redundant (2012-11-10), for later usage
}
}
......
......@@ -19,7 +19,8 @@ LIST_OF_SUBDIRS="${WORK_DIR}/list-of-subdirs.txt"
#
INDEX_FILE="index.php"
DEFAULT_FILE_NAME="check.php"
USECASES_FILE="${WORK_DIR}/usecases.txt"
#USECASES_FILE="${WORK_DIR}/usecases.txt"
USECASES_FILE="${WORK_DIR}/usecases.bin"
GRANT="${WORK_DIR}/permission_granted.bin"
NO="${WORK_DIR}/no.bin"
YES="${WORK_DIR}/yes.bin"
......@@ -65,6 +66,7 @@ hardcoded_perms() {
${CHMOD} 644 "${WORK_DIR}/${INDEX_FILE}"
${CHMOD} 644 "${WORK_DIR}/permission_granted.inc.php"
${CHMOD} 644 "${WORK_DIR}/usecases.inc.php"
#${CHMOD} 644 "${WORK_DIR}/usecases.bin"
#${CHMOD} 644 "${WORK_DIR}/usecases.txt"
${CHMOD} 644 "${USECASES_FILE}"
}
......
......@@ -39,7 +39,8 @@ ECHOFLAG=1 # one empty line before printing used options in debugging mode
# ----------------------
PERMISSIONCHECK_DIR="permissioncheck"
USE_CASES_FILE="usecases.txt"
#USE_CASES_FILE="usecases.txt"
USE_CASES_FILE="usecases.bin"
USE_CASES_PATH=${PERMISSIONCHECK_DIR}
USE_CASES_NAME=${USE_CASES_PATH}/${USE_CASES_FILE}
......@@ -235,6 +236,7 @@ DIRS="db dump img/wiki img/wiki_up img/trackers modules/cache temp temp/cache te
get_permission_data() {
if [ ${DEBUG} = '1' ] ; then
echo
echo permissioncheck subdir: ${PERMISSIONCHECK_DIR}
fi
#USE____CASES_FILE="${WORK_DIR}/usecases.txt"
......@@ -250,10 +252,15 @@ get_permission_data() {
MODEL_NAME=${USE_CASE}
MODEL_PERMS_SUBDIRS=`echo ${ONE_USE_CASE_PER_LINE} | cut -d: -f2`
MODEL_PERMS_FILES=`echo ${ONE_USE_CASE_PER_LINE} | cut -d: -f3`
MODEL_PERMS_WRITE_SUBDIRS=`echo ${ONE_USE_CASE_PER_LINE} | cut -d: -f4`
MODEL_PERMS_WRITE_FILES=`echo ${ONE_USE_CASE_PER_LINE} | cut -d: -f5`
if [ ${DEBUG} = '1' ] ; then
echo
echo MODEL_NAME=${MODEL_NAME}
echo MODEL_PERMS_SUBDIRS=${MODEL_PERMS_SUBDIRS}
echo MODEL_PERMS_FILES=${MODEL_PERMS_FILES}
echo MODEL_PERMS_WRITE_SUBDIRS=${MODEL_PERMS_WRITE_SUBDIRS}
echo MODEL_PERMS_WRITE_FILES=${MODEL_PERMS_WRITE_FILES}
fi
fi
done < ${USE_CASES_NAME}
......@@ -281,9 +288,27 @@ permission_exceptions() {
permission_via_php_check() {
get_permission_data
# set permissions here
echo STOP - DEBUG MODE
exit 1
# set permissions here
#echo "\nSTOP - DEBUG MODE"
#exit 1
if [ ${DEBUG} = '2' ] ; then
echo
find . -type d -exec echo ${CHMOD} ${MODEL_PERMS_SUBDIRS} {} \;
find . -type f -exec echo ${CHMOD} ${MODEL_PERMS_FILES} {} \;
fi
E=echo
$E find . -type d -exec ${CHMOD} ${MODEL_PERMS_SUBDIRS} {} \;
$E find . -type f -exec ${CHMOD} ${MODEL_PERMS_FILES} {} \;
#echo
for WRITABLE in $DIRS ; do
#echo ${WRITABLE}
if [ -d ${WRITABLE} ] ; then
$E find ${WRITABLE} -type d -exec echo ${CHMOD} ${MODEL_PERMS_WRITE_SUBDIRS} {} \;
$E find ${WRITABLE} -type f -exec echo ${CHMOD} ${MODEL_PERMS_WRITE_FILES} {} \;
fi
done
#echo "\nSTOP - DEBUG MODE"
#exit 1
}
# part 4.2 - several command options as fix, open, ...
......@@ -437,12 +462,14 @@ command_open() {
}
# debug exit
debug_exit() {
if [ ${DEBUG} = '1' ] ; then
echo
echo "Exiting... for execution mode use option '-d off' or set DEBUG=0 at the beginning of this script"
echo
exit 1
fi
}
# part 5 - main program
# ---------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment