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 initConfColors: Ignore invalid default.*\\n)?DEBUG setConf: colors set to '.*'"
55 lappend ans "DEBUG setConf: color set to '0'"
56 lappend ans "DEBUG setConf: pager set to '$install_pagercmd'"
57 lappend ans "DEBUG setState: shelltype set to 'sh'"
58 lappend ans "DEBUG setState: paginate set to '0'"
59 lappend ans "DEBUG setState: report_format set to 'regular'"
60 lappend ans "DEBUG setState: reportfd set to 'stderr'"
61 lappend ans "DEBUG setState: timer set to '0'"
62 lappend ans $vers_reportre
63 lappend ans "DEBUG setConf: logger set to '$::install_loggercmd'"
64 lappend ans "DEBUG setState: logging set to '0'"
65 lappend ans "DEBUG setState: logfd set to ''"
66 lappend ans "DEBUG setState: error_count set to '0'"
67 testouterr_cmd_re sh {--no-pager -D -V} {} [join $ans \n]
68 restore_file_perms $tclextlib_file
69
70 # replace Tcl extension library by a non lib file
71 file rename $tclextlib_file $tclextlib_file.orig
72 file copy lib/envmodules.c $tclextlib_file
73 set tclextlib_file_abs_re [regsub -all "\(\[.+?\]\)" [file normalize $tclextlib_file] {\\\1}]
74 if {$os_name eq {darwin}} {
75 set tserr "$error_msgs: dlopen\\\($tclextlib_file_abs_re,.*"
76 } else {
77 set tserr "$error_msgs: couldn't load file \"$tclextlib_file_abs_re\":.*"
78 }
79 testouterr_cmd_re sh {-V} {} $tserr
80 file delete $tclextlib_file
81 file rename $tclextlib_file.orig $tclextlib_file
82 }
83
84 # restrict read access to site-specific configuration script
85 if {[file readable $siteconfig_file] && [file owned $siteconfig_file]} {
86 change_file_perms $siteconfig_file ugo-rx
87 testouterr_cmd_re sh {-V} {} $vers_reportre
88 restore_file_perms $siteconfig_file
89 }
90
91 skip_if_quick_mode
92
93 # restrict read access to additional site-specific configuration script
94 if {![is_config_locked extra_siteconfig]} {
95 set addsiteconfig_file $env(TESTSUITEDIR)/example/siteconfig.tcl-2
96 setenv_var MODULES_SITECONFIG $addsiteconfig_file
97 change_file_perms $addsiteconfig_file ugo-rx
98 testouterr_cmd_re sh {-V} {} $vers_reportre
99 restore_file_perms $addsiteconfig_file
100 unsetenv_var MODULES_SITECONFIG
101 }
102
103 # restrict read access to MODULERCFILE
104 set modulerc_file $env(TESTSUITEDIR)/etc/modulerc
105 setenv_var MODULERCFILE $modulerc_file
106 change_file_perms $modulerc_file ugo-rx
107 testouterr_cmd_re sh {list} {} $no_loaded
108 restore_file_perms $modulerc_file
109 setenv_var MODULERCFILE $ORIG_MODULERCFILE
110
111
112 #
113 # Cleanup
114 #
115
116 reset_test_env
117
118 }