Debian Codegraph @

testsuite/modules.60-initx/080-access-initx.exp

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