bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 1 | #include <iostream> |
| 2 | #include <fstream> |
| 3 | #include <sstream> |
| 4 | #include <string> |
| 5 | #include <vector> |
| 6 | #include <string.h> |
| 7 | #include <libgen.h> |
| 8 | #include <unistd.h> |
| 9 | #include <sys/stat.h> |
| 10 | #include <dirent.h> |
bigbiff bigbiff | 84a3f1a | 2013-12-28 18:32:15 -0500 | [diff] [blame] | 11 | #include <errno.h> |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 12 | #include "gui/rapidxml.hpp" |
| 13 | #include "twrp-functions.hpp" |
| 14 | |
| 15 | using namespace std; |
| 16 | |
| 17 | class fixPermissions { |
| 18 | public: |
that | a3d31fb | 2014-12-21 22:27:40 +0100 | [diff] [blame] | 19 | fixPermissions(); |
| 20 | ~fixPermissions(); |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 21 | int fixPerms(bool enable_debug, bool remove_data_for_missing_apps); |
that | a3d31fb | 2014-12-21 22:27:40 +0100 | [diff] [blame] | 22 | int fixContexts(); |
bigbiff bigbiff | 6b600f9 | 2014-01-05 18:13:43 -0500 | [diff] [blame] | 23 | int fixDataInternalContexts(void); |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 24 | |
| 25 | private: |
that | a3d31fb | 2014-12-21 22:27:40 +0100 | [diff] [blame] | 26 | int pchown(string fn, int puid, int pgid); |
| 27 | int pchmod(string fn, mode_t mode); |
| 28 | vector <string> listAllDirectories(string path); |
| 29 | vector <string> listAllFiles(string path); |
| 30 | void deletePackages(); |
| 31 | int getPackages(const string& packageFile); |
| 32 | int fixApps(); |
| 33 | int fixAllFiles(string directory, int uid, int gid, mode_t file_perms); |
| 34 | int fixDir(const string& dir, int diruid, int dirgid, mode_t dirmode, int fileuid, int filegid, mode_t filemode); |
Dees_Troy | 201d76b | 2012-11-16 17:12:02 +0000 | [diff] [blame] | 35 | int fixDataData(string dataDir); |
that | a3d31fb | 2014-12-21 22:27:40 +0100 | [diff] [blame] | 36 | int restorecon(string entry, struct stat *sb); |
bigbiff bigbiff | 6b600f9 | 2014-01-05 18:13:43 -0500 | [diff] [blame] | 37 | int fixDataDataContexts(void); |
that | a3d31fb | 2014-12-21 22:27:40 +0100 | [diff] [blame] | 38 | int fixContextsRecursively(string path, int level); |
bigbiff bigbiff | 872a3b9 | 2013-10-18 20:50:25 -0400 | [diff] [blame] | 39 | |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 40 | struct package { |
| 41 | string pkgName; |
| 42 | string codePath; |
| 43 | string appDir; |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 44 | string dDir; |
| 45 | int gid; |
| 46 | int uid; |
| 47 | package *next; |
| 48 | }; |
| 49 | bool debug; |
| 50 | bool remove_data; |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 51 | package* head; |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 52 | }; |