Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Public Release 0.1

  • Loading branch information...
commit b334e37974d18a0051b6cf787faedae9bc0da854 0 parents
@rpetrich authored
2  .gitignore
@@ -0,0 +1,2 @@
+.theos
+*.deb
3  .gitmodules
@@ -0,0 +1,3 @@
+[submodule "framework"]
+ path = framework
+ url = git://github.com/rpetrich/theos.git
9 Makefile
@@ -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
1  framework
@@ -0,0 +1 @@
+Subproject commit 51ede74b96aea9b21f54e0b0d812179814edfdac
9 layout/DEBIAN/control
@@ -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>
7 layout/DEBIAN/postinst
@@ -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
3  layout/DEBIAN/prerm
@@ -0,0 +1,3 @@
+#!/bin/sh
+/bin/launchctl unload /Library/LaunchDaemons/com.rpetrich.untrackerd.plist
+exit 0
19 layout/Library/LaunchDaemons/com.rpetrich.untrackerd.plist
@@ -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>
62 untrackerd.c
@@ -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;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.