diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-17 23:00:41 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-17 23:00:41 +0000 |
commit | d9a434b6deb9a5c83515d4b40a2a0928ad967385 (patch) | |
tree | 7f0387af5681fb69ea2ba014bc07e3ec08179070 | |
parent | c35ef85640a7c4b7d3980d55d7c664a45a51143c (diff) | |
parent | 30537bd10a17d48a52506d1bb679b578e969d33f (diff) | |
download | bionic-android14-d1-s1-release.tar.gz |
Snap for 10509639 from 30537bd10a17d48a52506d1bb679b578e969d33f to udc-d1-releaseandroid-14.0.0_r9android-14.0.0_r8android-14.0.0_r7android-14.0.0_r6android-14.0.0_r5android-14.0.0_r4android-14.0.0_r3android-14.0.0_r12android-14.0.0_r11android-14.0.0_r10android14-d1-s7-releaseandroid14-d1-s6-releaseandroid14-d1-s5-releaseandroid14-d1-s4-releaseandroid14-d1-s3-releaseandroid14-d1-s2-releaseandroid14-d1-s1-releaseandroid14-d1-release
Change-Id: If7c30bef5a1f2827ee58c420c4db0ffd9e7011d8
-rw-r--r-- | libc/bionic/system_property_set.cpp | 23 | ||||
-rw-r--r-- | libc/include/sys/_system_properties.h | 1 |
2 files changed, 5 insertions, 19 deletions
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp index 845ff27e6..212aafcc1 100644 --- a/libc/bionic/system_property_set.cpp +++ b/libc/bionic/system_property_set.cpp @@ -49,34 +49,21 @@ #include "private/ScopedFd.h" static const char property_service_socket[] = "/dev/socket/" PROP_SERVICE_NAME; -static const char property_service_for_system_socket[] = - "/dev/socket/" PROP_SERVICE_FOR_SYSTEM_NAME; static const char* kServiceVersionPropertyName = "ro.property_service.version"; class PropertyServiceConnection { public: - PropertyServiceConnection(const char* name) : last_error_(0) { + PropertyServiceConnection() : last_error_(0) { socket_.reset(::socket(AF_LOCAL, SOCK_STREAM | SOCK_CLOEXEC, 0)); if (socket_.get() == -1) { last_error_ = errno; return; } - // If we're trying to set "sys.powerctl" from a privileged process, use the special - // socket. Because this socket is only accessible to privileged processes, it can't - // be DoSed directly by malicious apps. (The shell user should be able to reboot, - // though, so we don't just always use the special socket for "sys.powerctl".) - // See b/262237198 for context - const char* socket = property_service_socket; - if (strcmp(name, "sys.powerctl") == 0 && - access(property_service_for_system_socket, W_OK) == 0) { - socket = property_service_for_system_socket; - } - - const size_t namelen = strlen(socket); + const size_t namelen = strlen(property_service_socket); sockaddr_un addr; memset(&addr, 0, sizeof(addr)); - strlcpy(addr.sun_path, socket, sizeof(addr.sun_path)); + strlcpy(addr.sun_path, property_service_socket, sizeof(addr.sun_path)); addr.sun_family = AF_LOCAL; socklen_t alen = namelen + offsetof(sockaddr_un, sun_path) + 1; @@ -189,7 +176,7 @@ struct prop_msg { }; static int send_prop_msg(const prop_msg* msg) { - PropertyServiceConnection connection(msg->name); + PropertyServiceConnection connection; if (!connection.IsValid()) { return connection.GetLastError(); } @@ -282,7 +269,7 @@ int __system_property_set(const char* key, const char* value) { // New protocol only allows long values for ro. properties only. if (strlen(value) >= PROP_VALUE_MAX && strncmp(key, "ro.", 3) != 0) return -1; // Use proper protocol - PropertyServiceConnection connection(key); + PropertyServiceConnection connection; if (!connection.IsValid()) { errno = connection.GetLastError(); async_safe_format_log( diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h index c7a30ebbd..744a45b71 100644 --- a/libc/include/sys/_system_properties.h +++ b/libc/include/sys/_system_properties.h @@ -41,7 +41,6 @@ __BEGIN_DECLS #define PROP_SERVICE_NAME "property_service" -#define PROP_SERVICE_FOR_SYSTEM_NAME "property_service_for_system" #define PROP_FILENAME "/dev/__properties__" #define PROP_MSG_SETPROP 1 |