Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README #36

Open
wants to merge 76 commits into
base: legacy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
4b31539
Do not use _mktemp
ChainsDD Jun 15, 2011
9b15727
Fix Android.mk
ChainsDD Jun 15, 2011
91cd65c
Bump version
ChainsDD Jun 15, 2011
f79e166
Merge master-dev into master
ChainsDD Sep 27, 2011
186b862
shell uid always gets root.
koush Oct 6, 2011
00f1bb5
Possible fix for db crash
Oct 18, 2011
6fa4b9c
Merge pull request #2 from HomerSp/master
ChainsDD Oct 18, 2011
49427f6
Fix potential buffer overflow when getting a shell from the command line
Oct 22, 2011
a0cc2b9
Fix file mode:
ChainsDD Oct 22, 2011
67394c6
bump verison
ChainsDD Oct 22, 2011
a185546
Fix db double close
Oct 22, 2011
fa0ecd3
Merge branch 'master' of git://github.com/ChainsDD/su-binary
Oct 22, 2011
815bd14
Merge pull request #3 from git-core/master
ChainsDD Oct 22, 2011
263b17e
Clean up whitespace
ChainsDD Oct 22, 2011
233b1d0
bump version
ChainsDD Dec 14, 2011
a9a303f
bump version
ChainsDD Dec 14, 2011
0123ee3
Report error from read rather than successful completion of close
Oct 23, 2011
2e17b69
Remove setgroups in allow()
Oct 23, 2011
d5984c9
Always free result table if sqlite3_get_table succeeds
Oct 29, 2011
4c6ea93
Clean up sources
Oct 30, 2011
7d97cfe
Fix potential security flaw in creation of sockets/directories
Dec 3, 2011
1fe89ff
Remove all occurences of req_uid
Oct 23, 2011
690dcc6
Merge pull request #4 from git-core/master
ChainsDD Dec 15, 2011
9934e87
Fix for Android 4.0.3 from shakalaca on github
ChainsDD Dec 18, 2011
070fc98
bump version
ChainsDD Dec 18, 2011
e0329ce
Inherit the environment of the caller process for a new process image
Dec 16, 2011
8fb8756
Report error from read rather than successful completion of close
Oct 23, 2011
8cee79f
Remove setgroups in allow()
Oct 23, 2011
7e47a99
Always free result table if sqlite3_get_table succeeds
Oct 29, 2011
77cf837
Clean up sources
Oct 30, 2011
b1e2851
Fix potential security flaw in creation of sockets/directories
Dec 3, 2011
ae5862b
Remove all occurences of req_uid
Oct 23, 2011
4b22bdc
Fix for Android 4.0.3 from shakalaca on github
ChainsDD Dec 18, 2011
c46a3db
bump version
ChainsDD Dec 18, 2011
b9a681d
Use /dev as storage for cache instead of /data/data
Dec 16, 2011
fb9f063
Preliminary fix for security issue reported via private email
Dec 17, 2011
73a4964
Move all code that deals with database in db.c
Dec 17, 2011
cbcc769
Don't use mktemp
Dec 18, 2011
815edac
Merge legacy branch
Dec 19, 2011
cf50c02
Fix off-by-one bug when calculating the bundle size
Dec 25, 2011
983d8e0
Reorder the code which stores intent into parcel for clarity
Dec 26, 2011
57d607f
Use DEFAULT_COMMAND intead of hardcoded name for default shell
Dec 28, 2011
b3c8708
Fix segmentation fault when shell passed via -s doesn't contain /
Dec 28, 2011
da86864
Exit with false status if exec(3) fails ...
Dec 28, 2011
fc7479f
Be compatible with other implementation of su
Dec 28, 2011
0e769cc
Don't allow garbage instead of real uid in the command line
Dec 28, 2011
94d02f2
Bump version
ChainsDD Jan 5, 2012
bc9bbec
Check syscall return codes
Jan 14, 2012
c29f8d4
Remove the communication socket if Ctrl+C (SIGINT) or Ctrl+\ (SIGQUIT…
Jan 17, 2012
aa74885
Prepare to implement argument passing from su command line to a callee
Jan 17, 2012
e39e1e3
Accurately handle -c option
Jan 21, 2012
69c1b43
Return special exit code when terminating by signal
Jan 21, 2012
ac59b39
Handle -l option
Jan 21, 2012
418ec8b
Pass the rest of arguments in the command line to a callee
Jan 29, 2012
4eb8017
Combine su_initiator and su_request into su_context
Jan 29, 2012
6f6eb26
Move frequently used code snippet in get_command()
Jan 29, 2012
95fe237
Call property_get() only once
Jan 29, 2012
73e06ac
Pass last parameter to send_intent() as pointer to the action name
Jan 29, 2012
067da4e
Provide LOG_TAG for db too
Jan 29, 2012
3352996
constantify su_context* arg & small cosmetic fixes
Jan 29, 2012
b7744e9
Merge branch 'gc' into gc-ics
Feb 18, 2012
c97414b
Revert "Inherit the environment of the caller process for a new proce…
Feb 20, 2012
8afac1d
Setup environment for a new process image, implement -p/-m options
Feb 25, 2012
f39dbf0
Change euid back to root before finally set a new id
Mar 3, 2012
382d1e3
Use am to send intents rather than a binder transaction.
ChainsDD Jun 4, 2012
d86184a
Build su as static.
ChainsDD Jun 4, 2012
8bf97db
Send information required for the result service in the intent
ChainsDD Jun 4, 2012
538413f
CM specific changes to allow disabling of root access from system set…
ChainsDD Jul 1, 2012
ec37525
Use flat files for stored apps
ChainsDD Jul 7, 2012
ff77b49
Update version
ChainsDD Jul 7, 2012
15ea355
Revert "Update version"
ChainsDD Jul 8, 2012
588c414
Revert "Use flat files for stored apps"
ChainsDD Jul 8, 2012
d74df17
Revert "Revert "Use flat files for stored apps""
ChainsDD Jul 8, 2012
f215759
Revert "Revert "Update version""
ChainsDD Jul 8, 2012
4baab01
Prevent compiler warnings
ChainsDD Jul 8, 2012
e40811c
Update README
shadiberck Apr 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE := su
LOCAL_SRC_FILES := su.c activity.cpp
LOCAL_SRC_FILES := su.c db.c activity.c utils.c


LOCAL_C_INCLUDES += external/sqlite/dist
LOCAL_SHARED_LIBRARIES := liblog libsqlite libandroid_runtime
LOCAL_STATIC_LIBRARIES := \
liblog \
libc \

LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := eng debug
LOCAL_FORCE_STATIC_EXECUTABLE := true

include $(BUILD_EXECUTABLE)
include $(BUILD_EXECUTABLE)
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Branches for this repo support the following Android versions:
Branches marked with '-dev' are in work and should probably not be used. I will push to those channels as I develop new versions so they may be broken from time to time.

* I have yet to personally test superuser on any honeycomb devices, therefore I cannot guarantee it's compatibility
Run
78 changes: 78 additions & 0 deletions activity.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
** Copyright 2010, Adam Shanks (@ChainsDD)
** Copyright 2008, Zinx Verituse (@zinxv)
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>

#include "su.h"

int send_intent(const struct su_context *ctx,
const char *socket_path, int allow, const char *action)
{
char command[PATH_MAX];

sprintf(command, "/system/bin/am broadcast -a '%s' --es socket '%s' --ei caller_uid '%d' --ei allow '%d' --ei version_code '%d' > /dev/null",
action, socket_path, ctx->from.uid, allow, VERSION_CODE);

// before sending the intent, make sure the (uid and euid) and (gid and egid) match,
// otherwise LD_LIBRARY_PATH is wiped in Android 4.0+.
// Also, sanitize all secure environment variables (from linker_environ.c in linker).

/* The same list than GLibc at this point */
static const char* const unsec_vars[] = {
"GCONV_PATH",
"GETCONF_DIR",
"HOSTALIASES",
"LD_AUDIT",
"LD_DEBUG",
"LD_DEBUG_OUTPUT",
"LD_DYNAMIC_WEAK",
"LD_LIBRARY_PATH",
"LD_ORIGIN_PATH",
"LD_PRELOAD",
"LD_PROFILE",
"LD_SHOW_AUXV",
"LD_USE_LOAD_BIAS",
"LOCALDOMAIN",
"LOCPATH",
"MALLOC_TRACE",
"MALLOC_CHECK_",
"NIS_PATH",
"NLSPATH",
"RESOLV_HOST_CONF",
"RES_OPTIONS",
"TMPDIR",
"TZDIR",
"LD_AOUT_LIBRARY_PATH",
"LD_AOUT_PRELOAD",
// not listed in linker, used due to system() call
"IFS",
};
const char* const* cp = unsec_vars;
const char* const* endp = cp + sizeof(unsec_vars)/sizeof(unsec_vars[0]);
while (cp < endp) {
unsetenv(*cp);
cp++;
}

// sane value so "am" works
setenv("LD_LIBRARY_PATH", "/vendor/lib:/system/lib", 1);
setegid(getgid());
seteuid(getuid());
return system(command);
}
113 changes: 0 additions & 113 deletions activity.cpp

This file was deleted.

58 changes: 58 additions & 0 deletions db.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
** Copyright 2010, Adam Shanks (@ChainsDD)
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/

#include <stdlib.h>
#include <stdio.h>
#include <limits.h>
#include <cutils/log.h>

#include "su.h"

int database_check(const struct su_context *ctx)
{
FILE *fp;
char allow = '-';
char *filename = malloc(snprintf(NULL, 0, "%s/%u-%u", REQUESTOR_STORED_PATH, ctx->from.uid, ctx->to.uid) + 1);
sprintf(filename, "%s/%u-%u", REQUESTOR_STORED_PATH, ctx->from.uid, ctx->to.uid);
if ((fp = fopen(filename, "r"))) {
LOGD("Found file");
char cmd[PATH_MAX];
fgets(cmd, sizeof(cmd), fp);
int last = strlen(cmd) - 1;
LOGD("this is the last character %u of the string", cmd[5]);
if (cmd[last] == '\n') {
cmd[last] = '\0';
}
LOGD("Comparing %c %s, %u to %s", cmd[last - 2], cmd, last, get_command(&ctx->to));
if (strcmp(cmd, get_command(&ctx->to)) == 0) {
allow = fgetc(fp);
}
fclose(fp);
} else if ((fp = fopen(REQUESTOR_STORED_DEFAULT, "r"))) {
LOGD("Using default");
allow = fgetc(fp);
fclose(fp);
}
free(filename);

if (allow == '1') {
return DB_ALLOW;
} else if (allow == '0') {
return DB_DENY;
} else {
return DB_INTERACTIVE;
}
}
Loading