1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
##############################################################################
# Modules Revision 3.0
# Providing a flexible user environment
#
# File: modules.60-initx/%M%
# Revision: %I%
# First Edition: 2017/07/01
# Last Mod.: %U%, %G%
#
# Authors: Xavier Delaruelle, xavier.delaruelle@cea.fr
#
# Description: Testuite testsequence
# Command: initlist, initadd, initprepend, initswitch
# initrm, initclear
# Modulefiles:
# Sub-Command:
#
# Comment: %C{
# Handling of init file when access rights to get to it
# does not allow it
# }C%
#
##############################################################################
skip_if_quick_mode
# cannot test access if cannot change file permission
if {!$is_file_perms_editable} {
send_user "\tskipping access tests as file permissions cannot be changed\n"
# cannot test access if superuser privileges are in use
} elseif {$tcl_platform(user) eq "root"} {
send_user "\tskipping access tests as tests are run by superuser\n"
# cannot test access if restricted file permissions have no effect
} elseif {$is_locked_dir_file_readable && $is_locked_file_readable} {
send_user "\tskipping access tests as locked files or directories are still readable\n"
} else {
# restore regular .modules file for test
set initf "$env(HOME)/.modules"
set initfsave "${initf}.save"
file copy -force $initfsave $initf
set initlist_sh "sh initialization file \$HOME/.modules loads modules:\n\tnull\n\tdot module-cvs module-info modules use.own"
set write_msg_sh "$error_msgs: Init file $initf cannot be written.\n [couldnotopen_permdenied $initf]"
set hide_perms "ugo-rx"
set write_perms "ugo-w"
#
# Test access to init file when read access not granted on this file
#
change_file_perms $initf $hide_perms
testouterr_cmd sh "initlist" "OK" ""
testouterr_cmd sh "initadd foobar" "ERR" "$find_msg_sh"
testouterr_cmd sh "initswitch foo food" "ERR" "$find_msg_sh"
testouterr_cmd sh "initprepend foobar" "ERR" "$find_msg_sh"
testouterr_cmd sh "initrm foobar" "ERR" "$find_msg_sh"
testouterr_cmd sh "initclear" "ERR" "$find_msg_sh"
restore_file_perms $initf
#
# Test access to init file when write access not granted on this file
#
change_file_perms $initf $write_perms
testouterr_cmd sh "initlist" "OK" "$initlist_sh"
testouterr_cmd sh "initadd foobar" "ERR" "$write_msg_sh"
testouterr_cmd sh "initswitch foo food" "ERR" "$write_msg_sh"
testouterr_cmd sh "initprepend foobar" "ERR" "$write_msg_sh"
testouterr_cmd sh "initrm foobar" "ERR" "$write_msg_sh"
testouterr_cmd sh "initclear" "ERR" "$write_msg_sh"
restore_file_perms $initf
#
# Cleanup
#
reset_test_env
}
|