Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Fix salt with restricted SERIAL
Browse files Browse the repository at this point in the history
Refs #1661
  • Loading branch information
M66B committed May 28, 2014
1 parent b5e3a5c commit 585e002
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ protected void onCreate(Bundle savedInstanceState) {
if (getIntent().getAction().equals(Intent.ACTION_VIEW))
Util.importProLicense(new File(getIntent().getData().getEncodedPath()));

// Delete legacy salt
String salt = PrivacyManager.getSetting(userId, PrivacyManager.cSettingSalt, null, false);
if (salt != null && salt.equals(PrivacyManager.getSalt(userId)))
PrivacyManager.setSetting(userId, PrivacyManager.cSettingSalt, null);

// Set layout
setContentView(R.layout.mainlist);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Expand Down
1 change: 1 addition & 0 deletions src/biz/bokhorst/xprivacy/Meta.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Meta {
private static List<Hook> mListHook = new ArrayList<Hook>();

public final static String cTypeAccount = "Account";
public final static String cTypeAccountHash = "AccountHash";
public final static String cTypeApplication = "Application";
public final static String cTypeContact = "Contact";
public final static String cTypeTemplate = "Template";
Expand Down
2 changes: 1 addition & 1 deletion src/biz/bokhorst/xprivacy/PrivacyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public class PrivacyManager {
public final static String cSettingSortInverted = "SortInverted";
public final static String cSettingModifyTime = "ModifyTime";
public final static String cSettingTheme = "Theme";
private final static String cSettingSalt = "Salt";
public final static String cSettingSalt = "Salt";
public final static String cSettingVersion = "Version";
public final static String cSettingFirstRun = "FirstRun";
public final static String cSettingTutorialMain = "TutorialMain";
Expand Down
7 changes: 7 additions & 0 deletions src/biz/bokhorst/xprivacy/PrivacyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,13 @@ else if (uid != setting.uid)
@SuppressLint("DefaultLocale")
public PSetting getSetting(PSetting setting) throws RemoteException {
int userId = Util.getUserId(setting.uid);
if (Meta.cTypeAccountHash.equals(setting.type))
try {
setting.type = Meta.cTypeAccount;
setting.value = Util.sha1(setting.value);
} catch (Throwable ex) {
Util.bug(null, ex);
}
PSetting result = new PSetting(setting.uid, setting.type, setting.name, setting.value);

try {
Expand Down
3 changes: 1 addition & 2 deletions src/biz/bokhorst/xprivacy/XAccountManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ private boolean isAccountAllowed(Account account, int uid) {

private boolean isAccountAllowed(String accountName, String accountType, int uid) {
try {
String sha1 = Util.sha1(accountName + accountType);
if (PrivacyManager.getSettingBool(-uid, Meta.cTypeAccount, sha1, false, true))
if (PrivacyManager.getSettingBool(-uid, Meta.cTypeAccountHash, accountName + accountType, false, true))
return true;
} catch (Throwable ex) {
Util.bug(this, ex);
Expand Down

0 comments on commit 585e002

Please sign in to comment.