• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

external/koush/Superuser


Commit MetaInfo

Revisionb27031ea499498d2632583c167a7e6126391756d (tree)
Time2013-11-24 08:02:58
AuthorKevin Cernekee <cernekee@gmai...>
CommiterKevin Cernekee

Log Message

Add workaround for Samsung set*id restrictions (bug #196)

Change Summary

Incremental Difference

--- a/Superuser/jni/su/su.c
+++ b/Superuser/jni/su/su.c
@@ -623,6 +623,28 @@ static int is_api_18() {
623623 return ver >= 18;
624624 }
625625
626+static void fork_for_samsung(void)
627+{
628+ // Samsung CONFIG_SEC_RESTRICT_SETUID wants the parent process to have
629+ // EUID 0, or else our setresuid() calls will be denied. So make sure
630+ // all such syscalls are executed by a child process.
631+ int rv;
632+
633+ switch (fork()) {
634+ case 0:
635+ return;
636+ case -1:
637+ PLOGE("fork");
638+ exit(1);
639+ default:
640+ if (wait(&rv) < 0) {
641+ exit(1);
642+ } else {
643+ exit(WEXITSTATUS(rv));
644+ }
645+ }
646+}
647+
626648 int main(int argc, char *argv[]) {
627649 // start up in daemon mode if prompted
628650 if (argc == 2 && strcmp(argv[1], "--daemon") == 0) {
@@ -641,6 +663,8 @@ int main(int argc, char *argv[]) {
641663
642664 LOGD("skipping daemon client %d %d", getuid(), geteuid());
643665
666+ fork_for_samsung();
667+
644668 // Sanitize all secure environment variables (from linker_environ.c in AOSP linker).
645669 /* The same list than GLibc at this point */
646670 static const char* const unsec_vars[] = {