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
ff3710de
Commit
ff3710de
authored
Jul 01, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor code changes across all sources
parent
db8dd9f1
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
50 additions
and
82 deletions
+50
-82
socket.cpp
native/jni/core/socket.cpp
+3
-3
magiskrc.h
native/jni/init/magiskrc.h
+1
-1
rootdir.cpp
native/jni/init/rootdir.cpp
+1
-0
hide_policy.cpp
native/jni/magiskhide/hide_policy.cpp
+0
-5
magiskhide.cpp
native/jni/magiskhide/magiskhide.cpp
+0
-1
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+1
-1
magiskpolicy.cpp
native/jni/magiskpolicy/magiskpolicy.cpp
+1
-1
magiskpolicy.h
native/jni/magiskpolicy/magiskpolicy.h
+3
-10
rules.cpp
native/jni/magiskpolicy/rules.cpp
+2
-2
sepolicy.h
native/jni/magiskpolicy/sepolicy.h
+3
-10
persist_properties.cpp
native/jni/resetprop/persist_properties.cpp
+1
-1
resetprop.h
native/jni/resetprop/private/resetprop.h
+3
-10
resetprop.cpp
native/jni/resetprop/resetprop.cpp
+14
-13
connect.cpp
native/jni/su/connect.cpp
+0
-1
pts.cpp
native/jni/su/pts.cpp
+1
-1
su.cpp
native/jni/su/su.cpp
+12
-13
su.h
native/jni/su/su.h
+1
-1
su_daemon.cpp
native/jni/su/su_daemon.cpp
+1
-1
file.cpp
native/jni/utils/file.cpp
+0
-1
selinux.h
native/jni/utils/include/selinux.h
+2
-6
No files found.
native/jni/core/socket.cpp
View file @
ff3710de
...
...
@@ -8,7 +8,7 @@
#include <daemon.h>
#include <utils.h>
#include <
magisk
.h>
#include <
logging
.h>
#define ABS_SOCKET_LEN(sun) (sizeof(sa_family_t) + strlen(sun->sun_path + 1) + 1)
...
...
@@ -34,7 +34,7 @@ int socket_accept(int sockfd, int timeout) {
.
fd
=
sockfd
,
.
events
=
POLL_IN
};
return
xpoll
(
&
pfd
,
1
,
timeout
*
1000
)
<=
0
?
-
1
:
xaccept4
(
sockfd
,
NULL
,
NULL
,
SOCK_CLOEXEC
);
return
xpoll
(
&
pfd
,
1
,
timeout
*
1000
)
<=
0
?
-
1
:
xaccept4
(
sockfd
,
nullptr
,
nullptr
,
SOCK_CLOEXEC
);
}
void
get_client_cred
(
int
fd
,
struct
ucred
*
cred
)
{
...
...
@@ -86,7 +86,7 @@ int recv_fd(int sockfd) {
cmsg
=
CMSG_FIRSTHDR
(
&
msg
);
if
(
cmsg
==
NULL
||
if
(
cmsg
==
nullptr
||
cmsg
->
cmsg_len
!=
CMSG_LEN
(
sizeof
(
int
))
||
cmsg
->
cmsg_level
!=
SOL_SOCKET
||
cmsg
->
cmsg_type
!=
SCM_RIGHTS
)
{
...
...
native/jni/init/magiskrc.h
View file @
ff3710de
#include <magisk.h>
#include <
magiskpolicy
.h>
#include <
selinux
.h>
constexpr
const
char
magiskrc
[]
=
"
\n\n
"
...
...
native/jni/init/rootdir.cpp
View file @
ff3710de
...
...
@@ -3,6 +3,7 @@
#include <fcntl.h>
#include <magisk.h>
#include <magiskpolicy.h>
#include <utils.h>
#include "init.h"
...
...
native/jni/magiskhide/hide_policy.cpp
View file @
ff3710de
...
...
@@ -63,11 +63,6 @@ void hide_unmount(int pid) {
chmod
(
SELINUX_POLICY
,
0440
);
}
getprop
([](
const
char
*
name
,
auto
,
auto
)
{
if
(
strstr
(
name
,
"magisk"
))
deleteprop
(
name
);
},
nullptr
,
false
);
vector
<
string
>
targets
;
// Unmount dummy skeletons and /sbin links
...
...
native/jni/magiskhide/magiskhide.cpp
View file @
ff3710de
...
...
@@ -8,7 +8,6 @@
#include <sys/types.h>
#include <sys/mount.h>
#include <magisk.h>
#include <daemon.h>
#include <utils.h>
#include <flags.h>
...
...
native/jni/magiskhide/proc_monitor.cpp
View file @
ff3710de
...
...
@@ -13,7 +13,7 @@
#include <vector>
#include <bitset>
#include <
magisk
.h>
#include <
logging
.h>
#include <utils.h>
#include "magiskhide.h"
...
...
native/jni/magiskpolicy/magiskpolicy.cpp
View file @
ff3710de
...
...
@@ -8,7 +8,7 @@
#include <vector>
#include <string>
#include <
magisk
.h>
#include <
logging
.h>
#include <utils.h>
#include <flags.h>
...
...
native/jni/magiskpolicy/magiskpolicy.h
View file @
ff3710de
/* magiskpolicy.h - Public API for policy patching
*/
#ifndef _MAGISKPOLICY_H
#define _MAGISKPOLICY_H
#pragma once
#include <stdlib.h>
#include <selinux.h>
#define ALL NULL
#ifdef __cplusplus
extern
"C"
{
#endif
__BEGIN_DECLS
// policydb functions
int
load_policydb
(
const
char
*
file
);
...
...
@@ -41,8 +38,4 @@ int sepol_exists(const char *source);
// Built in rules
void
sepol_magisk_rules
();
#ifdef __cplusplus
};
#endif
#endif
__END_DECLS
native/jni/magiskpolicy/rules.cpp
View file @
ff3710de
#include <magisk.h>
#include <logging.h>
#include <flags.h>
#include "magiskpolicy.h"
#include "sepolicy.h"
#include "flags.h"
static
void
allowSuClient
(
const
char
*
target
)
{
if
(
!
sepol_exists
(
target
))
...
...
native/jni/magiskpolicy/sepolicy.h
View file @
ff3710de
/* sepolicy.h - Header for magiskpolicy non-public APIs
*/
#ifndef _SEPOLICY_H
#define _SEPOLICY_H
#pragma once
#include <sepol/policydb/policydb.h>
#ifdef __cplusplus
extern
"C"
{
#endif
__BEGIN_DECLS
// Global policydb
extern
policydb_t
*
policydb
;
...
...
@@ -36,8 +33,4 @@ int add_rule(const char *s, const char *t, const char *c, const char *p, int eff
int
add_xperm_rule
(
const
char
*
s
,
const
char
*
t
,
const
char
*
c
,
const
char
*
range
,
int
effect
,
int
n
);
int
add_type_rule
(
const
char
*
s
,
const
char
*
t
,
const
char
*
c
,
const
char
*
d
,
int
effect
);
#ifdef __cplusplus
};
#endif
#endif
__END_DECLS
native/jni/resetprop/persist_properties.cpp
View file @
ff3710de
...
...
@@ -11,7 +11,7 @@
#include <pb_encode.h>
#include <utils.h>
#include "
_
resetprop.h"
#include "
private/
resetprop.h"
using
namespace
std
;
...
...
native/jni/resetprop/
_
resetprop.h
→
native/jni/resetprop/
private/
resetprop.h
View file @
ff3710de
/* resetprop.h - Internal struct definitions
*/
#ifndef MAGISK_PROPS_H
#define MAGISK_PROPS_H
#pragma once
#include <string>
#include <logging.h>
#include "
private/
system_properties.h"
#include "system_properties.h"
struct
prop_t
{
char
*
name
;
...
...
@@ -28,7 +23,7 @@ struct prop_t {
bool
operator
<
(
const
prop_t
&
prop
)
const
{
return
strcmp
(
name
,
prop
.
name
)
<
0
;
}
prop_t
&
operator
=
(
prop_t
&&
prop
)
{
prop_t
&
operator
=
(
prop_t
&&
prop
)
{
if
(
this
!=
&
prop
)
{
free
(
name
);
name
=
prop
.
name
;
...
...
@@ -60,5 +55,3 @@ std::string persist_getprop(const char *name);
void
persist_getprop
(
read_cb_t
*
read_cb
);
bool
persist_deleteprop
(
const
char
*
name
);
void
collect_props
(
const
char
*
name
,
const
char
*
value
,
void
*
v_plist
);
#endif //MAGISK_PROPS_H
native/jni/resetprop/resetprop.cpp
View file @
ff3710de
...
...
@@ -9,7 +9,7 @@
#include <vector>
#include <algorithm>
#include <
magisk
.h>
#include <
logging
.h>
#include <resetprop.h>
#include <utils.h>
#include <flags.h>
...
...
@@ -17,7 +17,7 @@
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include "private/_system_properties.h"
#include "private/system_properties.h"
#include "
_
resetprop.h"
#include "
private/
resetprop.h"
using
namespace
std
;
...
...
@@ -80,15 +80,14 @@ illegal:
static
void
read_props
(
const
prop_info
*
pi
,
void
*
read_cb
)
{
__system_property_read_callback
(
pi
,
[](
auto
cb
,
auto
name
,
auto
value
,
auto
)
->
void
{
pi
,
[](
auto
cb
,
auto
name
,
auto
value
,
auto
)
{
((
read_cb_t
*
)
cb
)
->
exec
(
name
,
value
);
},
read_cb
);
}
void
collect_props
(
const
char
*
name
,
const
char
*
value
,
void
*
v_plist
)
{
auto
&
prop_list
=
*
static_cast
<
vector
<
prop_t
>
*>
(
v_plist
);
prop_list
.
emplace_back
(
name
,
value
);
auto
prop_list
=
static_cast
<
vector
<
prop_t
>
*>
(
v_plist
);
prop_list
->
emplace_back
(
name
,
value
);
}
static
void
collect_unique_props
(
const
char
*
name
,
const
char
*
value
,
void
*
v_plist
)
{
...
...
@@ -121,15 +120,18 @@ static void print_props(bool persist) {
* Implementations of functions in resetprop.h (APIs)
* **************************************************/
#define ENSURE_INIT(ret) if (init_resetprop()) return ret
int
prop_exist
(
const
char
*
name
)
{
if
(
init_resetprop
())
return
0
;
ENSURE_INIT
(
0
)
;
return
__system_property_find
(
name
)
!=
nullptr
;
}
// Get prop by name, return string
string
getprop
(
const
char
*
name
,
bool
persist
)
{
if
(
!
check_legal_property_name
(
name
)
||
init_resetprop
()
)
if
(
!
check_legal_property_name
(
name
))
return
string
();
ENSURE_INIT
(
string
());
const
prop_info
*
pi
=
__system_property_find
(
name
);
if
(
pi
==
nullptr
)
{
if
(
persist
&&
strncmp
(
name
,
"persist."
,
8
)
==
0
)
{
...
...
@@ -151,7 +153,7 @@ string getprop(const char *name, bool persist) {
}
void
getprop
(
void
(
*
callback
)(
const
char
*
,
const
char
*
,
void
*
),
void
*
cookie
,
bool
persist
)
{
if
(
init_resetprop
())
return
;
ENSURE_INIT
()
;
read_cb_t
read_cb
(
callback
,
cookie
);
__system_property_foreach
(
read_props
,
&
read_cb
);
if
(
persist
)
{
...
...
@@ -163,8 +165,7 @@ void getprop(void (*callback)(const char *, const char *, void *), void *cookie,
int
setprop
(
const
char
*
name
,
const
char
*
value
,
bool
trigger
)
{
if
(
!
check_legal_property_name
(
name
))
return
1
;
if
(
init_resetprop
())
return
-
1
;
ENSURE_INIT
(
-
1
);
int
ret
;
...
...
@@ -197,7 +198,7 @@ int setprop(const char *name, const char *value, bool trigger) {
int
deleteprop
(
const
char
*
name
,
bool
persist
)
{
if
(
!
check_legal_property_name
(
name
))
return
1
;
if
(
init_resetprop
())
return
-
1
;
ENSURE_INIT
(
-
1
)
;
char
path
[
PATH_MAX
];
path
[
0
]
=
'\0'
;
LOGD
(
"resetprop: deleteprop [%s]
\n
"
,
name
);
...
...
@@ -207,7 +208,7 @@ int deleteprop(const char *name, bool persist) {
}
void
load_prop_file
(
const
char
*
filename
,
bool
trigger
)
{
if
(
init_resetprop
())
return
;
ENSURE_INIT
()
;
LOGD
(
"resetprop: Parse prop file [%s]
\n
"
,
filename
);
parse_prop_file
(
filename
,
[
=
](
auto
key
,
auto
val
)
->
bool
{
setprop
(
key
.
data
(),
val
.
data
(),
trigger
);
...
...
native/jni/su/connect.cpp
View file @
ff3710de
...
...
@@ -5,7 +5,6 @@
#include <fcntl.h>
#include <stdio.h>
#include <magisk.h>
#include <daemon.h>
#include <utils.h>
...
...
native/jni/su/pts.cpp
View file @
ff3710de
...
...
@@ -17,7 +17,7 @@
#include <errno.h>
#include <pthread.h>
#include <
magisk
.h>
#include <
logging
.h>
#include "pts.h"
...
...
native/jni/su/su.cpp
View file @
ff3710de
...
...
@@ -21,7 +21,6 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <magisk.h>
#include <daemon.h>
#include <utils.h>
#include <flags.h>
...
...
@@ -82,7 +81,7 @@ static void sighandler(int sig) {
memset
(
&
act
,
0
,
sizeof
(
act
));
act
.
sa_handler
=
SIG_DFL
;
for
(
int
i
=
0
;
quit_signals
[
i
];
++
i
)
{
sigaction
(
quit_signals
[
i
],
&
act
,
NULL
);
sigaction
(
quit_signals
[
i
],
&
act
,
nullptr
);
}
}
...
...
@@ -91,7 +90,7 @@ static void setup_sighandlers(void (*handler)(int)) {
memset
(
&
act
,
0
,
sizeof
(
act
));
act
.
sa_handler
=
handler
;
for
(
int
i
=
0
;
quit_signals
[
i
];
++
i
)
{
sigaction
(
quit_signals
[
i
],
&
act
,
NULL
);
sigaction
(
quit_signals
[
i
],
&
act
,
nullptr
);
}
}
...
...
@@ -107,15 +106,15 @@ su_request::su_request()
int
su_client_main
(
int
argc
,
char
*
argv
[])
{
int
c
;
struct
option
long_opts
[]
=
{
{
"command"
,
required_argument
,
NULL
,
'c'
},
{
"help"
,
no_argument
,
NULL
,
'h'
},
{
"login"
,
no_argument
,
NULL
,
'l'
},
{
"preserve-environment"
,
no_argument
,
NULL
,
'p'
},
{
"shell"
,
required_argument
,
NULL
,
's'
},
{
"version"
,
no_argument
,
NULL
,
'v'
},
{
"context"
,
required_argument
,
NULL
,
'z'
},
{
"mount-master"
,
no_argument
,
NULL
,
'M'
},
{
NULL
,
0
,
NULL
,
0
},
{
"command"
,
required_argument
,
nullptr
,
'c'
},
{
"help"
,
no_argument
,
nullptr
,
'h'
},
{
"login"
,
no_argument
,
nullptr
,
'l'
},
{
"preserve-environment"
,
no_argument
,
nullptr
,
'p'
},
{
"shell"
,
required_argument
,
nullptr
,
's'
},
{
"version"
,
no_argument
,
nullptr
,
'v'
},
{
"context"
,
required_argument
,
nullptr
,
'z'
},
{
"mount-master"
,
no_argument
,
nullptr
,
'M'
},
{
nullptr
,
0
,
nullptr
,
0
},
};
su_request
su_req
;
...
...
@@ -128,7 +127,7 @@ int su_client_main(int argc, char *argv[]) {
strcpy
(
argv
[
i
],
"-M"
);
}
while
((
c
=
getopt_long
(
argc
,
argv
,
"c:hlmps:Vvuz:M"
,
long_opts
,
NULL
))
!=
-
1
)
{
while
((
c
=
getopt_long
(
argc
,
argv
,
"c:hlmps:Vvuz:M"
,
long_opts
,
nullptr
))
!=
-
1
)
{
switch
(
c
)
{
case
'c'
:
su_req
.
command
=
concat_commands
(
argc
,
argv
);
...
...
native/jni/su/su.h
View file @
ff3710de
...
...
@@ -8,7 +8,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include
"db.h"
#include
<db.h>
#define DEFAULT_SHELL "/system/bin/sh"
...
...
native/jni/su/su_daemon.cpp
View file @
ff3710de
...
...
@@ -12,7 +12,7 @@
#include <sys/wait.h>
#include <sys/mount.h>
#include <
magisk
.h>
#include <
logging
.h>
#include <daemon.h>
#include <utils.h>
#include <selinux.h>
...
...
native/jni/utils/file.cpp
View file @
ff3710de
...
...
@@ -11,7 +11,6 @@
#include <string.h>
#include <libgen.h>
#include <magisk.h>
#include <utils.h>
#include <selinux.h>
...
...
native/jni/utils/include/selinux.h
View file @
ff3710de
...
...
@@ -18,9 +18,7 @@
#define SEPOL_PROC_DOMAIN "magisk"
#define SEPOL_FILE_DOMAIN "magisk_file"
#ifdef __cplusplus
extern
"C"
{
#endif
__BEGIN_DECLS
extern
void
(
*
freecon
)(
char
*
con
);
extern
int
(
*
setcon
)(
const
char
*
con
);
...
...
@@ -38,6 +36,4 @@ void dload_selinux();
void
restorecon
();
void
restore_rootcon
();
#ifdef __cplusplus
}
#endif
__END_DECLS
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