Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b334e37
Showing
9 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.theos | ||
*.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "framework"] | ||
path = framework | ||
url = git://github.com/rpetrich/theos.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
TOOL_NAME = untrackerd | ||
untrackerd_FILES = untrackerd.c | ||
untrackerd_FRAMEWORKS = CoreFoundation | ||
untrackerd_LDFLAGS = -lsqlite3 -Wl,-stack_size,1000 | ||
|
||
ADDITIONAL_CFLAGS = -std=c99 | ||
|
||
include framework/makefiles/common.mk | ||
include framework/makefiles/tool.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Package: com.rpetrich.untrackerd | ||
Priority: optional | ||
Section: System | ||
Architecture: iphoneos-arm | ||
Version: 0.1 | ||
Description: Continuously clean up locationd's history data | ||
Name: untrackerd | ||
Depends: firmware (>= 4.0) | ||
Author: Ryan Petrich <rpetrich+untrackerd@gmail.com> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
chown root:wheel /usr/bin/untrackerd | ||
chmod 755 /usr/bin/untrackerd | ||
chown root:wheel /Library/LaunchDaemons/com.rpetrich.untrackerd.plist | ||
chmod 644 /Library/LaunchDaemons/com.rpetrich.untrackerd.plist | ||
/bin/launchctl load -w /Library/LaunchDaemons/com.rpetrich.untrackerd.plist | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
/bin/launchctl unload /Library/LaunchDaemons/com.rpetrich.untrackerd.plist | ||
exit 0 |
19 changes: 19 additions & 0 deletions
19
layout/Library/LaunchDaemons/com.rpetrich.untrackerd.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
|
||
<dict> | ||
<key>Label</key> | ||
<string>com.rpetrich.untrackerd</string> | ||
|
||
<key>Program</key> | ||
<string>/usr/bin/untrackerd</string> | ||
|
||
<key>StandardErrorPath</key> | ||
<string>/dev/null</string> | ||
|
||
<key>OnDemand</key> | ||
<false/> | ||
</dict> | ||
|
||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <stdio.h> | ||
#include <CoreFoundation/CoreFoundation.h> | ||
#include <sqlite3.h> | ||
|
||
// untrackerd | ||
// Ryan Petrich | ||
// Continuously clean up locationd's history data | ||
|
||
static inline bool clear_data() | ||
{ | ||
sqlite3 *database = NULL; | ||
// Open Database | ||
int result = sqlite3_open("/var/root/Library/Caches/locationd/consolidated.db", &database); | ||
if (result == SQLITE_OK) { | ||
sqlite3_stmt *statement = NULL; | ||
CFAbsoluteTime time = CFAbsoluteTimeGetCurrent() - (60.0 * 30.0); | ||
// Clear Cell data | ||
result = sqlite3_prepare_v2(database, "DELETE FROM CellLocation WHERE Timestamp < ?;", -1, &statement, NULL); | ||
if (result == SQLITE_OK) { | ||
result = sqlite3_bind_double(statement, 1, time); | ||
if (result == SQLITE_OK) { | ||
do { | ||
result = sqlite3_step(statement); | ||
} while (result == SQLITE_ROW); | ||
} | ||
sqlite3_finalize(statement); | ||
} | ||
// Clear WiFi Data | ||
if (result == SQLITE_DONE) { | ||
result = sqlite3_prepare_v2(database, "DELETE FROM WifiLocation WHERE Timestamp < ?;", -1, &statement, NULL); | ||
if (result == SQLITE_OK) { | ||
result = sqlite3_bind_double(statement, 1, time); | ||
if (result == SQLITE_OK) { | ||
do { | ||
result = sqlite3_step(statement); | ||
} while (result == SQLITE_ROW); | ||
} | ||
sqlite3_finalize(statement); | ||
} | ||
} | ||
// Close Database | ||
sqlite3_close(database); | ||
} | ||
return (result == SQLITE_OK) || (result == SQLITE_DONE); | ||
} | ||
|
||
static void timer_callback(CFRunLoopTimerRef timer, void *info) | ||
{ | ||
clear_data(); | ||
} | ||
|
||
int main(int argc, const char *argv[]) | ||
{ | ||
// Loop ad infinitum | ||
CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), (5.0 * 60.0), 0, 0, &timer_callback, NULL); | ||
CFRunLoopRef loop = CFRunLoopGetCurrent(); | ||
CFRunLoopAddTimer(loop, timer, kCFRunLoopCommonModes); | ||
CFRunLoopRun(); | ||
CFRunLoopRemoveTimer(loop, timer, kCFRunLoopCommonModes); | ||
CFRelease(timer); | ||
return 0; | ||
} |