0

I'm developing a small tweak that changes some files in /var/preferences. Here is my constructor:

%ctor
{
    NSLog(@"\n\n\n Tweak Loading... \n\n\n ");

    NSError *error = [[NSError alloc] init];
    BOOL success = [[NSFileManager defaultManager] copyItemAtPath:somePath toPath:someOtherPath error:&error];
    if (success)
    {
        NSLog(@"\n\n\n Success:) \n\n\n ");
    } else {
        NSLog(@"\n\n\n Failure! \n\n\n ");
    }

    //Method hook initialization
    %init;
}

As /var/preferences/ is not accessible for mobile user the tweak should be loaded in a root process. With a little bit search I found out that wifid has root privileges. So I changed my filter to com.apple.wifid filter for bundle identifiers.

After I restarted wifid daemon nothing happens and the tweak isn't loaded. I thought it's a problem with this specific daemon so I wrote a simple command line tool for test that has a runloop in it (it's just like a launch daemon instead it doesn't have a plist to run at startup). Then I modified the plist to this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Filter</key>
    <dict>
        <key>Executables</key>
        <array>
            <string>myExecutableName</string>
        </array>
    </dict>
</dict>
</plist>

Again nothing happens and the tweak is not loaded. How can I solve this problem? Why doesn't this tweak load in those processes?

Hamed
  • 297
  • 3
  • 21
  • Don't know why your tweak isn't working but why do you even do this in a tweak? The point of tweaks is to change default behaviour of something. In your case it seems that you only need to execute something as root and it doesn't matter from which process. Looks like you will be better off with your own daemon that can have any priviliges you want. – creker Jul 15 '14 at 20:44
  • @creker I just want to get it work for now and then I had plans to convert it to daemon! The code up there isn't all of my code and there are some hooking too. That's why I had to write a tweak. – Hamed Jul 16 '14 at 06:07
  • The problem with wifid has been solved! I changed the filter to `Executables`-`wifid` instead of `Bundles`-`com.apple.wifid`! But the problem still stays with my own executable. Am I wrong somewhere? – Hamed Jul 16 '14 at 06:32

1 Answers1

0

It's a really "dirty" solution to hook into a root process like wifid just for the sake of running a (seemingly) unrelated task as root. Like creker said, you could instead run your task as a LaunchDaemon, or even run your task inside an app that runs as root. Either way makes more sense than hooking into an existing process to do something that does not seem to be related to the process.

epetousis
  • 455
  • 1
  • 4
  • 21