summaryrefslogtreecommitdiffstats
path: root/gatekeeperd
diff options
context:
space:
mode:
authorAndres Morales <anmorales@google.com>2015-04-17 09:00:28 -0700
committerAndres Morales <anmorales@google.com>2015-04-17 09:01:41 -0700
commitdcb3fbdaa4bf5eca7b6a07689871e4e8f631070c (patch)
tree037fed8bff51641c76114da6d3e0d31b9c7f035d /gatekeeperd
parent44dd33a2eff721d1c8989e6f70e18fad570b792a (diff)
downloadsystem_core-dcb3fbdaa4bf5eca7b6a07689871e4e8f631070c.zip
system_core-dcb3fbdaa4bf5eca7b6a07689871e4e8f631070c.tar.gz
system_core-dcb3fbdaa4bf5eca7b6a07689871e4e8f631070c.tar.bz2
Make clear SID delete the file
This allows us to recover in situations where we manage to clear the SID in GateKeeper but fail to remove the password in LockSettingsService. Change-Id: Ib64ead137632f9615745a414c90a9b66b847134f
Diffstat (limited to 'gatekeeperd')
-rw-r--r--gatekeeperd/gatekeeperd.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/gatekeeperd/gatekeeperd.cpp b/gatekeeperd/gatekeeperd.cpp
index a242504..75cd225 100644
--- a/gatekeeperd/gatekeeperd.cpp
+++ b/gatekeeperd/gatekeeperd.cpp
@@ -63,7 +63,7 @@ public:
sprintf(filename, "%u", uid);
int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
if (fd < 0) {
- ALOGW("could not open file: %s: %s", filename, strerror(errno));
+ ALOGE("could not open file: %s: %s", filename, strerror(errno));
return;
}
write(fd, &sid, sizeof(sid));
@@ -88,6 +88,15 @@ public:
return sid;
}
+ void clear_sid(uint32_t uid) {
+ char filename[21];
+ sprintf(filename, "%u", uid);
+ if (remove(filename) < 0) {
+ ALOGE("%s: could not remove file [%s], attempting 0 write", __func__, strerror(errno));
+ store_sid(uid, 0);
+ }
+ }
+
virtual status_t enroll(uint32_t uid,
const uint8_t *current_password_handle, uint32_t current_password_handle_length,
const uint8_t *current_password, uint32_t current_password_length,
@@ -181,7 +190,7 @@ public:
ALOGE("%s: permission denied for [%d:%d]", __func__, calling_pid, calling_uid);
return;
}
- store_sid(uid, 0);
+ clear_sid(uid);
}
virtual status_t dump(int fd, const Vector<String16> &) {