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
17d3a87b
Commit
17d3a87b
authored
May 30, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent resetprop function signature duplicate with libc
parent
14c5c608
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
156 additions
and
932 deletions
+156
-932
Android.mk
jni/Android.mk
+0
-1
bootstages.c
jni/daemon/bootstages.c
+3
-0
_system_properties.h
jni/resetprop/_system_properties.h
+20
-20
libc_logging.cpp
jni/resetprop/libc_logging.cpp
+0
-659
libc_logging.h
jni/resetprop/libc_logging.h
+0
-115
resetprop.cpp
jni/resetprop/resetprop.cpp
+10
-8
system_properties.cpp
jni/resetprop/system_properties.cpp
+108
-114
system_properties.h
jni/resetprop/system_properties.h
+15
-15
No files found.
jni/Android.mk
View file @
17d3a87b
...
@@ -34,7 +34,6 @@ LOCAL_SRC_FILES := \
...
@@ -34,7 +34,6 @@ LOCAL_SRC_FILES := \
magiskpolicy/sepolicy.c \
magiskpolicy/sepolicy.c \
magiskpolicy/api.c \
magiskpolicy/api.c \
resetprop/resetprop.cpp \
resetprop/resetprop.cpp \
resetprop/libc_logging.cpp \
resetprop/system_properties.cpp \
resetprop/system_properties.cpp \
su/su.c \
su/su.c \
su/activity.c \
su/activity.c \
...
...
jni/daemon/bootstages.c
View file @
17d3a87b
...
@@ -693,6 +693,9 @@ void post_fs_data(int client) {
...
@@ -693,6 +693,9 @@ void post_fs_data(int client) {
bind_mount
(
HOSTSFILE
,
"/system/etc/hosts"
);
bind_mount
(
HOSTSFILE
,
"/system/etc/hosts"
);
}
}
// Initialize resetprop for the daemon
init_resetprop
();
// Start magiskhide if enabled
// Start magiskhide if enabled
char
*
hide_prop
=
getprop
(
MAGISKHIDE_PROP
);
char
*
hide_prop
=
getprop
(
MAGISKHIDE_PROP
);
if
(
hide_prop
)
{
if
(
hide_prop
)
{
...
...
jni/resetprop/_system_properties.h
View file @
17d3a87b
...
@@ -62,38 +62,38 @@ __BEGIN_DECLS
...
@@ -62,38 +62,38 @@ __BEGIN_DECLS
** Map the property area from the specified filename. This
** Map the property area from the specified filename. This
** method is for testing only.
** method is for testing only.
*/
*/
int
__system_property_set_filename
(
const
char
*
filename
);
int
__system_property_set_filename
2
(
const
char
*
filename
);
/*
/*
** Initialize the area to be used to store properties. Can
** Initialize the area to be used to store properties. Can
** only be done by a single process that has write access to
** only be done by a single process that has write access to
** the property area.
** the property area.
*/
*/
int
__system_property_area_init
();
int
__system_property_area_init
2
();
/* Read the global serial number of the system properties
/* Read the global serial number of the system properties
**
**
** Called to predict if a series of cached __system_property_find
** Called to predict if a series of cached __system_property_find
2
** objects will have seen __system_property_serial values change.
** objects will have seen __system_property_serial
2
values change.
** But also aids the converse, as changes in the global serial can
** But also aids the converse, as changes in the global serial can
** also be used to predict if a failed __system_property_find
** also be used to predict if a failed __system_property_find
2
** could in-turn now find a new object; thus preventing the
** could in-turn now find a new object; thus preventing the
** cycles of effort to poll __system_property_find.
** cycles of effort to poll __system_property_find
2
.
**
**
** Typically called at beginning of a cache cycle to signal if _any_ possible
** Typically called at beginning of a cache cycle to signal if _any_ possible
** changes have occurred since last. If there is, one may check each individual
** changes have occurred since last. If there is, one may check each individual
** __system_property_serial
to confirm dirty, or __system_property_find
** __system_property_serial
2 to confirm dirty, or __system_property_find2
** to check if the property now exists. If a call to __system_property_add
** to check if the property now exists. If a call to __system_property_add
2
** or __system_property_update has completed between two calls to
** or __system_property_update
2
has completed between two calls to
** __system_property_area_serial then the second call will return a larger
** __system_property_area_serial
2
then the second call will return a larger
** value than the first call. Beware of race conditions as changes to the
** value than the first call. Beware of race conditions as changes to the
** properties are not atomic, the main value of this call is to determine
** properties are not atomic, the main value of this call is to determine
** whether the expensive __system_property_find is worth retrying to see if
** whether the expensive __system_property_find
2
is worth retrying to see if
** a property now exists.
** a property now exists.
**
**
** Returns the serial number on success, -1 on error.
** Returns the serial number on success, -1 on error.
*/
*/
uint32_t
__system_property_area_serial
();
uint32_t
__system_property_area_serial
2
();
/* Add a new system property. Can only be done by a single
/* Add a new system property. Can only be done by a single
** process that has write access to the property area, and
** process that has write access to the property area, and
...
@@ -103,7 +103,7 @@ uint32_t __system_property_area_serial();
...
@@ -103,7 +103,7 @@ uint32_t __system_property_area_serial();
**
**
** Returns 0 on success, -1 if the property area is full.
** Returns 0 on success, -1 if the property area is full.
*/
*/
int
__system_property_add
(
const
char
*
name
,
unsigned
int
namelen
,
const
char
*
value
,
unsigned
int
valuelen
);
int
__system_property_add
2
(
const
char
*
name
,
unsigned
int
namelen
,
const
char
*
value
,
unsigned
int
valuelen
);
/* Delete a new system property. Added in resetprop
/* Delete a new system property. Added in resetprop
**
**
...
@@ -112,21 +112,21 @@ int __system_property_add(const char *name, unsigned int namelen, const char *va
...
@@ -112,21 +112,21 @@ int __system_property_add(const char *name, unsigned int namelen, const char *va
int
__system_property_del
(
const
char
*
name
);
int
__system_property_del
(
const
char
*
name
);
/* Update the value of a system property returned by
/* Update the value of a system property returned by
** __system_property_find. Can only be done by a single process
** __system_property_find
2
. Can only be done by a single process
** that has write access to the property area, and that process
** that has write access to the property area, and that process
** must handle sequencing to ensure that only one property is
** must handle sequencing to ensure that only one property is
** updated at a time.
** updated at a time.
**
**
** Returns 0 on success, -1 if the parameters are incorrect.
** Returns 0 on success, -1 if the parameters are incorrect.
*/
*/
int
__system_property_update
(
prop_info
*
pi
,
const
char
*
value
,
unsigned
int
len
);
int
__system_property_update
2
(
prop_info
*
pi
,
const
char
*
value
,
unsigned
int
len
);
/* Read the serial number of a system property returned by
/* Read the serial number of a system property returned by
** __system_property_find.
** __system_property_find
2
.
**
**
** Returns the serial number on success, -1 on error.
** Returns the serial number on success, -1 on error.
*/
*/
uint32_t
__system_property_serial
(
const
prop_info
*
pi
);
uint32_t
__system_property_serial
2
(
const
prop_info
*
pi
);
/* Initialize the system properties area in read only mode.
/* Initialize the system properties area in read only mode.
* Should be done by all processes that need to read system
* Should be done by all processes that need to read system
...
@@ -134,10 +134,10 @@ uint32_t __system_property_serial(const prop_info* pi);
...
@@ -134,10 +134,10 @@ uint32_t __system_property_serial(const prop_info* pi);
*
*
* Returns 0 on success, -1 otherwise.
* Returns 0 on success, -1 otherwise.
*/
*/
int
__system_properties_init
();
int
__system_properties_init
2
();
/* Deprecated: use __system_property_wait instead. */
/* Deprecated: use __system_property_wait
2
instead. */
uint32_t
__system_property_wait_any
(
uint32_t
old_serial
);
uint32_t
__system_property_wait_any
2
(
uint32_t
old_serial
);
__END_DECLS
__END_DECLS
...
...
jni/resetprop/libc_logging.cpp
deleted
100644 → 0
View file @
14c5c608
This diff is collapsed.
Click to expand it.
jni/resetprop/libc_logging.h
deleted
100644 → 0
View file @
14c5c608
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _LIBC_LOGGING_H
#define _LIBC_LOGGING_H
#include <sys/cdefs.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
__BEGIN_DECLS
enum
{
ANDROID_LOG_UNKNOWN
=
0
,
ANDROID_LOG_DEFAULT
,
/* only for SetMinPriority() */
ANDROID_LOG_VERBOSE
,
ANDROID_LOG_DEBUG
,
ANDROID_LOG_INFO
,
ANDROID_LOG_WARN
,
ANDROID_LOG_ERROR
,
ANDROID_LOG_FATAL
,
ANDROID_LOG_SILENT
,
/* only for SetMinPriority(); must be last */
};
enum
{
LOG_ID_MIN
=
0
,
LOG_ID_MAIN
=
0
,
LOG_ID_RADIO
=
1
,
LOG_ID_EVENTS
=
2
,
LOG_ID_SYSTEM
=
3
,
LOG_ID_CRASH
=
4
,
LOG_ID_MAX
};
struct
abort_msg_t
{
size_t
size
;
char
msg
[
0
];
};
//
// Formats a message to the log (priority 'fatal'), then aborts.
//
__LIBC_HIDDEN__
__noreturn
void
__libc_fatal
(
const
char
*
format
,
...)
__printflike
(
1
,
2
);
//
// Formats a message to the log (priority 'fatal'), but doesn't abort.
// Used by the malloc implementation to ensure that debuggerd dumps memory
// around the bad address.
//
__LIBC_HIDDEN__
void
__libc_fatal_no_abort
(
const
char
*
format
,
...)
__printflike
(
1
,
2
);
//
// Formatting routines for the C library's internal debugging.
// Unlike the usual alternatives, these don't allocate, and they don't drag in all of stdio.
//
__LIBC_HIDDEN__
int
__libc_format_buffer
(
char
*
buffer
,
size_t
buffer_size
,
const
char
*
format
,
...)
__printflike
(
3
,
4
);
__LIBC_HIDDEN__
int
__libc_format_fd
(
int
fd
,
const
char
*
format
,
...)
__printflike
(
2
,
3
);
__LIBC_HIDDEN__
int
__libc_format_log
(
int
priority
,
const
char
*
tag
,
const
char
*
format
,
...)
__printflike
(
3
,
4
);
__LIBC_HIDDEN__
int
__libc_format_log_va_list
(
int
priority
,
const
char
*
tag
,
const
char
*
format
,
va_list
ap
);
__LIBC_HIDDEN__
int
__libc_write_log
(
int
priority
,
const
char
*
tag
,
const
char
*
msg
);
//
// Event logging.
//
__LIBC_HIDDEN__
void
__libc_android_log_event_int
(
int32_t
tag
,
int
value
);
__LIBC_HIDDEN__
void
__libc_android_log_event_uid
(
int32_t
tag
);
__LIBC_HIDDEN__
__noreturn
void
__fortify_chk_fail
(
const
char
*
msg
,
uint32_t
event_tag
);
__END_DECLS
#endif
jni/resetprop/resetprop.cpp
View file @
17d3a87b
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
* Functions that need to be patched/added in system_properties.cpp
* Functions that need to be patched/added in system_properties.cpp
*
*
* int __system_properties_init()
* int __system_properties_init
2
()
* on android 7, first tear down the everything then let it initialize again:
* on android 7, first tear down the everything then let it initialize again:
* if (initialized) {
* if (initialized) {
* //list_foreach(contexts, [](context_node* l) { l->reset_access(); });
* //list_foreach(contexts, [](context_node* l) { l->reset_access(); });
...
@@ -123,7 +123,7 @@ static int usage(char* arg0) {
...
@@ -123,7 +123,7 @@ static int usage(char* arg0) {
int
init_resetprop
()
{
int
init_resetprop
()
{
PRINT_D
(
"resetprop: Initializing...
\n
"
);
PRINT_D
(
"resetprop: Initializing...
\n
"
);
if
(
__system_properties_init
())
{
if
(
__system_properties_init
2
())
{
PRINT_E
(
"resetprop: Initialize error
\n
"
);
PRINT_E
(
"resetprop: Initialize error
\n
"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -136,12 +136,12 @@ static void read_prop_info(void* cookie, const char *name, const char *value, ui
...
@@ -136,12 +136,12 @@ static void read_prop_info(void* cookie, const char *name, const char *value, ui
// Get prop by name, return string (should free manually!)
// Get prop by name, return string (should free manually!)
char
*
getprop
(
const
char
*
name
)
{
char
*
getprop
(
const
char
*
name
)
{
const
prop_info
*
pi
=
__system_property_find
(
name
);
const
prop_info
*
pi
=
__system_property_find
2
(
name
);
if
(
pi
==
NULL
)
{
if
(
pi
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
char
value
[
PROP_VALUE_MAX
];
char
value
[
PROP_VALUE_MAX
];
__system_property_read_callback
(
pi
,
read_prop_info
,
value
);
__system_property_read_callback
2
(
pi
,
read_prop_info
,
value
);
PRINT_D
(
"resetprop: getprop [%s]: [%s]
\n
"
,
name
,
value
);
PRINT_D
(
"resetprop: getprop [%s]: [%s]
\n
"
,
name
,
value
);
return
strdup
(
value
);
return
strdup
(
value
);
}
}
...
@@ -158,16 +158,16 @@ int setprop2(const char *name, const char *value, const int trigger) {
...
@@ -158,16 +158,16 @@ int setprop2(const char *name, const char *value, const int trigger) {
free
(
check
);
free
(
check
);
if
(
trigger
)
{
if
(
trigger
)
{
if
(
!
strncmp
(
name
,
"ro."
,
3
))
deleteprop
(
name
);
if
(
!
strncmp
(
name
,
"ro."
,
3
))
deleteprop
(
name
);
ret
=
__system_property_set
(
name
,
value
);
ret
=
__system_property_set
2
(
name
,
value
);
}
else
{
}
else
{
ret
=
__system_property_update
((
prop_info
*
)
__system_property_find
(
name
),
value
,
strlen
(
value
));
ret
=
__system_property_update
2
((
prop_info
*
)
__system_property_find2
(
name
),
value
,
strlen
(
value
));
}
}
}
else
{
}
else
{
PRINT_D
(
"resetprop: New prop [%s]
\n
"
,
name
);
PRINT_D
(
"resetprop: New prop [%s]
\n
"
,
name
);
if
(
trigger
)
{
if
(
trigger
)
{
ret
=
__system_property_set
(
name
,
value
);
ret
=
__system_property_set
2
(
name
,
value
);
}
else
{
}
else
{
ret
=
__system_property_add
(
name
,
strlen
(
name
),
value
,
strlen
(
value
));
ret
=
__system_property_add
2
(
name
,
strlen
(
name
),
value
,
strlen
(
value
));
}
}
}
}
...
@@ -276,6 +276,8 @@ int resetprop_main(int argc, char *argv[]) {
...
@@ -276,6 +276,8 @@ int resetprop_main(int argc, char *argv[]) {
}
}
}
}
init_resetprop
();
if
(
file
)
{
if
(
file
)
{
return
read_prop_file
(
filename
,
trigger
);
return
read_prop_file
(
filename
,
trigger
);
}
else
if
(
del
)
{
}
else
if
(
del
)
{
...
...
jni/resetprop/system_properties.cpp
View file @
17d3a87b
This diff is collapsed.
Click to expand it.
jni/resetprop/system_properties.h
View file @
17d3a87b
...
@@ -43,30 +43,30 @@ typedef struct prop_info prop_info;
...
@@ -43,30 +43,30 @@ typedef struct prop_info prop_info;
/*
/*
* Sets system property `key` to `value`, creating the system property if it doesn't already exist.
* Sets system property `key` to `value`, creating the system property if it doesn't already exist.
*/
*/
int
__system_property_set
(
const
char
*
key
,
const
char
*
value
)
__INTRODUCED_IN
(
12
);
int
__system_property_set
2
(
const
char
*
key
,
const
char
*
value
)
__INTRODUCED_IN
(
12
);
/*
/*
* Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist.
* Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist.
* Use __system_property_read_callback to query the current value.
* Use __system_property_read_callback
2
to query the current value.
*
*
* Property lookup is expensive, so it can be useful to cache the result of this function.
* Property lookup is expensive, so it can be useful to cache the result of this function.
*/
*/
const
prop_info
*
__system_property_find
(
const
char
*
name
);
const
prop_info
*
__system_property_find
2
(
const
char
*
name
);
/*
/*
* Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
* Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
*/
*/
void
__system_property_read_callback
(
const
prop_info
*
pi
,
void
__system_property_read_callback
2
(
const
prop_info
*
pi
,
void
(
*
callback
)(
void
*
cookie
,
const
char
*
name
,
const
char
*
value
,
uint32_t
serial
),
void
(
*
callback
)(
void
*
cookie
,
const
char
*
name
,
const
char
*
value
,
uint32_t
serial
),
void
*
cookie
)
__INTRODUCED_IN
_FUTURE
;
void
*
cookie
)
__INTRODUCED_IN
(
26
)
;
/*
/*
* Passes a `prop_info` for each system property to the provided
* Passes a `prop_info` for each system property to the provided
* callback. Use __system_property_read_callback() to read the value.
* callback. Use __system_property_read_callback
2
() to read the value.
*
*
* This method is for inspecting and debugging the property system, and not generally useful.
* This method is for inspecting and debugging the property system, and not generally useful.
*/
*/
int
__system_property_foreach
(
void
(
*
propfn
)(
const
prop_info
*
pi
,
void
*
cookie
),
void
*
cookie
)
int
__system_property_foreach
2
(
void
(
*
propfn
)(
const
prop_info
*
pi
,
void
*
cookie
),
void
*
cookie
)
__INTRODUCED_IN
(
19
);
__INTRODUCED_IN
(
19
);
/*
/*
...
@@ -82,20 +82,20 @@ int __system_property_foreach(void (*propfn)(const prop_info* pi, void* cookie),
...
@@ -82,20 +82,20 @@ int __system_property_foreach(void (*propfn)(const prop_info* pi, void* cookie),
* timed out.
* timed out.
*/
*/
struct
timespec
;
struct
timespec
;
bool
__system_property_wait
(
const
prop_info
*
pi
,
bool
__system_property_wait
2
(
const
prop_info
*
pi
,
uint32_t
old_serial
,
uint32_t
old_serial
,
uint32_t
*
new_serial_ptr
,
uint32_t
*
new_serial_ptr
,
const
struct
timespec
*
relative_timeout
)
const
struct
timespec
*
relative_timeout
)
__INTRODUCED_IN
_FUTURE
;
__INTRODUCED_IN
(
26
)
;
/* Deprecated. In Android O and above, there's no limit on property name length. */
/* Deprecated. In Android O and above, there's no limit on property name length. */
#define PROP_NAME_MAX 32
#define PROP_NAME_MAX 32
/* Deprecated. Use __system_property_read_callback instead. */
/* Deprecated. Use __system_property_read_callback
2
instead. */
int
__system_property_read
(
const
prop_info
*
pi
,
char
*
name
,
char
*
value
);
int
__system_property_read
2
(
const
prop_info
*
pi
,
char
*
name
,
char
*
value
);
/* Deprecated. Use __system_property_read_callback instead. */
/* Deprecated. Use __system_property_read_callback
2
instead. */
int
__system_property_get
(
const
char
*
name
,
char
*
value
);
int
__system_property_get
2
(
const
char
*
name
,
char
*
value
);
/* Deprecated. Use __system_property_foreach
instead. Aborts in Android O and above
. */
/* Deprecated. Use __system_property_foreach
2 instead
. */
const
prop_info
*
__system_property_find_nth
(
unsigned
n
)
__REMOVED_IN
(
26
);
const
prop_info
*
__system_property_find_nth2
(
unsigned
n
);
__END_DECLS
__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