Debian Codegraph @

testsuite/modules.00-init/150-access-init.exp

raw
1 ##############################################################################
2 # Modules Revision 3.0
3 # Providing a flexible user environment
4 #
5 # File: modules.00-init/%M%
6 # Revision: %I%
7 # First Edition: 2019/05/05
8 # Last Mod.: %U%, %G%
9 #
10 # Authors: Xavier Delaruelle, [email protected]
11 #
12 # Description: Testuite testsequence
13 # Command: load, display
14 # Modulefiles:
15 # Sub-Command:
16 #
17 # Comment: %C{
18 # Tests startup of the modulecmd script when access to its
19 # external files is forbidden
20 # }C%
21 #
22 ##############################################################################
23
24 # cannot test access if cannot change file permission
25 if {!$is_file_perms_editable} {
26 send_user "\tskipping access tests as file permissions cannot be changed\n"
27 # cannot test access if superuser privileges are in use
28 } elseif {$tcl_platform(user) eq "root"} {
29 send_user "\tskipping access tests as tests are run by superuser\n"
30 # cannot test access if restricted file permissions have no effect
31 } elseif {$is_locked_dir_file_readable && $is_locked_file_readable} {
32 send_user "\tskipping access tests as locked files or directories are still readable\n"
33 } else {
34
35 set ans [list]
36
37 if {[info exists tclextlib_file]} {
38 # restrict read access to Tcl extension library
39 change_file_perms $tclextlib_file ugo-rx
40 lappend ans "DEBUG setState: cmdline set to '$MODULECMD sh --no-pager -D -V'"
41 if {$::install_multilibsupport eq {y}} {
42 lappend ans "DEBUG setState: machine set to '$::tcl_platform(machine)'"
43 }
44 lappend ans "DEBUG setConf: tcl_ext_lib set to '$tclextlib_file'"
45 lappend ans "DEBUG setConf: siteconfig set to '$siteconfig_filere'(\\nDEBUG sourceSiteConfig: Source site configuration \\($siteconfig_filere\\))?(\\nDEBUG setState: siteconfig_loaded set to '1')?"
46 lappend ans "DEBUG setConf: locked_configs set to '$install_lockedconfigs'"
47 lappend ans "DEBUG setState: supported_shells set to 'sh bash ksh zsh csh tcsh fish cmd tcl perl python ruby lisp cmake r pwsh'"
48 lappend ans "DEBUG setState: shell set to 'sh'"
49 lappend ans "DEBUG setState: subcmd set to ''"
50 lappend ans "DEBUG setState: subcmd_args set to ''"
51 lappend ans "DEBUG setState: init_error_report set to '1'"
52 lappend ans "DEBUG setConf: verbosity set to 'debug'"
53 lappend ans "DEBUG setConf: term_background set to '$install_termbg'"
54 lappend ans "(DEBUG parseEqualListConfValue: Ignore invalid default.*\\n)?DEBUG setConf: colors set to '.*'"
55 lappend ans "DEBUG setConf: color set to '0'"
56 lappend ans "DEBUG setConf: paginate set to '0'"
57 lappend ans "DEBUG setState: paginate set to '0'"
58 lappend ans "DEBUG setState: report_format set to 'regular'"
59 lappend ans "DEBUG setState: reportfd set to 'stderr'"
60 lappend ans "DEBUG setState: timer set to '0'"
61 lappend ans $vers_reportre
62 lappend ans "DEBUG setConf: logger set to '$::install_loggercmd'"
63 lappend ans "DEBUG setState: logging set to '0'"
64 lappend ans "DEBUG setState: logfd set to ''"
65 lappend ans "DEBUG setState: error_count set to '0'"
66 testouterr_cmd_re sh {--no-pager -D -V} {} [join $ans \n]
67 restore_file_perms $tclextlib_file
68
69 # replace Tcl extension library by a non lib file
70 file rename $tclextlib_file $tclextlib_file.orig
71 file copy lib/envmodules.c $tclextlib_file
72 set tclextlib_file_abs_re [regsub -all "\(\[.+?\]\)" [file normalize $tclextlib_file] {\\\1}]
73 if {$os_name eq {darwin}} {
74 set tserr "$error_msgs: dlopen\\\($tclextlib_file_abs_re,.*"
75 } else {
76 set tserr "$error_msgs: couldn't load file \"$tclextlib_file_abs_re\":.*"
77 }
78 testouterr_cmd_re sh {-V} ERR $tserr
79 file delete $tclextlib_file
80 file rename $tclextlib_file.orig $tclextlib_file
81 }
82
83 # restrict read access to site-specific configuration script
84 if {[file readable $siteconfig_file] && [file owned $siteconfig_file]} {
85 change_file_perms $siteconfig_file ugo-rx
86 testouterr_cmd_re sh {-V} {} $vers_reportre
87 restore_file_perms $siteconfig_file
88 }
89
90 skip_if_quick_mode
91
92 # restrict read access to additional site-specific configuration script
93 if {![is_config_locked extra_siteconfig]} {
94 set addsiteconfig_file $env(TESTSUITEDIR)/example/siteconfig.tcl-2
95 setenv_var MODULES_SITECONFIG $addsiteconfig_file
96 change_file_perms $addsiteconfig_file ugo-rx
97 testouterr_cmd_re sh {-V} {} $vers_reportre
98 restore_file_perms $addsiteconfig_file
99 unsetenv_var MODULES_SITECONFIG
100 }
101
102 # restrict read access to MODULERCFILE
103 set modulerc_file $env(TESTSUITEDIR)/etc/modulerc
104 setenv_var MODULERCFILE $modulerc_file
105 change_file_perms $modulerc_file ugo-rx
106 testouterr_cmd_re sh {list} {} $no_loaded
107 restore_file_perms $modulerc_file
108 setenv_var MODULERCFILE $ORIG_MODULERCFILE
109
110
111 #
112 # Cleanup
113 #
114
115 reset_test_env
116
117 }