diff options
author | Jay Freeman (saurik) <saurik@saurik.com> | 2015-07-02 14:12:35 -0700 |
---|---|---|
committer | Jay Freeman (saurik) <saurik@saurik.com> | 2015-07-02 14:12:35 -0700 |
commit | d78cda50503c66b044150c9ced5a2a4a8c9607dd (patch) | |
tree | 24b92bf5c7ebe0bd318a3704a403210bade1491d /MobileCydia.mm | |
parent | 195c97b3e2fecc62d78780bee0446d62c1f9b3ad (diff) |
Avoid overwriting extended_states with a symlink.
Diffstat (limited to 'MobileCydia.mm')
-rw-r--r-- | MobileCydia.mm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/MobileCydia.mm b/MobileCydia.mm index 968a67a..86e6a6f 100644 --- a/MobileCydia.mm +++ b/MobileCydia.mm @@ -4089,11 +4089,17 @@ class CydiaLogCleaner : delock_ = nil; + pkgPackageManager::OrderResult result(manager_->DoInstall(statusfd_)); + NSString *oextended(@"/var/lib/apt/extended_states"); NSString *nextended(Cache("extended_states")); - pkgPackageManager::OrderResult result(manager_->DoInstall(statusfd_)); - system([[NSString stringWithFormat:@"/usr/libexec/cydia/cydo /bin/mv -f %@ %@", nextended, oextended] UTF8String]); - system([[NSString stringWithFormat:@"/usr/libexec/cydia/cydo /bin/chown 0:0 %@", oextended] UTF8String]); + + struct stat info; + if (stat([nextended UTF8String], &info) != -1 && (info.st_mode & S_IFMT) == S_IFREG) { + system([[NSString stringWithFormat:@"/usr/libexec/cydia/cydo /bin/mv -f %@ %@", nextended, oextended] UTF8String]); + system([[NSString stringWithFormat:@"/usr/libexec/cydia/cydo /bin/chown 0:0 %@", oextended] UTF8String]); + } + unlink([nextended UTF8String]); symlink([oextended UTF8String], [nextended UTF8String]); |