summaryrefslogtreecommitdiffstats
path: root/core/modules/vmware-common/data/opt/openslx/pam/hooks/session-open.d/vmware-tmpfs-dir
blob: ed5633ed524221961dc45067dbcae6c097c82772 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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