-
Notifications
You must be signed in to change notification settings - Fork 4
/
ideal_init.h
297 lines (285 loc) · 6.69 KB
/
ideal_init.h
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*
* Ideal init
*
* Copyright (C) 2015 JackpotClavin <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*/
#ifndef _IDEAL_INIT_H_
#define _IDEAL_INIT_H_
const std::string II_START = "II: ";
const std::string II_NEW_SECTION = "II: ON: ";
const std::string II_SERVICE_DECLARED = "init.svc.";
const std::string II_SERVICE_RUNNING = "running";
const std::string SERVICE_START = "service";
enum state {
NOTHING = 0,
JUST_MKDIR,
MKDIR_AND_CHMOD
};
const std::string valid_syscalls[] = {
"mkdir",
"chmod",
"chown",
"write",
"symlink",
"mount",
"setrlimit",
"setprop",
"echo",
"service"
};
const std::string ii_syscalls[] = {
"MKDIR",
"CHMOD",
"CHOWN",
"WRITE",
"SYMLINK",
"MOUNT",
"SETRLIMIT",
"SETPROP",
"ECHO",
"SERVICE",
};
std::string get_uid_gid(int n) {
switch (n) {
case 0:
return "root";
break;
case 1000:
return "system";
break;
case 1001:
return "radio";
break;
case 1002:
return "bluetooth";
break;
case 1003:
return "graphics";
break;
case 1004:
return "input";
break;
case 1005:
return "audio";
break;
case 1006:
return "camera";
break;
case 1007:
return "log";
break;
case 1008:
return "compass";
break;
case 1009:
return "mount";
break;
case 1010:
return "wifi";
break;
case 1011:
return "adb";
break;
case 1012:
return "install";
break;
case 1013:
return "media";
break;
case 1014:
return "dhcp";
break;
case 1015:
return "sdcard_rw";
break;
case 1016:
return "vpn";
break;
case 1017:
return "keystore";
break;
case 1018:
return "usb";
break;
case 1019:
return "drm";
break;
case 1020:
return "mdnsr";
break;
case 1021:
return "gps";
break;
case 1023:
return "media_rw";
break;
case 1024:
return "mtp";
break;
case 1026:
return "drmrpc";
break;
case 1027:
return "nfc";
break;
case 1028:
return "sdcard_r";
break;
case 1029:
return "clat";
break;
case 1030:
return "loop_radio";
break;
case 1031:
return "mediadrm";
break;
case 1032:
return "package_info";
break;
case 1033:
return "sdcard_pics";
break;
case 1034:
return "sdcard_av";
break;
case 1035:
return "sdcard_all";
break;
case 1036:
return "logd";
break;
case 1037:
return "shared_relro";
break;
case 1049:
return "audit";
break;
case 2000:
return "shell";
break;
case 2001:
return "cache";
break;
case 2002:
return "diag";
break;
case 3001:
return "net_bt_admin";
break;
case 3002:
return "net_bt";
break;
case 3003:
return "inet";
break;
case 3004:
return "net_raw";
break;
case 3005:
return "net_admin";
break;
case 3006:
return "net_bw_stats";
break;
case 3010:
return "ims";
break;
case 3007:
return "net_bw_acct";
break;
case 3008:
return "net_bt_stack";
break;
case 3009:
return "qcom_diag";
break;
case 3011:
return "sensors";
break;
case 3012:
return "rfs";
break;
case 3013:
return "rfs_shared";
break;
case 9997:
return "everybody";
break;
case 9998:
return "misc";
break;
case 9999:
return "nobody";
break;
}
return "UNKNOWN_UID/GID";
}
/*
* These are the fs-independent mount-flags: up to 32 flags are supported
*/
#define MS_RDONLY 1 /* Mount read-only */
#define MS_NOSUID 2 /* Ignore suid and sgid bits */
#define MS_NODEV 4 /* Disallow access to device special files */
#define MS_NOEXEC 8 /* Disallow program execution */
#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
#define MS_NOATIME 1024 /* Do not update access times. */
#define MS_NODIRATIME 2048 /* Do not update directory access times */
#define MS_BIND 4096
#define MS_MOVE 8192
#define MS_REC 16384
#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
MS_VERBOSE is deprecated. */
#define MS_SILENT 32768
#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
#define MS_UNBINDABLE (1<<17) /* change to unbindable */
#define MS_PRIVATE (1<<18) /* change to private */
#define MS_SLAVE (1<<19) /* change to slave */
#define MS_SHARED (1<<20) /* change to shared */
#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
#define MS_I_VERSION (1<<23) /* Update inode I_version field */
#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
#define MS_NOSEC (1<<28)
#define MS_BORN (1<<29)
#define MS_ACTIVE (1<<30)
#define MS_NOUSER (1<<31)
static struct {
const char *name;
unsigned flag;
} mount_flags[] = {
{ "noatime", MS_NOATIME },
{ "noexec", MS_NOEXEC },
{ "nosuid", MS_NOSUID },
{ "nodev", MS_NODEV },
{ "nodiratime", MS_NODIRATIME },
{ "ro", MS_RDONLY },
{ "rw", 0 },
{ "remount", MS_REMOUNT },
{ "bind", MS_BIND },
{ "rec", MS_REC },
{ "unbindable", MS_UNBINDABLE },
{ "private", MS_PRIVATE },
{ "slave", MS_SLAVE },
{ "shared", MS_SHARED },
{ "defaults", 0 },
{ 0, 0 },
};
#endif