diff options
-rwxr-xr-x | Library/move.sh | 3 | ||||
-rw-r--r-- | postinst.mm | 29 |
2 files changed, 32 insertions, 0 deletions
diff --git a/Library/move.sh b/Library/move.sh index c0fc10c..98d9986 100755 --- a/Library/move.sh +++ b/Library/move.sh @@ -24,6 +24,9 @@ function mv_() { tmp=$(mktemp -d /var/stash/_.XXXXXX) dst=${tmp}/${src##*/} + chmod 755 "${tmp}" + chown root.admin "${tmp}" + mkdir -- "${dst}" || { rmdir -- "${tmp}" exit 1 diff --git a/postinst.mm b/postinst.mm index a326911..405b317 100644 --- a/postinst.mm +++ b/postinst.mm @@ -24,6 +24,33 @@ void Finish(const char *finish) { fclose(fout); } +static void FixPermissions() { + DIR *stash(opendir("/var/stash")); + if (stash == NULL) + return; + + while (dirent *entry = readdir(stash)) { + const char *folder(entry->d_name); + if (strlen(folder) != 8) + continue; + if (strncmp(folder, "_.", 2) != 0) + continue; + + char path[1024]; + sprintf(path, "/var/stash/%s", folder); + + struct stat stat; + if (lstat(path, &stat) == -1) + continue; + if (!S_ISDIR(stat.st_mode)) + continue; + + chmod(path, 0755); + } + + closedir(stash); +} + #define APPLICATIONS "/Applications" static bool FixApplications() { char target[1024]; @@ -126,6 +153,8 @@ int main(int argc, const char *argv[]) { CydiaWriteSources(); + FixPermissions(); + if (FixApplications()) Finish("restart"); |