summaryrefslogtreecommitdiffstats
path: root/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir')
-rw-r--r--core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir17
1 files changed, 17 insertions, 0 deletions
diff --git a/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir b/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir
new file mode 100644
index 00000000..ed5633ed
--- /dev/null
+++ b/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir
@@ -0,0 +1,17 @@
+create_vmware_tmpdir() {
+ local tmpdir="/tmp/vmware-${PAM_USER}"
+ [ -d "$tmpdir" ] || mkdir -p "$tmpdir"
+ grep -qE '^tmpfs\s+'"$tmpdir" /proc/mounts && return 0
+
+ local mount_opts="-o mode=0700,size=100%"
+ local user_uid="$(id -u $PAM_USER)"
+ [ -n "$user_uid" ] && mount_opts="${mount_opts},uid=${user_uid}"
+ local user_gid="$(id -g $PAM_USER)"
+ [ -n "$user_gid" ] && mount_opts="${mount_opts},gid=${user_gid}"
+ # NO QUOTES!!!1
+ mount -t tmpfs tmpfs ${mount_opts} "$tmpdir"
+}
+if [ "x$PAM_SERVICE" != "xsu" -a "x$PAM_SERVICE" != "xsudo" ]; then
+ create_vmware_tmpdir
+fi
+true