File: 00_default.lua

package info (click to toggle)
scratchbox2 2.2.4-1debian1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 5,392 kB
  • ctags: 5,239
  • sloc: ansic: 21,734; sh: 4,360; perl: 2,170; cpp: 1,913; makefile: 610; python: 184
file content (170 lines) | stat: -rw-r--r-- 5,061 bytes parent folder | download
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
-- Copyright (C) 2007 Lauri Leukkunen <lle@rahina.org>
-- Licensed under MIT license.
--
-- "simple" mode, to be used for software development & building
-- (as the name says, this is the simple solution; See/use the "devel"
-- mode when a more full-featured environment is needed)

-- Rule file interface version, mandatory.
--
rule_file_interface_version = "26"
----------------------------------

tools = tools_root
if (not tools) then
	tools = "/"
end

simple_chain = {
	next_chain = nil,
	binary = nil,
	rules = {
		-- -----------------------------------------------
		-- 1. The session directory
		{dir = session_dir, use_orig_path = true},

		-- -----------------------------------------------
		-- 2. Development environment special destinations:

		{prefix = "/sb2/wrappers",
		 replace_by = sbox_dir.."/share/scratchbox2/wrappers",
		 readonly = true},

		{prefix = "/sb2/scripts",
		 replace_by = sbox_dir.."/share/scratchbox2/scripts",
		 readonly = true},

		{prefix = sbox_user_home_dir, use_orig_path = true},

		{prefix = sbox_dir .. "/share/scratchbox2",
		 use_orig_path = true},

		{path = "/usr/bin/sb2-show",
		 use_orig_path = true, readonly = true},

		-- -----------------------------------------------
		-- 99. Other rules.
		{prefix = "/usr/share/python", use_orig_path = true, readonly = true},
		{prefix = "/usr/share/pyshared", use_orig_path = true, readonly = true},
		{prefix = "/usr/lib/pymodules", use_orig_path = true, readonly = true},
		{prefix = "/usr/lib/pyshared", use_orig_path = true, readonly = true},
		{prefix = "/usr/lib/python", use_orig_path = true, readonly = true},
		{prefix = "/usr/lib/perl", map_to = tools},
		{prefix = "/usr/lib/gcc", map_to = tools},
		{prefix = "/usr/lib/git-core", use_orig_path = true, readonly = true},
		{prefix = "/usr/lib", map_to = target_root},
		{prefix = "/usr/include", map_to = target_root},
		{prefix = "/home/user", map_to = target_root},
		{prefix = "/home", use_orig_path = true},
		{prefix = "/host_usr", map_to = target_root},
		{prefix = "/tmp", use_orig_path = true},
		{prefix = "/dev", use_orig_path = true},
		{prefix = "/proc", custom_map_funct = sb2_procfs_mapper,
		 virtual_path = true},
		{prefix = "/sys", use_orig_path = true},

		--
		-- Following 3 rules are needed because package
		-- "resolvconf" makes resolv.conf to be symlink that
		-- points to /etc/resolvconf/run/resolv.conf and
		-- we want them all to come from host.
		--
		{prefix = "/var/run/resolvconf", force_orig_path = true,
		 readonly = true},
		{prefix = "/etc/resolvconf", force_orig_path = true,
		 readonly = true},
		{prefix = "/etc/resolv.conf", force_orig_path = true,
		 readonly = true},

		{prefix = "/lib", map_to = target_root},
		--

		{prefix = tools, use_orig_path = true},
		{path = "/", use_orig_path = true},
		{prefix = "/", map_to = tools}
	}
}

function qemu_chain(cputransparency_cmd)
	local chain = {
		next_chain = nil,
		binary = basename(cputransparency_cmd),
		rules = {
			{prefix = "/usr/lib", map_to = target_root},
			{prefix = "/usr/local/lib", map_to = target_root},
			{prefix = "/tmp", use_orig_path = true},
			{prefix = "/dev", use_orig_path = true},
			{dir = "/proc", custom_map_funct = sb2_procfs_mapper,
			 virtual_path = true},
			{prefix = "/sys", use_orig_path = true},

			--
			-- Following 3 rules are needed because package
			-- "resolvconf" makes resolv.conf to be symlink that
			-- points to /etc/resolvconf/run/resolv.conf and
			-- we want them all to come from host.
			--
			{prefix = "/var/run/resolvconf", force_orig_path = true,
			 readonly = true},
			{prefix = "/etc/resolvconf", force_orig_path = true,
			 readonly = true},
			{prefix = "/etc/resolv.conf", force_orig_path = true,
			 readonly = true},

			{prefix = "/lib", map_to = target_root},
			--

			{prefix = tools, use_orig_path = true},
			{path = "/", use_orig_path = true},
			{prefix = "/", map_to = tools}
		}
	}
	return chain
end

export_chains = {
	qemu_chain(sbox_cputransparency_cmd),
	qemu_chain(sbox_cputransparency_native_cmd),
	simple_chain
}

-- Exec policy rules.

-- If the permission token exists and contains "root",
-- use fakeroot
local fakeroot_ld_preload = ""
if sb.get_session_perm() == "root" then
	fakeroot_ld_preload = ":"..host_ld_preload_fakeroot
end

default_exec_policy = {
	name = "Default",

	native_app_ld_preload_prefix = host_ld_preload..fakeroot_ld_preload,

	native_app_ld_library_path_prefix = 
		host_ld_library_path_libfakeroot ..
		host_ld_library_path_prefix ..
		host_ld_library_path_libsb2,
	native_app_ld_library_path_suffix = host_ld_library_path_suffix,
}

-- Note that the real path (mapped path) is used when looking up rules!
all_exec_policies_chain = {
	next_chain = nil,
	binary = nil,
	rules = {
		-- DEFAULT RULE (must exist):
		{prefix = "/", exec_policy = default_exec_policy}
	}
}

exec_policy_chains = {
	all_exec_policies_chain
}

-- This table lists all exec policies - this is used when the current
-- process wants to locate the currently active policy
all_exec_policies = {
	default_exec_policy,
}