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
f339a087
Commit
f339a087
authored
Jul 13, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let Magisk compile against SDK 16
parent
1affb91f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
710 additions
and
145 deletions
+710
-145
build.py
build.py
+10
-10
Application.mk
native/jni/Application.mk
+4
-4
magiskinit.c
native/jni/core/magiskinit.c
+4
-3
utils.h
native/jni/include/utils.h
+5
-0
bootimg.h
native/jni/magiskboot/bootimg.h
+3
-3
dtb.c
native/jni/magiskboot/dtb.c
+1
-1
hide_utils.c
native/jni/magiskhide/hide_utils.c
+1
-0
proc_monitor.c
native/jni/magiskhide/proc_monitor.c
+1
-0
ErrnoRestorer.h
native/jni/resetprop/ErrnoRestorer.h
+0
-43
bionic_futex.h
native/jni/resetprop/private/bionic_futex.h
+2
-2
bionic_lock.h
native/jni/resetprop/private/bionic_lock.h
+1
-1
bionic_macros.h
native/jni/resetprop/private/bionic_macros.h
+0
-0
futex.h
native/jni/resetprop/private/futex.h
+77
-0
stdatomic.h
native/jni/resetprop/private/stdatomic.h
+370
-0
xattr.h
native/jni/resetprop/private/xattr.h
+61
-0
system_properties.cpp
native/jni/resetprop/system_properties.cpp
+83
-74
su
native/jni/su
+1
-1
misc.c
native/jni/utils/misc.c
+78
-3
xwrap.c
native/jni/utils/xwrap.c
+8
-0
No files found.
build.py
View file @
f339a087
...
@@ -119,12 +119,12 @@ def build_binary(args):
...
@@ -119,12 +119,12 @@ def build_binary(args):
error
(
'Build Magisk binary failed!'
)
error
(
'Build Magisk binary failed!'
)
collect_binary
()
collect_binary
()
old_plat
form
=
False
old_plat
=
False
flags
=
base_flags
flags
=
base_flags
if
'b64xz'
in
targets
:
if
'b64xz'
in
targets
:
flags
+=
' B_BXZ=1'
flags
+=
' B_BXZ=1'
old_plat
form
=
True
old_plat
=
True
if
'magiskinit'
in
targets
:
if
'magiskinit'
in
targets
:
for
arch
in
archs
:
for
arch
in
archs
:
...
@@ -144,27 +144,27 @@ def build_binary(args):
...
@@ -144,27 +144,27 @@ def build_binary(args):
xz_dump
(
src
,
out
,
'manager_xz'
)
xz_dump
(
src
,
out
,
'manager_xz'
)
flags
+=
' B_INIT=1'
flags
+=
' B_INIT=1'
old_plat
form
=
True
old_plat
=
True
if
'magiskboot'
in
targets
:
if
'magiskboot'
in
targets
:
flags
+=
' B_BOOT=1'
flags
+=
' B_BOOT=1'
old_plat
form
=
True
old_plat
=
True
if
old_plat
form
:
if
old_plat
:
proc
=
subprocess
.
run
(
'{} -C native
OLD_PLAT=1
{} -j{}'
.
format
(
ndk_build
,
flags
,
cpu_count
),
shell
=
True
,
stdout
=
STDOUT
)
proc
=
subprocess
.
run
(
'{} -C native {} -j{}'
.
format
(
ndk_build
,
flags
,
cpu_count
),
shell
=
True
,
stdout
=
STDOUT
)
if
proc
.
returncode
!=
0
:
if
proc
.
returncode
!=
0
:
error
(
'Build binaries failed!'
)
error
(
'Build binaries failed!'
)
collect_binary
()
collect_binary
()
other
=
False
new_plat
=
False
flags
=
base_flags
flags
=
base_flags
if
'busybox'
in
targets
:
if
'busybox'
in
targets
:
flags
+=
' B_BB=1'
flags
+=
' B_BB=1'
other
=
True
new_plat
=
True
if
other
:
if
new_plat
:
proc
=
subprocess
.
run
(
'{} -C native {} -j{}'
.
format
(
ndk_build
,
flags
,
cpu_count
),
shell
=
True
,
stdout
=
STDOUT
)
proc
=
subprocess
.
run
(
'{} -C native
NEW_PLAT=1
{} -j{}'
.
format
(
ndk_build
,
flags
,
cpu_count
),
shell
=
True
,
stdout
=
STDOUT
)
if
proc
.
returncode
!=
0
:
if
proc
.
returncode
!=
0
:
error
(
'Build binaries failed!'
)
error
(
'Build binaries failed!'
)
collect_binary
()
collect_binary
()
...
...
native/jni/Application.mk
View file @
f339a087
APP_ABI :=
x86 armeabi-v7a
APP_ABI :=
armeabi-v7a x86
APP_CFLAGS := -std=gnu99 ${MAGISK_DEBUG} \
APP_CFLAGS := -std=gnu99 ${MAGISK_DEBUG} \
-DMAGISK_VERSION="${MAGISK_VERSION}" -DMAGISK_VER_CODE=${MAGISK_VER_CODE}
-DMAGISK_VERSION="${MAGISK_VERSION}" -DMAGISK_VER_CODE=${MAGISK_VER_CODE}
APP_CPPFLAGS := -std=c++11
APP_CPPFLAGS := -std=c++11
APP_SHORT_COMMANDS := true
APP_SHORT_COMMANDS := true
ifdef OLD_PLAT
ifdef NEW_PLAT
APP_PLATFORM := android-21
else
APP_PLATFORM := android-16
APP_PLATFORM := android-16
APP_CFLAGS += -Wno-implicit-function-declaration
APP_CFLAGS += -Wno-implicit-function-declaration
else
APP_PLATFORM := android-21
endif
endif
native/jni/core/magiskinit.c
View file @
f339a087
...
@@ -76,12 +76,11 @@ static void parse_cmdline(struct cmdline *cmd) {
...
@@ -76,12 +76,11 @@ static void parse_cmdline(struct cmdline *cmd) {
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
memset
(
cmd
,
0
,
sizeof
(
*
cmd
));
char
cmdline
[
4096
];
char
cmdline
[
4096
];
mkdir
(
"/proc"
,
0
5
55
);
mkdir
(
"/proc"
,
0
7
55
);
xmount
(
"proc"
,
"/proc"
,
"proc"
,
0
,
NULL
);
xmount
(
"proc"
,
"/proc"
,
"proc"
,
0
,
NULL
);
int
fd
=
open
(
"/proc/cmdline"
,
O_RDONLY
|
O_CLOEXEC
);
int
fd
=
open
(
"/proc/cmdline"
,
O_RDONLY
|
O_CLOEXEC
);
cmdline
[
read
(
fd
,
cmdline
,
sizeof
(
cmdline
))]
=
'\0'
;
cmdline
[
read
(
fd
,
cmdline
,
sizeof
(
cmdline
))]
=
'\0'
;
close
(
fd
);
close
(
fd
);
umount
(
"/proc"
);
for
(
char
*
tok
=
strtok
(
cmdline
,
" "
);
tok
;
tok
=
strtok
(
NULL
,
" "
))
{
for
(
char
*
tok
=
strtok
(
cmdline
,
" "
);
tok
;
tok
=
strtok
(
NULL
,
" "
))
{
if
(
strncmp
(
tok
,
"androidboot.slot_suffix"
,
23
)
==
0
)
{
if
(
strncmp
(
tok
,
"androidboot.slot_suffix"
,
23
)
==
0
)
{
sscanf
(
tok
,
"androidboot.slot_suffix=%s"
,
cmd
->
slot
);
sscanf
(
tok
,
"androidboot.slot_suffix=%s"
,
cmd
->
slot
);
...
@@ -402,7 +401,7 @@ int main(int argc, char *argv[]) {
...
@@ -402,7 +401,7 @@ int main(int argc, char *argv[]) {
if
(
cmd
.
skip_initramfs
)
{
if
(
cmd
.
skip_initramfs
)
{
// Clear rootfs
// Clear rootfs
excl_list
=
(
char
*
[])
{
"overlay"
,
".backup"
,
"init.bak"
,
NULL
};
excl_list
=
(
char
*
[])
{
"overlay"
,
".backup"
,
"
proc"
,
"
init.bak"
,
NULL
};
frm_rf
(
root
);
frm_rf
(
root
);
}
else
if
(
access
(
"/ramdisk.cpio.xz"
,
R_OK
)
==
0
)
{
}
else
if
(
access
(
"/ramdisk.cpio.xz"
,
R_OK
)
==
0
)
{
// High compression mode
// High compression mode
...
@@ -499,6 +498,8 @@ int main(int argc, char *argv[]) {
...
@@ -499,6 +498,8 @@ int main(int argc, char *argv[]) {
// Clean up
// Clean up
close
(
root
);
close
(
root
);
umount
(
"/proc"
);
umount
(
"/sys"
);
if
(
mounted_system
)
if
(
mounted_system
)
umount
(
"/system"
);
umount
(
"/system"
);
if
(
mounted_vendor
)
if
(
mounted_vendor
)
...
...
native/jni/include/utils.h
View file @
f339a087
...
@@ -38,6 +38,7 @@ ssize_t xread(int fd, void *buf, size_t count);
...
@@ -38,6 +38,7 @@ ssize_t xread(int fd, void *buf, size_t count);
ssize_t
xxread
(
int
fd
,
void
*
buf
,
size_t
count
);
ssize_t
xxread
(
int
fd
,
void
*
buf
,
size_t
count
);
int
xpipe2
(
int
pipefd
[
2
],
int
flags
);
int
xpipe2
(
int
pipefd
[
2
],
int
flags
);
int
xsetns
(
int
fd
,
int
nstype
);
int
xsetns
(
int
fd
,
int
nstype
);
int
xunshare
(
int
flags
);
DIR
*
xopendir
(
const
char
*
name
);
DIR
*
xopendir
(
const
char
*
name
);
DIR
*
xfdopendir
(
int
fd
);
DIR
*
xfdopendir
(
int
fd
);
struct
dirent
*
xreaddir
(
DIR
*
dirp
);
struct
dirent
*
xreaddir
(
DIR
*
dirp
);
...
@@ -81,6 +82,8 @@ pid_t xfork();
...
@@ -81,6 +82,8 @@ pid_t xfork();
// misc.c
// misc.c
#define quit_signals ((int []) { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 })
#define quit_signals ((int []) { SIGALRM, SIGABRT, SIGHUP, SIGPIPE, SIGQUIT, SIGTERM, SIGINT, 0 })
#define getline my_getline
#define getdelim my_getdelim
unsigned
get_shell_uid
();
unsigned
get_shell_uid
();
unsigned
get_system_uid
();
unsigned
get_system_uid
();
...
@@ -89,6 +92,8 @@ int check_data();
...
@@ -89,6 +92,8 @@ int check_data();
int
file_to_vector
(
const
char
*
filename
,
struct
vector
*
v
);
int
file_to_vector
(
const
char
*
filename
,
struct
vector
*
v
);
int
vector_to_file
(
const
char
*
filename
,
struct
vector
*
v
);
int
vector_to_file
(
const
char
*
filename
,
struct
vector
*
v
);
ssize_t
fdgets
(
char
*
buf
,
size_t
size
,
int
fd
);
ssize_t
fdgets
(
char
*
buf
,
size_t
size
,
int
fd
);
ssize_t
my_getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
);
ssize_t
my_getdelim
(
char
**
lineptr
,
size_t
*
n
,
int
delim
,
FILE
*
stream
);
void
ps
(
void
(
*
func
)(
int
));
void
ps
(
void
(
*
func
)(
int
));
void
ps_filter_proc_name
(
const
char
*
filter
,
void
(
*
func
)(
int
));
void
ps_filter_proc_name
(
const
char
*
filter
,
void
(
*
func
)(
int
));
void
unlock_blocks
();
void
unlock_blocks
();
...
...
native/jni/magiskboot/bootimg.h
View file @
f339a087
...
@@ -100,7 +100,7 @@ typedef struct mtk_hdr {
...
@@ -100,7 +100,7 @@ typedef struct mtk_hdr {
typedef
struct
dhtb_hdr
{
typedef
struct
dhtb_hdr
{
char
magic
[
8
];
/* DHTB magic */
char
magic
[
8
];
/* DHTB magic */
char
checksum
[
40
];
/* Payload SHA256, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
uint8_t
checksum
[
40
];
/* Payload SHA256, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
uint32_t
size
;
/* Payload size, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
uint32_t
size
;
/* Payload size, whole image + SEANDROIDENFORCE + 0xFFFFFFFF */
}
__attribute__
((
packed
))
dhtb_hdr
;
}
__attribute__
((
packed
))
dhtb_hdr
;
...
...
native/jni/magiskboot/dtb.c
View file @
f339a087
...
@@ -78,7 +78,7 @@ static void dtb_patch(const char *file, int patch) {
...
@@ -78,7 +78,7 @@ static void dtb_patch(const char *file, int patch) {
fdt_for_each_subnode
(
block
,
fdt
,
fstab
)
{
fdt_for_each_subnode
(
block
,
fdt
,
fstab
)
{
fprintf
(
stderr
,
"Found block [%s] in fstab
\n
"
,
fdt_get_name
(
fdt
,
block
,
NULL
));
fprintf
(
stderr
,
"Found block [%s] in fstab
\n
"
,
fdt_get_name
(
fdt
,
block
,
NULL
));
uint32_t
value_size
;
uint32_t
value_size
;
void
*
value
=
(
void
*
)
fdt_getprop
(
fdt
,
block
,
"fsmgr_flags"
,
&
value_size
);
void
*
value
=
(
void
*
)
fdt_getprop
(
fdt
,
block
,
"fsmgr_flags"
,
(
int
*
)
&
value_size
);
if
(
patch
)
{
if
(
patch
)
{
void
*
dup
=
xmalloc
(
value_size
);
void
*
dup
=
xmalloc
(
value_size
);
memcpy
(
dup
,
value
,
value_size
);
memcpy
(
dup
,
value
,
value_size
);
...
...
native/jni/magiskhide/hide_utils.c
View file @
f339a087
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <unistd.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <dirent.h>
#include <string.h>
#include <string.h>
#include <sys/types.h>
#include <sys/types.h>
...
...
native/jni/magiskhide/proc_monitor.c
View file @
f339a087
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <unistd.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <signal.h>
#include <pthread.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/types.h>
...
...
native/jni/resetprop/ErrnoRestorer.h
deleted
100644 → 0
View file @
1affb91f
/*
* Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ERRNO_RESTORER_H
#define ERRNO_RESTORER_H
#include <errno.h>
#include "bionic_macros.h"
class
ErrnoRestorer
{
public
:
explicit
ErrnoRestorer
()
:
saved_errno_
(
errno
)
{
}
~
ErrnoRestorer
()
{
errno
=
saved_errno_
;
}
void
override
(
int
new_errno
)
{
saved_errno_
=
new_errno
;
}
private
:
int
saved_errno_
;
DISALLOW_COPY_AND_ASSIGN
(
ErrnoRestorer
);
};
#endif // ERRNO_RESTORER_H
native/jni/resetprop/bionic_futex.h
→
native/jni/resetprop/
private/
bionic_futex.h
View file @
f339a087
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
#define _BIONIC_FUTEX_H
#define _BIONIC_FUTEX_H
#include <errno.h>
#include <errno.h>
#include
<linux/futex.h>
#include
"futex.h"
#include <stdbool.h>
#include <stdbool.h>
#include <stddef.h>
#include <stddef.h>
#include <sys/cdefs.h>
#include <sys/cdefs.h>
...
@@ -40,7 +40,7 @@ __BEGIN_DECLS
...
@@ -40,7 +40,7 @@ __BEGIN_DECLS
struct
timespec
;
struct
timespec
;
static
inline
__always_inline
int
__futex
(
volatile
void
*
ftx
,
int
op
,
int
value
,
static
inline
int
__futex
(
volatile
void
*
ftx
,
int
op
,
int
value
,
const
struct
timespec
*
timeout
,
const
struct
timespec
*
timeout
,
int
bitset
)
{
int
bitset
)
{
// Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to.
// Our generated syscall assembler sets errno, but our callers (pthread functions) don't want to.
...
...
native/jni/resetprop/bionic_lock.h
→
native/jni/resetprop/
private/
bionic_lock.h
View file @
f339a087
...
@@ -28,7 +28,7 @@
...
@@ -28,7 +28,7 @@
#ifndef _BIONIC_LOCK_H
#ifndef _BIONIC_LOCK_H
#define _BIONIC_LOCK_H
#define _BIONIC_LOCK_H
#include
<stdatomic.h>
#include
"stdatomic.h"
#include "bionic_futex.h"
#include "bionic_futex.h"
#include "bionic_macros.h"
#include "bionic_macros.h"
...
...
native/jni/resetprop/bionic_macros.h
→
native/jni/resetprop/
private/
bionic_macros.h
View file @
f339a087
File moved
native/jni/resetprop/private/futex.h
0 → 100644
View file @
f339a087
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
*** To edit the content of this header, modify the corresponding
*** source file (e.g. under external/kernel-headers/original/) then
*** run bionic/libc/kernel/tools/update_all.py
***
*** Any manual change here will be lost the next time this script will
*** be run. You've been warned!
***
****************************************************************************
****************************************************************************/
#ifndef _UAPI_LINUX_FUTEX_H
#define _UAPI_LINUX_FUTEX_H
#include <linux/compiler.h>
#include <linux/types.h>
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
#define FUTEX_FD 2
#define FUTEX_REQUEUE 3
#define FUTEX_CMP_REQUEUE 4
#define FUTEX_WAKE_OP 5
#define FUTEX_LOCK_PI 6
#define FUTEX_UNLOCK_PI 7
#define FUTEX_TRYLOCK_PI 8
#define FUTEX_WAIT_BITSET 9
#define FUTEX_WAKE_BITSET 10
#define FUTEX_WAIT_REQUEUE_PI 11
#define FUTEX_CMP_REQUEUE_PI 12
#define FUTEX_PRIVATE_FLAG 128
#define FUTEX_CLOCK_REALTIME 256
#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
#define FUTEX_REQUEUE_PRIVATE (FUTEX_REQUEUE | FUTEX_PRIVATE_FLAG)
#define FUTEX_CMP_REQUEUE_PRIVATE (FUTEX_CMP_REQUEUE | FUTEX_PRIVATE_FLAG)
#define FUTEX_WAKE_OP_PRIVATE (FUTEX_WAKE_OP | FUTEX_PRIVATE_FLAG)
#define FUTEX_LOCK_PI_PRIVATE (FUTEX_LOCK_PI | FUTEX_PRIVATE_FLAG)
#define FUTEX_UNLOCK_PI_PRIVATE (FUTEX_UNLOCK_PI | FUTEX_PRIVATE_FLAG)
#define FUTEX_TRYLOCK_PI_PRIVATE (FUTEX_TRYLOCK_PI | FUTEX_PRIVATE_FLAG)
#define FUTEX_WAIT_BITSET_PRIVATE (FUTEX_WAIT_BITSET | FUTEX_PRIVATE_FLAG)
#define FUTEX_WAKE_BITSET_PRIVATE (FUTEX_WAKE_BITSET | FUTEX_PRIVATE_FLAG)
#define FUTEX_WAIT_REQUEUE_PI_PRIVATE (FUTEX_WAIT_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
#define FUTEX_CMP_REQUEUE_PI_PRIVATE (FUTEX_CMP_REQUEUE_PI | FUTEX_PRIVATE_FLAG)
struct
robust_list
{
struct
robust_list
__user
*
next
;
};
struct
robust_list_head
{
struct
robust_list
list
;
long
futex_offset
;
struct
robust_list
__user
*
list_op_pending
;
};
#define FUTEX_WAITERS 0x80000000
#define FUTEX_OWNER_DIED 0x40000000
#define FUTEX_TID_MASK 0x3fffffff
#define ROBUST_LIST_LIMIT 2048
#define FUTEX_BITSET_MATCH_ANY 0xffffffff
#define FUTEX_OP_SET 0
#define FUTEX_OP_ADD 1
#define FUTEX_OP_OR 2
#define FUTEX_OP_ANDN 3
#define FUTEX_OP_XOR 4
#define FUTEX_OP_OPARG_SHIFT 8
#define FUTEX_OP_CMP_EQ 0
#define FUTEX_OP_CMP_NE 1
#define FUTEX_OP_CMP_LT 2
#define FUTEX_OP_CMP_LE 3
#define FUTEX_OP_CMP_GT 4
#define FUTEX_OP_CMP_GE 5
#define FUTEX_OP(op,oparg,cmp,cmparg) (((op & 0xf) << 28) | ((cmp & 0xf) << 24) | ((oparg & 0xfff) << 12) | (cmparg & 0xfff))
#endif
native/jni/resetprop/private/stdatomic.h
0 → 100644
View file @
f339a087
This diff is collapsed.
Click to expand it.
native/jni/resetprop/private/xattr.h
0 → 100644
View file @
f339a087
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
*** To edit the content of this header, modify the corresponding
*** source file (e.g. under external/kernel-headers/original/) then
*** run bionic/libc/kernel/tools/update_all.py
***
*** Any manual change here will be lost the next time this script will
*** be run. You've been warned!
***
****************************************************************************
****************************************************************************/
#ifndef _UAPI_LINUX_XATTR_H
#define _UAPI_LINUX_XATTR_H
#define XATTR_OS2_PREFIX "os2."
#define XATTR_OS2_PREFIX_LEN (sizeof(XATTR_OS2_PREFIX) - 1)
#define XATTR_MAC_OSX_PREFIX "osx."
#define XATTR_MAC_OSX_PREFIX_LEN (sizeof(XATTR_MAC_OSX_PREFIX) - 1)
#define XATTR_BTRFS_PREFIX "btrfs."
#define XATTR_BTRFS_PREFIX_LEN (sizeof(XATTR_BTRFS_PREFIX) - 1)
#define XATTR_SECURITY_PREFIX "security."
#define XATTR_SECURITY_PREFIX_LEN (sizeof(XATTR_SECURITY_PREFIX) - 1)
#define XATTR_SYSTEM_PREFIX "system."
#define XATTR_SYSTEM_PREFIX_LEN (sizeof(XATTR_SYSTEM_PREFIX) - 1)
#define XATTR_TRUSTED_PREFIX "trusted."
#define XATTR_TRUSTED_PREFIX_LEN (sizeof(XATTR_TRUSTED_PREFIX) - 1)
#define XATTR_USER_PREFIX "user."
#define XATTR_USER_PREFIX_LEN (sizeof(XATTR_USER_PREFIX) - 1)
#define XATTR_EVM_SUFFIX "evm"
#define XATTR_NAME_EVM XATTR_SECURITY_PREFIX XATTR_EVM_SUFFIX
#define XATTR_IMA_SUFFIX "ima"
#define XATTR_NAME_IMA XATTR_SECURITY_PREFIX XATTR_IMA_SUFFIX
#define XATTR_SELINUX_SUFFIX "selinux"
#define XATTR_NAME_SELINUX XATTR_SECURITY_PREFIX XATTR_SELINUX_SUFFIX
#define XATTR_SMACK_SUFFIX "SMACK64"
#define XATTR_SMACK_IPIN "SMACK64IPIN"
#define XATTR_SMACK_IPOUT "SMACK64IPOUT"
#define XATTR_SMACK_EXEC "SMACK64EXEC"
#define XATTR_SMACK_TRANSMUTE "SMACK64TRANSMUTE"
#define XATTR_SMACK_MMAP "SMACK64MMAP"
#define XATTR_NAME_SMACK XATTR_SECURITY_PREFIX XATTR_SMACK_SUFFIX
#define XATTR_NAME_SMACKIPIN XATTR_SECURITY_PREFIX XATTR_SMACK_IPIN
#define XATTR_NAME_SMACKIPOUT XATTR_SECURITY_PREFIX XATTR_SMACK_IPOUT
#define XATTR_NAME_SMACKEXEC XATTR_SECURITY_PREFIX XATTR_SMACK_EXEC
#define XATTR_NAME_SMACKTRANSMUTE XATTR_SECURITY_PREFIX XATTR_SMACK_TRANSMUTE
#define XATTR_NAME_SMACKMMAP XATTR_SECURITY_PREFIX XATTR_SMACK_MMAP
#define XATTR_APPARMOR_SUFFIX "apparmor"
#define XATTR_NAME_APPARMOR XATTR_SECURITY_PREFIX XATTR_APPARMOR_SUFFIX
#define XATTR_CAPS_SUFFIX "capability"
#define XATTR_NAME_CAPS XATTR_SECURITY_PREFIX XATTR_CAPS_SUFFIX
#define XATTR_POSIX_ACL_ACCESS "posix_acl_access"
#define XATTR_NAME_POSIX_ACL_ACCESS XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_ACCESS
#define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
#define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
#endif
native/jni/resetprop/system_properties.cpp
View file @
f339a087
This diff is collapsed.
Click to expand it.
su
@
00129431
Subproject commit
69b226b005e3f87c4c872fa3382e05006969118e
Subproject commit
001294317f7d8b3e209567005edd25df0dc6e3c6
native/jni/utils/misc.c
View file @
f339a087
...
@@ -85,6 +85,80 @@ int check_data() {
...
@@ -85,6 +85,80 @@ int check_data() {
return
data
;
return
data
;
}
}
/* Original source: https://opensource.apple.com/source/cvs/cvs-19/cvs/lib/getline.c
* License: GPL 2 or later
* Adjusted to match POSIX */
#define MIN_CHUNK 64
ssize_t
my_getdelim
(
char
**
lineptr
,
size_t
*
n
,
int
delim
,
FILE
*
stream
)
{
size_t
nchars_avail
;
char
*
read_pos
;
if
(
!
lineptr
||
!
n
||
!
stream
)
{
errno
=
EINVAL
;
return
-
1
;
}
if
(
!*
lineptr
)
{
*
n
=
MIN_CHUNK
;
*
lineptr
=
malloc
(
*
n
);
if
(
!*
lineptr
)
{
errno
=
ENOMEM
;
return
-
1
;
}
}
nchars_avail
=
*
n
;
read_pos
=
*
lineptr
;
while
(
1
)
{
int
save_errno
;
register
int
c
=
getc
(
stream
);
save_errno
=
errno
;
if
(
nchars_avail
<
2
)
{
if
(
*
n
>
MIN_CHUNK
)
*
n
*=
2
;
else
*
n
+=
MIN_CHUNK
;
nchars_avail
=
*
n
+
*
lineptr
-
read_pos
;
*
lineptr
=
realloc
(
*
lineptr
,
*
n
);
if
(
!*
lineptr
)
{
errno
=
ENOMEM
;
return
-
1
;
}
read_pos
=
*
n
-
nchars_avail
+
*
lineptr
;
}
if
(
ferror
(
stream
))
{
errno
=
save_errno
;
return
-
1
;
}
if
(
c
==
EOF
)
{
if
(
read_pos
==
*
lineptr
)
return
-
1
;
else
break
;
}
*
read_pos
++
=
c
;
nchars_avail
--
;
if
(
c
==
delim
)
break
;
}
*
read_pos
=
'\0'
;
return
read_pos
-
*
lineptr
;
}
ssize_t
my_getline
(
char
**
lineptr
,
size_t
*
n
,
FILE
*
stream
)
{
return
my_getdelim
(
lineptr
,
n
,
'\n'
,
stream
);
}
/* All the string should be freed manually!! */
/* All the string should be freed manually!! */
int
file_to_vector
(
const
char
*
filename
,
struct
vector
*
v
)
{
int
file_to_vector
(
const
char
*
filename
,
struct
vector
*
v
)
{
if
(
access
(
filename
,
R_OK
)
!=
0
)
if
(
access
(
filename
,
R_OK
)
!=
0
)
...
@@ -261,7 +335,7 @@ int exec_array(int err, int *fd, void (*setenv)(struct vector *), char *const *a
...
@@ -261,7 +335,7 @@ int exec_array(int err, int *fd, void (*setenv)(struct vector *), char *const *a
}
}
// Setup environment
// Setup environment
char
*
const
*
envp
;
char
**
envp
;
struct
vector
env
;
struct
vector
env
;
vec_init
(
&
env
);
vec_init
(
&
env
);
if
(
setenv
)
{
if
(
setenv
)
{
...
@@ -289,8 +363,9 @@ int exec_array(int err, int *fd, void (*setenv)(struct vector *), char *const *a
...
@@ -289,8 +363,9 @@ int exec_array(int err, int *fd, void (*setenv)(struct vector *), char *const *a
xdup2
(
writeEnd
,
STDERR_FILENO
);
xdup2
(
writeEnd
,
STDERR_FILENO
);
}
}
execvpe
(
argv
[
0
],
argv
,
envp
);
environ
=
envp
;
PLOGE
(
"execvpe %s"
,
argv
[
0
]);
execvp
(
argv
[
0
],
argv
);
PLOGE
(
"execvp %s"
,
argv
[
0
]);
return
-
1
;
return
-
1
;
}
}
...
...
native/jni/utils/xwrap.c
View file @
f339a087
...
@@ -108,6 +108,14 @@ int xsetns(int fd, int nstype) {
...
@@ -108,6 +108,14 @@ int xsetns(int fd, int nstype) {
return
ret
;
return
ret
;
}
}
int
xunshare
(
int
flags
)
{
int
ret
=
(
int
)
syscall
(
__NR_unshare
,
flags
);
if
(
ret
==
-
1
)
{
PLOGE
(
"unshare"
);
}
return
ret
;
}
DIR
*
xopendir
(
const
char
*
name
)
{
DIR
*
xopendir
(
const
char
*
name
)
{
DIR
*
d
=
opendir
(
name
);
DIR
*
d
=
opendir
(
name
);
if
(
d
==
NULL
)
{
if
(
d
==
NULL
)
{
...
...
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