OSDN Git Service

su: import CyanogenMod's version for Superuser
[android-x86/system-extras.git] / su / su.h
1 /*
2 ** Copyright 2010, Adam Shanks (@ChainsDD)
3 ** Copyright 2008, Zinx Verituse (@zinxv)
4 **
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
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
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.
16 */
17
18 #ifndef SU_h
19 #define SU_h 1
20
21 #define REQUESTOR_DATA_PATH "/data/data/com.noshufou.android.su"
22 #define REQUESTOR_CACHE_PATH REQUESTOR_DATA_PATH "/cache"
23
24 #define REQUESTOR_DATABASES_PATH REQUESTOR_DATA_PATH "/databases"
25 #define REQUESTOR_DATABASE_PATH REQUESTOR_DATABASES_PATH "/permissions.sqlite"
26
27 #define DEFAULT_COMMAND "/system/bin/sh"
28
29 #define SOCKET_PATH_TEMPLATE REQUESTOR_CACHE_PATH "/.socketXXXXXX"
30
31 #define VERSION "3.0.3.2"
32 #define VERSION_CODE 15
33
34 #define DATABASE_VERSION 6
35
36 struct su_initiator {
37     pid_t pid;
38     unsigned uid;
39     char bin[PATH_MAX];
40     char args[4096];
41 };
42
43 struct su_request {
44     unsigned uid;
45     char *command;
46 };
47
48 enum {
49     DB_INTERACTIVE,
50     DB_DENY,
51     DB_ALLOW
52 };
53
54 extern int send_intent(struct su_initiator *from, struct su_request *to, const char *socket_path, int allow, int type);
55
56 #if 0
57 #undef LOGE
58 #define LOGE(fmt,args...) fprintf(stderr, fmt , ## args )
59 #undef LOGD
60 #define LOGD(fmt,args...) fprintf(stderr, fmt , ## args )
61 #undef LOGW
62 #define LOGW(fmt,args...) fprintf(stderr, fmt , ## args )
63 #endif
64
65 #define PLOGE(fmt,args...) LOGE(fmt " failed with %d: %s" , ## args , errno, strerror(errno))
66 #define PLOGEV(fmt,err,args...) LOGE(fmt " failed with %d: %s" , ## args , err, strerror(err))
67
68 #endif