summaryrefslogtreecommitdiffstats
path: root/cmds/settings
diff options
context:
space:
mode:
authorSvetoslav <svetoslavganov@google.com>2015-03-02 16:21:35 -0800
committerSvetoslav <svetoslavganov@google.com>2015-03-02 16:24:18 -0800
commita8c6111a88df157240ea40e61f46df8366b1b945 (patch)
tree41fb40d840fdc125217fb8de2d993c2b14c8525c /cmds/settings
parent7b91c55b3ff4857e904a11a0a67fcc86a32868b4 (diff)
downloadframeworks_base-a8c6111a88df157240ea40e61f46df8366b1b945.zip
frameworks_base-a8c6111a88df157240ea40e61f46df8366b1b945.tar.gz
frameworks_base-a8c6111a88df157240ea40e61f46df8366b1b945.tar.bz2
Content and settings shell commands passing invalid calling package.
Change-Id: Ia80099ba0afba054b70511c0d95265ec303446e0
Diffstat (limited to 'cmds/settings')
-rw-r--r--cmds/settings/src/com/android/commands/settings/SettingsCmd.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
index e6847a9..a31b150 100644
--- a/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
+++ b/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
@@ -24,12 +24,12 @@ import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.Process;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
public final class SettingsCmd {
- static final String TAG = "settings";
enum CommandVerb {
UNSPECIFIED,
@@ -188,7 +188,7 @@ public final class SettingsCmd {
try {
Bundle arg = new Bundle();
arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
- Bundle b = provider.call(null, callGetCommand, key, arg);
+ Bundle b = provider.call(resolveCallingPackage(), callGetCommand, key, arg);
if (b != null) {
result = b.getPairValue();
}
@@ -213,7 +213,7 @@ public final class SettingsCmd {
Bundle arg = new Bundle();
arg.putString(Settings.NameValueTable.VALUE, value);
arg.putInt(Settings.CALL_METHOD_USER_KEY, userHandle);
- provider.call(null, callPutCommand, key, arg);
+ provider.call(resolveCallingPackage(), callPutCommand, key, arg);
} catch (RemoteException e) {
System.err.println("Can't set key " + key + " in " + table + " for user " + userHandle);
}
@@ -232,7 +232,7 @@ public final class SettingsCmd {
int num = 0;
try {
- num = provider.delete(null, targetUri, null, null);
+ num = provider.delete(resolveCallingPackage(), targetUri, null, null);
} catch (RemoteException e) {
System.err.println("Can't clear key " + key + " in " + table + " for user "
+ userHandle);
@@ -247,4 +247,20 @@ public final class SettingsCmd {
System.err.println("\n'namespace' is one of {system, secure, global}, case-insensitive");
System.err.println("If '--user NUM' is not given, the operations are performed on the owner user.");
}
+
+ public static String resolveCallingPackage() {
+ switch (android.os.Process.myUid()) {
+ case Process.ROOT_UID: {
+ return "root";
+ }
+
+ case Process.SHELL_UID: {
+ return "com.android.shell";
+ }
+
+ default: {
+ return null;
+ }
+ }
+ }
}