#include <sys/stat.h>
#include <stdarg.h>
#include <sys/types.h>
+#include <sys/endian.h>
#include "su.h"
#include "utils.h"
return pid;
}
else {
- if (pid = fork())
+ if ((pid = fork()))
exit(0);
return 0;
}
from->uid = getuid();
from->pid = getppid();
+ if (is_daemon) {
+ from->uid = daemon_from_uid;
+ from->pid = daemon_from_pid;
+ }
+
/* Get the command line */
snprintf(path, sizeof(path), "/proc/%u/cmdline", from->pid);
fd = open(path, O_RDONLY);
strncpy(from->name, pw->pw_name, sizeof(from->name));
}
- if (is_daemon) {
- from->uid = daemon_from_uid;
- from->pid = daemon_from_pid;
- }
-
return 0;
}
static int socket_send_request(int fd, const struct su_context *ctx) {
#define write_data(fd, data, data_len) \
do { \
- size_t __len = htonl(data_len); \
+ uint32_t __len = htonl(data_len); \
__len = write((fd), &__len, sizeof(__len)); \
if (__len != sizeof(__len)) { \
PLOGE("write(" #data ")"); \
if (data != NULL) {
len = strlen(data);
if (len >= PROPERTY_VALUE_MAX)
- memcpy(enabled, "1", 2);
+ memcpy(enabled, "0", 2);
else
memcpy(enabled, data, len + 1);
free(data);
} else
- memcpy(enabled, "1", 2);
+ memcpy(enabled, "0", 2);
/* enforce persist.sys.root_access on non-eng builds for apps */
if (strcmp("eng", build_type) != 0 &&
return run_daemon();
}
+ int ppid = getppid();
fork_for_samsung();
// Sanitize all secure environment variables (from linker_environ.c in AOSP linker).
cp++;
}
- /*
- * set LD_LIBRARY_PATH if the linker has wiped out it due to we're suid.
- * This occurs on Android 4.0+
- */
- setenv("LD_LIBRARY_PATH", "/vendor/lib:/system/lib", 0);
-
LOGD("su invoked.");
struct su_context ctx = {
get_api_version() >= 19) {
// attempt to connect to daemon...
LOGD("starting daemon client %d %d", getuid(), geteuid());
- return connect_daemon(argc, argv);
+ return connect_daemon(argc, argv, ppid);
}
}