Skip to content

Commit dccdaa2

Browse files
committed
Fix: onLogin script when /etc/profile.d is executed with sh
1 parent 9f4af97 commit dccdaa2

File tree

7 files changed

+12
-28
lines changed

7 files changed

+12
-28
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
scriptDir=$(/usr/sbin/linuxmuster-linuxclient7 get-constant scriptDir)
2-
source $scriptDir/executeHookWithEnvFix.sh onLogin
2+
tmpEnvFile=$(/usr/sbin/linuxmuster-linuxclient7 get-constant tmpEnvironmentFilePath)
3+
4+
rm -f $tmpEnvFile
5+
6+
LinuxmusterLinuxclient7EnvFixActive=1 PATH=$PATH:$scriptDir/env-fix $scriptDir/onLogin
7+
8+
. $tmpEnvFile
9+
rm -f $tmpEnvFile

usr/lib/python3/dist-packages/linuxmusterLinuxclient7/templates.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _apply(templatePath):
5050
# never ever overwrite sssd.conf, this will lead to issues!
5151
# sssd.conf is written by `realm join`!
5252
if targetFilePath in constants.notTemplatableFiles:
53-
logging.warning("Skipping forbidden file {}".format(targetFilePath))
53+
logging.warning(f"Skipping forbidden file {targetFilePath}")
5454
return True
5555

5656
# create target directory
@@ -61,7 +61,7 @@ def _apply(templatePath):
6161
fileData = _stripComment(fileData)
6262

6363
# write config file
64-
logging.debug("-> to {}".format(targetFilePath))
64+
logging.debug(f"-> to {targetFilePath}")
6565
with open(targetFilePath, 'w') as targetFile:
6666
targetFile.write(fileData)
6767

usr/sbin/lmn-export renamed to usr/share/linuxmuster-linuxclient7/scripts/env-fix/lmn-export

File renamed without changes.

usr/sbin/lmn-unset renamed to usr/share/linuxmuster-linuxclient7/scripts/env-fix/lmn-unset

File renamed without changes.

usr/share/linuxmuster-linuxclient7/scripts/executeHookWithEnvFix.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
This client uses Python. This brings a major problem: In Python it is not possible to modify the environment of the parent process.
22
Because of this, hook scripts must use `lmn-export` and `lmn-unset` instead of `export` and `unset`.
33
These scripts write the environment variables to a temporary file in `~/.linuxmuster-linuxclient7-environment.sh` which is then sourced afterwards.
4-
This only works for the `onLogin.d` hook / the `logon.sh` script and is achieved by sourcing the script `/usr/share/linuxmuster-linuxclient7/scripts/executeHookWithEnvFix.sh` in `/etc/profile.d/99-linuxmuster-linuxclient7.sh` which then calls the `onLogin` script and sources `~/.linuxmuster-linuxclient7-environment.sh` afterwards.
4+
This only works for the `onLogin.d` hook / the `logon.sh` script and is achieved in `/etc/profile.d/99-linuxmuster-linuxclient7.sh` which calls the `onLogin` script and sources `~/.linuxmuster-linuxclient7-environment.sh` afterwards.

wiki/Insights/Script-calling-strategy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This file is placed there in adsso-setup via the template in `/usr/share/linuxmu
1111
Pam_exec calls this script on login AND on logout. If it is a login our logout is determined by the `PAM_TYPE` environment variable.
1212

1313
### onLogin
14-
This is called via `/usr/share/linuxmuster-linuxclient7/scripts/executeHookWithEnvFix.sh`, which is called by `/etc/profile.d/99-linuxmuster-linuxclient7.sh` The reason for this is the [environment workaround](Environment-workaround)
14+
This is called via `/etc/profile.d/99-linuxmuster-linuxclient7.sh`. Please note the [environment workaround](Environment-workaround).
1515

1616
### onSessionStart
1717
This is called via `/home/$user/.config/autostart`.

0 commit comments

Comments
 (0)