2 ** Copyright 2010, Adam Shanks (@ChainsDD)
3 ** Copyright 2008, Zinx Verituse (@zinxv)
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
26 // CyanogenMod-specific behavior
27 #define CM_ROOT_ACCESS_DISABLED 0
28 #define CM_ROOT_ACCESS_APPS_ONLY 1
29 #define CM_ROOT_ACCESS_ADB_ONLY 2
30 #define CM_ROOT_ACCESS_APPS_AND_ADB 3
32 #define DAEMON_SOCKET_PATH "/dev/socket/su-daemon/"
34 #define DEFAULT_SHELL "/system/bin/sh"
36 #define xstr(a) str(a)
40 #define VERSION_CODE 16
42 #define VERSION xstr(VERSION_CODE) " cm-su"
44 #define PROTO_VERSION 1
68 struct su_initiator from;
71 char sock_path[PATH_MAX];
80 extern void set_identity(unsigned int uid);
82 static inline char *get_command(const struct su_request *to)
88 char* ret = to->argv[to->optind];
94 int appops_start_op_su(int uid, const char *pkgName);
95 int appops_finish_op_su(int uid, const char *pkgName);
98 int connect_daemon(int argc, char *argv[], int ppid);
99 int su_main(int argc, char *argv[], int need_client);
100 // for when you give zero fucks about the state of the child process.
101 // this version of fork understands you don't care about the child.
102 // deadbeat dad fork.
103 int fork_zero_fucks();
111 #define PLOGE(fmt,args...) ALOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
112 #define PLOGEV(fmt,err,args...) ALOGE(fmt " failed with %d: %s", ##args, err, strerror(err))