Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
32c8e752
Commit
32c8e752
authored
Dec 01, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More precise logging configuration
parent
a5e4f3cc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
11 deletions
+37
-11
Android.mk
jni/Android.mk
+2
-3
logging.h
jni/include/logging.h
+29
-2
file.c
jni/utils/file.c
+6
-6
No files found.
jni/Android.mk
View file @
32c8e752
...
...
@@ -50,7 +50,7 @@ LOCAL_SRC_FILES := \
su/su_daemon.c \
su/su_socket.c
LOCAL_CFLAGS := -DIS_DAEMON
LOCAL_CFLAGS := -DIS_DAEMON
-DSELINUX
LOCAL_LDLIBS := -llog
include $(BUILD_EXECUTABLE)
...
...
@@ -80,7 +80,6 @@ LOCAL_SRC_FILES := \
magiskpolicy/rules.c \
magiskpolicy/sepolicy.c
LOCAL_CFLAGS := -DNO_SELINUX
LOCAL_LDFLAGS := -static
include $(BUILD_EXECUTABLE)
...
...
@@ -109,7 +108,7 @@ LOCAL_SRC_FILES := \
utils/cpio.c \
utils/vector.c
LOCAL_CFLAGS := -D
NO_SELINUX
LOCAL_CFLAGS := -D
XWRAP_EXIT
LOCAL_LDLIBS := -lz
include $(BUILD_EXECUTABLE)
...
...
jni/include/logging.h
View file @
32c8e752
...
...
@@ -11,8 +11,24 @@
#define str(a) #a
#define xstr(a) str(a)
/**************
* No logging *
**************/
#define LOGI(...)
#define LOGE(...)
#define PLOGE(...)
/******************
* Daemon logging *
******************/
#ifdef IS_DAEMON
#undef LOGI
#undef LOGE
#undef PLOGE
#include <pthread.h>
#include <android/log.h>
...
...
@@ -41,7 +57,17 @@ void start_debug_full_log();
void
stop_debug_full_log
();
void
start_debug_log
();
#else // IS_DAEMON
#endif
/********************
* Tools Log & Exit *
********************/
#ifdef XWRAP_EXIT
#undef LOGI
#undef LOGE
#undef PLOGE
#include <stdio.h>
...
...
@@ -49,6 +75,7 @@ void start_debug_log();
#define LOGE(...) { fprintf(stderr, __VA_ARGS__); exit(1); }
#define PLOGE(fmt, args...) { fprintf(stderr, fmt " failed with %d: %s\n\n", ##args, errno, strerror(errno)); exit(1); }
#endif // IS_DAEMON
#endif
#endif // _LOGGING_H_
jni/utils/file.c
View file @
32c8e752
...
...
@@ -12,7 +12,7 @@
#include <sys/inotify.h>
#include <linux/fs.h>
#if
ndef NO_
SELINUX
#if
def
SELINUX
#include <selinux/selinux.h>
#endif
...
...
@@ -238,8 +238,8 @@ void wait_till_exists(const char *target) {
int
getattr
(
const
char
*
path
,
struct
file_attr
*
a
)
{
if
(
xlstat
(
path
,
&
a
->
st
)
==
-
1
)
return
-
1
;
#ifdef SELINUX
char
*
con
=
""
;
#ifndef NO_SELINUX
if
(
lgetfilecon
(
path
,
&
con
)
==
-
1
)
return
-
1
;
strcpy
(
a
->
con
,
con
);
...
...
@@ -277,7 +277,7 @@ int setattr(const char *path, struct file_attr *a) {
return
-
1
;
if
(
chown
(
path
,
a
->
st
.
st_uid
,
a
->
st
.
st_gid
)
<
0
)
return
-
1
;
#if
ndef NO_
SELINUX
#if
def
SELINUX
if
(
strlen
(
a
->
con
)
&&
lsetfilecon
(
path
,
a
->
con
)
<
0
)
return
-
1
;
#endif
...
...
@@ -294,7 +294,7 @@ int setattrat(int dirfd, const char *pathname, struct file_attr *a) {
}
int
fsetattr
(
int
fd
,
struct
file_attr
*
a
)
{
#if
ndef NO_
SELINUX
#if
def
SELINUX
char
path
[
PATH_MAX
];
fd_getpath
(
fd
,
path
,
sizeof
(
path
));
return
setattr
(
path
,
a
);
...
...
@@ -319,7 +319,7 @@ void fclone_attr(const int sourcefd, const int targetfd) {
fsetattr
(
targetfd
,
&
a
);
}
#if
ndef NO_
SELINUX
#if
def
SELINUX
#define UNLABEL_CON "u:object_r:unlabeled:s0"
#define SYSTEM_CON "u:object_r:system_file:s0"
...
...
@@ -355,7 +355,7 @@ void restorecon(int dirfd, int force) {
}
}
#endif //
NO_
SELINUX
#endif // SELINUX
static
void
_mmap
(
int
rw
,
const
char
*
filename
,
void
**
buf
,
size_t
*
size
)
{
struct
stat
st
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment