diff options
author | Simon Rettberg | 2024-05-13 14:32:33 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-05-13 14:32:33 +0200 |
commit | c3f6d244d119ebb458e59fd158c338153c778141 (patch) | |
tree | 5d4b0eeeede5942f99793917ff0e674073a0908f | |
parent | [run-virt/vmchooser2] Initial support for CoW-sessions (diff) | |
download | mltk-c3f6d244d119ebb458e59fd158c338153c778141.tar.gz mltk-c3f6d244d119ebb458e59fd158c338153c778141.tar.xz mltk-c3f6d244d119ebb458e59fd158c338153c778141.zip |
[run-virt] openslx.exe: Don't do persistent changes in admin/edit mode
5 files changed, 63 insertions, 21 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc index cf6592f1..df76c93e 100755 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc @@ -57,6 +57,13 @@ SCRIPTEXT=$(grep scriptExt "$DISKMOUNTDIR/openslx.ini" | cut -f 2 -d "=") MUTESOUND=$(grep muteSound "$DISKMOUNTDIR/openslx.ini" | cut -f 2 -d "=") SOUNDVOL="100%" +# Edit mode, VM is persistent +val=$( grep '^persistentMode=' "$SLXCONFIGFILE" | cut -d '=' -f 2) +PERSISTENT_MODE= +if [ -n "$val" ] && [ "$val" -ne 0 ]; then + PERSISTENT_MODE=1 +fi + ##### Programs interfering with resolution setting ##### KILLRESPROGS="kscreen_backend_launcher" diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc index 8b394334..85f185a3 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc @@ -121,18 +121,19 @@ function mount_share() unset PASSWD fi if [ "$ERR" -eq 0 ]; then - logger "openslx sharemapper: Linking ${SHARENAME}, if possible." + if [ -z "$PERSISTENT_MODE" ]; then + logger "openslx sharemapper: Linking ${SHARENAME}, if possible." - if [ -n "${SHARENAME}" ]; then - ln -s "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARENAME" - chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARENAME" - logger "openslx sharemapper: ${SHARENAME} linked." - elif [ -n "${SHARELETTER}" ]; then - ln -s "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARELETTER" - chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARELETTER" - logger "openslx sharemapper: No sharename found, share letter ${SHARELETTER} linked." + if [ -n "${SHARENAME}" ]; then + ln -sn "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARENAME" + chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARENAME" + logger "openslx sharemapper: ${SHARENAME} linked." + elif [ -n "${SHARELETTER}" ]; then + ln -sn "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARELETTER" + chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARELETTER" + logger "openslx sharemapper: No sharename found, share letter ${SHARELETTER} linked." + fi fi - else logger "openslx sharemapper: deleting previously creates share mount dir $USERSHAREDIR." rmdir "$USERSHAREDIR" 2>/dev/null @@ -150,21 +151,28 @@ function mount_home() unset USER unset PASSWD - case $ERR in 1) logger "openslx sharemapper: could not mount home share." + case $ERR in + 1) + logger "openslx sharemapper: could not mount home share." echo "Konnte Home-Laufwerk nicht einhängen!" >> "$USERLOGFILE" ;; - 2) logger "openslx sharemapper: home share seems to be already mounted." + 2) + logger "openslx sharemapper: home share seems to be already mounted." ;; - 0) logger "openslx sharemapper: Linking ${USERDESKTOP}/$(basename $USERHOMEDIR), if possible." - # Changed: Link on Desktop no longer "Home-verz.", but same - # name as last part of $USERHOMEDIR (-->PERSISTENT) - # ln -s "$USERHOMEDIR" "${USERDESKTOP}"/"$SHARENAME" - ln -s "$USERHOMEDIR" "${USERDESKTOP}"/$(basename "$USERHOMEDIR") - chown "$LOCALUSER" "${USERDESKTOP}"/$(basename "$USERHOMEDIR") - logger "openslx sharemapper: "${USERDESKTOP}"/$(basename "$USERHOMEDIR") linked." + 0) + if [ -z "$PERSISTENT_MODE" ]; then + logger "openslx sharemapper: Linking ${USERDESKTOP}/$(basename $USERHOMEDIR), if possible." + # Changed: Link on Desktop no longer "Home-verz.", but same + # name as last part of $USERHOMEDIR (-->PERSISTENT) + # ln -s "$USERHOMEDIR" "${USERDESKTOP}"/"$SHARENAME" + ln -sn "$USERHOMEDIR" "${USERDESKTOP}"/$(basename "$USERHOMEDIR") + chown "$LOCALUSER" "${USERDESKTOP}"/$(basename "$USERHOMEDIR") + logger "openslx sharemapper: "${USERDESKTOP}"/$(basename "$USERHOMEDIR") linked." + fi + ;; + *) + logger "openslx sharemapper: Unknown error level mounting home share." ;; - *) logger "openslx sharemapper: Unknown error level mounting home share." - ;; esac } diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe Binary files differindex 7a9e5e6c..73c19530 100755 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc index 3b1d9f18..87f3d736 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc @@ -116,6 +116,10 @@ setup_virtual_floppy() { # Enable openslx.exe debug output if we're running in debug mode local debug= $DEBUG && debug=1 + local editmode=0 + if is_on VMCHOOSER_ADMIN_MODE; then + editmode=1 + fi cat > "${FLOPPYDIR}/openslx.ini" <<-EOF [openslx] @@ -133,6 +137,7 @@ setup_virtual_floppy() { noHomeWarn=${SHARE_NO_HOME_WARN} runMode=${SLX_RUNMODE_MODULE} debug=${debug} + persistentMode=${editmode} [remap] documents=${SHARE_DOCUMENTS} diff --git a/core/modules/run-virt/winres/src/winres.c b/core/modules/run-virt/winres/src/winres.c index e8e03947..1011e1e8 100644 --- a/core/modules/run-virt/winres/src/winres.c +++ b/core/modules/run-virt/winres/src/winres.c @@ -74,6 +74,7 @@ static BOOL _passCreds = FALSE; static BOOL _noHomeWarn = FALSE; static BOOL _deletedCredentials = FALSE; static BOOL _scriptDone = TRUE, _mountDone = TRUE; // Will be set to false if we actually wait for something... +static BOOL _persistentMode = FALSE; // VM being edited, don't do any changes to system (shortcuts, regedit, ) static char *shost = NULL, *sport = NULL, *suser = NULL, *spass = NULL; #define SCRIPTFILELEN (50) @@ -106,6 +107,9 @@ static HRESULT createFolderShortcut(wchar_t* sTargetfile, wchar_t* sLinkfile, wc static void alog(const char *fmt, ...) { + if (_persistentMode) + return; + FILE *f = _wfopen(logFile, L"a+"); if (f == NULL) return; time_t raw = time(NULL); @@ -124,6 +128,9 @@ static void alog(const char *fmt, ...) static void wlog(const wchar_t *fmt, ...) { + if (_persistentMode) + return; + wchar_t wbuffer[1000]; char abuffer[1000]; va_list args; @@ -431,6 +438,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine if (hUser32 == NULL) { alog("Cannot load user32.dll"); } + if (GetPrivateProfileIntA("openslx", "persistentMode", 0, SETTINGS_FILE) != 0) { + _persistentMode = TRUE; + } winVer.dwOSVersionInfoSize = sizeof(winVer); BOOL retVer = GetVersionEx(&winVer); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); @@ -918,6 +928,9 @@ static int setResVMware(struct resolution *res, int nres) static int optimizeForRemote() { + if (_persistentMode) + return; + LONG ret; HKEY hKey; @@ -1499,6 +1512,9 @@ static uint8_t* hex2bin(char *szHexString) static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile, wchar_t* comment) { + if (_persistentMode) + return S_OK; + HRESULT hRes; /* Returned COM result code */ IShellLink* pShellLink; /* IShellLink object pointer */ IPersistFile* pPersistFile; /* IPersistFile object pointer */ @@ -1551,6 +1567,9 @@ static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile, wchar static BOOL patchRegPath(BOOL *patchOk, BOOL *anyMapped, HKEY hKey, wchar_t *letter, wchar_t *value, ...) { + if (_persistentMode) + return; + wchar_t *folder = NULL; wchar_t first[MAX_PATH] = {0}; wchar_t path[MAX_PATH]; @@ -1612,6 +1631,9 @@ typedef BOOL (WINAPI *P32TYPE)(HANDLE, PROCESSENTRY32W*); static void patchUserPaths(wchar_t *letter) { + if (_persistentMode) + return; + LONG ret; HKEY hKey; BOOL patchOk = TRUE; |