From 1763f9e4ccb4b204f842d7f2f62dff434bd769a6 Mon Sep 17 00:00:00 2001 From: iliajie Date: Sat, 12 Nov 2022 11:39:38 +0200 Subject: [PATCH] Fix to always prioritize module config over hardcoded shell flavors --- xterm/shellserver.pl | 46 +++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/xterm/shellserver.pl b/xterm/shellserver.pl index 474cd32d2..1d542d60d 100755 --- a/xterm/shellserver.pl +++ b/xterm/shellserver.pl @@ -124,17 +124,6 @@ if ($shinit) { } } -# User config environmental variables -if ($config{'flavors_envs'}) { - # Admin added to the module config custom - # environmental variables, load them now - my @flavors_envs = split(/\t+/, $config{'flavors_envs'}); - foreach my $flavors_env (@flavors_envs) { - my ($k, $v) = split(/=/, $flavors_env, 2); - $ENV{$k} = $v; - } - } - # Add additional shell envs from internal # shell flavors if defined for the # current user shell @@ -148,6 +137,18 @@ if ($shinit && $shinit->{'envs'}) { } } +# User defined environmental variables +# (in module config) to set +if ($config{'flavors_envs'}) { + # Admin added to the module config custom + # environmental variables, load them now + my @flavors_envs = split(/\t+/, $config{'flavors_envs'}); + foreach my $flavors_env (@flavors_envs) { + my ($k, $v) = split(/=/, $flavors_env, 2); + $ENV{$k} = $v; + } + } + # Set terminal $ENV{'TERM'} = 'xterm-256color'; $ENV{'HOME'} = $uinfo[7]; @@ -163,17 +164,6 @@ if (!$pid) { } print STDERR "shell process is $pid\n"; -# User config commands to run on shell login -if ($config{'flavors_cmds'}) { - # Admin added to the module config custom - # commands to run on shell login, run now - my @flavors_cmds = split(/\t+/, $config{'flavors_cmds'}); - foreach my $flavors_cmd (@flavors_cmds) { - my $cmd = " $flavors_cmd\r"; - syswrite($shellfh, $cmd, length($cmd)); - } - } - # Run additional shell commands from internal # shell flavors, if defined for the current # user shell to run after initial login @@ -188,6 +178,18 @@ if ($shinit && $shinit->{'cmds'}) { } } +# User defined commands (in module +# config) to run on shell login +if ($config{'flavors_cmds'}) { + # Admin added to the module config custom + # commands to run on shell login, run now + my @flavors_cmds = split(/\t+/, $config{'flavors_cmds'}); + foreach my $flavors_cmd (@flavors_cmds) { + my $cmd = " $flavors_cmd\r"; + syswrite($shellfh, $cmd, length($cmd)); + } + } + # Detach from controlling terminal if (fork()) { exit(0);