X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/b44af625f87066e90b1815ddcc84ee43c5bbce71..8dbbd7d6bc2796cb56b41ae3dade5d85d03ec49b:/MobileCydia.mm diff --git a/MobileCydia.mm b/MobileCydia.mm index 859a2d02..a6d5e892 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -247,11 +247,13 @@ struct Root { root_ = true; _trace(); _assert(setreuid(real ? 0 : 501, 0) != -1); + _assert(setregid(real ? 0 : 501, 0) != -1); } ~Root() { root_ = false; _trace(); + _assert(setregid(501, 501) != -1); _assert(setreuid(501, 501) != -1); } @@ -3815,6 +3817,8 @@ class CydiaLogCleaner : } _end + _root(true) _system->Lock(); + _trace(); OpProgress progress; bool opened; @@ -3850,6 +3854,7 @@ class CydiaLogCleaner : } } + _system->UnLock(); return; } _trace(); @@ -3977,7 +3982,7 @@ class CydiaLogCleaner : - (void) configure { NSString *dpkg = [NSString stringWithFormat:@"dpkg --configure -a --status-fd %u", statusfd_]; _trace(); - system([dpkg UTF8String]); + _root(true) system([dpkg UTF8String]); _trace(); } @@ -4728,7 +4733,7 @@ static _H Diversions_; _assert(close(fds[0]) != -1); _assert(close(fds[1]) != -1); /* XXX: this should probably not use du */ - execl("/usr/libexec/cydia/du", "du", "-s", [path UTF8String], NULL); + _root(true) execl("/usr/libexec/cydia/du", "du", "-s", [path UTF8String], NULL); exit(1); } else { _assert(close(fds[1]) != -1); @@ -5577,7 +5582,7 @@ bool DepSubstrate(const pkgCache::VerIterator &iterator) { pid_t pid(ExecFork()); if (pid == 0) { - execl("/usr/bin/sbreload", "sbreload", NULL); + _root(true) execl("/usr/bin/sbreload", "sbreload", NULL); perror("sbreload"); exit(0); @@ -7920,7 +7925,8 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi pid_t pid(ExecFork()); if (pid == 0) { - FILE *dpkg(popen("dpkg --set-selections", "w")); + FILE *dpkg(nullptr); // XXX: this is due to _root's if + _root(true) dpkg = popen("dpkg --set-selections", "w"); fwrite(package, strlen(package), 1, dpkg); if (on) @@ -9055,7 +9061,7 @@ static void HomeControllerReachabilityCallback(SCNetworkReachabilityRef reachabi } } - CydiaWriteSources(); + _root(true) CydiaWriteSources(); } // Navigation controller for the queuing badge. @@ -10398,7 +10404,7 @@ int main(int argc, char *argv[]) { } broken = nil; /* }}} */ - CydiaWriteSources(); + _root(true) CydiaWriteSources(); _trace(); _root(true) MetaFile_.Open("/var/lib/cydia/metadata.cb0"); @@ -10435,9 +10441,9 @@ int main(int argc, char *argv[]) { int version([[NSString stringWithContentsOfFile:@"/var/lib/cydia/firmware.ver"] intValue]); - _root(true) if (access("/User", F_OK) != 0 || version != 6) { + if (access("/User", F_OK) != 0 || version != 6) { _trace(); - system("/usr/libexec/cydia/firmware.sh"); + _root(true) system("/usr/libexec/cydia/firmware.sh"); _trace(); } @@ -10468,7 +10474,7 @@ int main(int argc, char *argv[]) { mkdir([Cache("lists") UTF8String], 0755); mkdir([Cache("lists/partial") UTF8String], 0755); mkdir([Cache("periodic") UTF8String], 0755); - _config->Set("Dir::State", [Cache_ UTF8String]); + _config->Set("Dir::State::Lists", [Cache("lists") UTF8String]); /* }}} */ /* Color Choices {{{ */ space_ = CGColorSpaceCreateDeviceRGB();