Commit 17d3a87b authored by topjohnwu's avatar topjohnwu

Prevent resetprop function signature duplicate with libc

parent 14c5c608
......@@ -34,7 +34,6 @@ LOCAL_SRC_FILES := \
magiskpolicy/sepolicy.c \
magiskpolicy/api.c \
resetprop/resetprop.cpp \
resetprop/libc_logging.cpp \
resetprop/system_properties.cpp \
su/su.c \
su/activity.c \
......
......@@ -693,6 +693,9 @@ void post_fs_data(int client) {
bind_mount(HOSTSFILE, "/system/etc/hosts");
}
// Initialize resetprop for the daemon
init_resetprop();
// Start magiskhide if enabled
char *hide_prop = getprop(MAGISKHIDE_PROP);
if (hide_prop) {
......
......@@ -62,38 +62,38 @@ __BEGIN_DECLS
** Map the property area from the specified filename. This
** method is for testing only.
*/
int __system_property_set_filename(const char *filename);
int __system_property_set_filename2(const char *filename);
/*
** Initialize the area to be used to store properties. Can
** only be done by a single process that has write access to
** the property area.
*/
int __system_property_area_init();
int __system_property_area_init2();
/* Read the global serial number of the system properties
**
** Called to predict if a series of cached __system_property_find
** objects will have seen __system_property_serial values change.
** Called to predict if a series of cached __system_property_find2
** objects will have seen __system_property_serial2 values change.
** 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_find2
** 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_find2.
**
** 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
** __system_property_serial to confirm dirty, or __system_property_find
** to check if the property now exists. If a call to __system_property_add
** or __system_property_update has completed between two calls to
** __system_property_area_serial then the second call will return a larger
** __system_property_serial2 to confirm dirty, or __system_property_find2
** to check if the property now exists. If a call to __system_property_add2
** or __system_property_update2 has completed between two calls to
** __system_property_area_serial2 then the second call will return a larger
** 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
** whether the expensive __system_property_find is worth retrying to see if
** whether the expensive __system_property_find2 is worth retrying to see if
** a property now exists.
**
** Returns the serial number on success, -1 on error.
*/
uint32_t __system_property_area_serial();
uint32_t __system_property_area_serial2();
/* Add a new system property. Can only be done by a single
** process that has write access to the property area, and
......@@ -103,7 +103,7 @@ uint32_t __system_property_area_serial();
**
** 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_add2(const char *name, unsigned int namelen, const char *value, unsigned int valuelen);
/* 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
int __system_property_del(const char *name);
/* Update the value of a system property returned by
** __system_property_find. Can only be done by a single process
** __system_property_find2. Can only be done by a single process
** that has write access to the property area, and that process
** must handle sequencing to ensure that only one property is
** updated at a time.
**
** 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_update2(prop_info *pi, const char *value, unsigned int len);
/* Read the serial number of a system property returned by
** __system_property_find.
** __system_property_find2.
**
** Returns the serial number on success, -1 on error.
*/
uint32_t __system_property_serial(const prop_info* pi);
uint32_t __system_property_serial2(const prop_info* pi);
/* Initialize the system properties area in read only mode.
* Should be done by all processes that need to read system
......@@ -134,10 +134,10 @@ uint32_t __system_property_serial(const prop_info* pi);
*
* Returns 0 on success, -1 otherwise.
*/
int __system_properties_init();
int __system_properties_init2();
/* Deprecated: use __system_property_wait instead. */
uint32_t __system_property_wait_any(uint32_t old_serial);
/* Deprecated: use __system_property_wait2 instead. */
uint32_t __system_property_wait_any2(uint32_t old_serial);
__END_DECLS
......
This diff is collapsed.
/*
* 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
......@@ -11,7 +11,7 @@
*
* Functions that need to be patched/added in system_properties.cpp
*
* int __system_properties_init()
* int __system_properties_init2()
* on android 7, first tear down the everything then let it initialize again:
* if (initialized) {
* //list_foreach(contexts, [](context_node* l) { l->reset_access(); });
......@@ -123,7 +123,7 @@ static int usage(char* arg0) {
int init_resetprop() {
PRINT_D("resetprop: Initializing...\n");
if (__system_properties_init()) {
if (__system_properties_init2()) {
PRINT_E("resetprop: Initialize error\n");
return -1;
}
......@@ -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!)
char *getprop(const char *name) {
const prop_info *pi = __system_property_find(name);
const prop_info *pi = __system_property_find2(name);
if (pi == NULL) {
return NULL;
}
char value[PROP_VALUE_MAX];
__system_property_read_callback(pi, read_prop_info, value);
__system_property_read_callback2(pi, read_prop_info, value);
PRINT_D("resetprop: getprop [%s]: [%s]\n", name, value);
return strdup(value);
}
......@@ -158,16 +158,16 @@ int setprop2(const char *name, const char *value, const int trigger) {
free(check);
if (trigger) {
if (!strncmp(name, "ro.", 3)) deleteprop(name);
ret = __system_property_set(name, value);
ret = __system_property_set2(name, value);
} else {
ret = __system_property_update((prop_info*) __system_property_find(name), value, strlen(value));
ret = __system_property_update2((prop_info*) __system_property_find2(name), value, strlen(value));
}
} else {
PRINT_D("resetprop: New prop [%s]\n", name);
if (trigger) {
ret = __system_property_set(name, value);
ret = __system_property_set2(name, value);
} else {
ret = __system_property_add(name, strlen(name), value, strlen(value));
ret = __system_property_add2(name, strlen(name), value, strlen(value));
}
}
......@@ -276,6 +276,8 @@ int resetprop_main(int argc, char *argv[]) {
}
}
init_resetprop();
if (file) {
return read_prop_file(filename, trigger);
} else if (del) {
......
This diff is collapsed.
......@@ -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.
*/
int __system_property_set(const char* key, const char* value) __INTRODUCED_IN(12);
int __system_property_set2(const char* key, const char* value) __INTRODUCED_IN(12);
/*
* 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_callback2 to query the current value.
*
* 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_find2(const char* name);
/*
* 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_callback2(const prop_info *pi,
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
* callback. Use __system_property_read_callback() to read the value.
* callback. Use __system_property_read_callback2() to read the value.
*
* 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_foreach2(void (*propfn)(const prop_info* pi, void* cookie), void* cookie)
__INTRODUCED_IN(19);
/*
......@@ -82,20 +82,20 @@ int __system_property_foreach(void (*propfn)(const prop_info* pi, void* cookie),
* timed out.
*/
struct timespec;
bool __system_property_wait(const prop_info* pi,
bool __system_property_wait2(const prop_info* pi,
uint32_t old_serial,
uint32_t* new_serial_ptr,
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. */
#define PROP_NAME_MAX 32
/* Deprecated. Use __system_property_read_callback instead. */
int __system_property_read(const prop_info *pi, char *name, char *value);
/* Deprecated. Use __system_property_read_callback instead. */
int __system_property_get(const char *name, char *value);
/* Deprecated. Use __system_property_foreach instead. Aborts in Android O and above. */
const prop_info *__system_property_find_nth(unsigned n) __REMOVED_IN(26);
/* Deprecated. Use __system_property_read_callback2 instead. */
int __system_property_read2(const prop_info* pi, char* name, char* value);
/* Deprecated. Use __system_property_read_callback2 instead. */
int __system_property_get2(const char* name, char* value);
/* Deprecated. Use __system_property_foreach2 instead. */
const prop_info* __system_property_find_nth2(unsigned n);
__END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment