File: xpra_Xdummy

package info (click to toggle)
xpra 3.1.5%2Bdfsg1-0.2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 18,692 kB
  • sloc: python: 117,045; javascript: 94,780; ansic: 2,843; sh: 939; cpp: 268; makefile: 212; xml: 89
file content (96 lines) | stat: -rwxr-xr-x 2,596 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#@PydevCodeAnalysisIgnore

find_ld_linux() {
	arch=$(uname -m)

	if [ $arch = "x86_64" ]; then
		LD_LINUX='/lib64/ld-linux-x86-64.so.2'
	elif [ $arch = "i386" ]; then
		LD_LINUX='/lib/ld-linux.so.2'
	elif [ $arch = "i486" ]; then
		LD_LINUX='/lib/ld-linux.so.2'
	elif [ $arch = "i586" ]; then
		LD_LINUX='/lib/ld-linux.so.2'
	elif [ $arch = "i686" ]; then
		LD_LINUX='/lib/ld-linux.so.2'
	elif [ $arch = "armel" ]; then
		LD_LINUX='/lib/ld-linux.so.3'
	elif [ $arch = "armhfp" ]; then
		LD_LINUX='/lib/ld-linux.so.3'
	elif [ $arch = "armhf" ]; then
		LD_LINUX='/lib/ld-linux-armhf.so.3'
	elif [ $arch = "ppc64" ]; then
		LD_LINUX='/lib64/ld64.so.1'
	elif [ $arch = "s390x" ]; then
		LD_LINUX='/lib64/ld64.so.1'
	else
		#suitable for: powerpc/ppc, mips/mipsel, s390 and others:
		LD_LINUX='/lib/ld.so.1'
	fi

	if [ ! -x "$LD_LINUX" ]; then
		# Musl C / Alpine Linux
		ldmusl=$(ls /lib | grep ^ld-musl)
		if [ -n "$ldmusl" ]; then
			LD_LINUX="/lib/$ldmusl"
		else
			LD_LINUX=''
			echo "could not determine ld path for $arch, please file an xpra bug"
		fi
	fi
}

if [ -x "/usr/libexec/Xorg" ]; then
	#Fedora 22+ workaround where /usr/bin/Xorg is not suid
	#because it is a script, which calls /usr/libexec/Xorg.wrap
	#which is setuid, and which eventually calls this one:
	XORG_BIN="/usr/libexec/Xorg"
elif [ -x "/usr/libexec/Xorg.bin" ]; then
	#Fedora 21 workaround where /usr/bin/Xorg is not suid
	#because it is a script, which calls /usr/libexec/Xorg.wrap
	#which is setuid, and which eventually calls this one:
	XORG_BIN="/usr/libexec/Xorg.bin"
elif [ -x "/usr/lib/xorg-server/Xorg" ]; then
	#Arch Linux:
	exec "/usr/lib/xorg-server/Xorg" "$@"
elif [ -x "/usr/lib/Xorg" ]; then
	#Arch Linux (new 2019):
	exec "/usr/lib/Xorg" "$@"
elif [ -x "/usr/lib/xorg/Xorg" ]; then
	#Ubuntu 16.10:
	exec "/usr/lib/xorg/Xorg" "$@"
else
	XORG_BIN=$(which Xorg)
fi

if [ ! -x "$XORG_BIN" ]; then
	echo "failed to locate Xorg binary to run"
	exit 1
fi

if [ -u "$XORG_BIN" ]; then
	# setuid is set, we need to do magic
	find_ld_linux
	if [ -n "$LD_LINUX" ]; then
		if [ -n "$BASH" ]; then
			#running in bash, can show a more helpful command name:
			exec -a "Xorg-nosuid" "$LD_LINUX" "$XORG_BIN" "$@"
		else
			exec "$LD_LINUX" "$XORG_BIN" "$@"
		fi
	else
		#fallback to making a copy of the binary:
		DOTXPRA_DIR="$HOME/.xpra"
		if [ ! -d "$DOTXPRA_DIR" ]; then
	 		mkdir "$DOTXPRA_DIR"
	 		chmod 700 "$DOTXPRA_DIR"
	 	fi
		NOSUID_XORG="$DOTXPRA_DIR/Xorg-nosuid"
	 	cp -f "$XORG_BIN" "$NOSUID_XORG"
	 	exec "$NOSUID_XORG" "$@"
	 fi
else
	# setuid is not set on xorg_bin
	exec "$XORG_BIN" "$@"
fi