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: |
| 19 | int fixPerms(bool enable_debug, bool remove_data_for_missing_apps); |
bigbiff bigbiff | 6b600f9 | 2014-01-05 18:13:43 -0500 | [diff] [blame] | 20 | int fixDataInternalContexts(void); |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 21 | |
| 22 | private: |
| 23 | int pchown(std::string fn, int puid, int pgid); |
| 24 | int pchmod(std::string fn, string mode); |
| 25 | vector <string> listAllDirectories(std::string path); |
| 26 | vector <string> listAllFiles(std::string path); |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 27 | int getPackages(); |
| 28 | int fixSystemApps(); |
| 29 | int fixDataApps(); |
| 30 | int fixAllFiles(string directory, int gid, int uid, string file_perms); |
Dees_Troy | 201d76b | 2012-11-16 17:12:02 +0000 | [diff] [blame] | 31 | int fixDataData(string dataDir); |
bigbiff bigbiff | 872a3b9 | 2013-10-18 20:50:25 -0400 | [diff] [blame] | 32 | int restorecon(std::string entry, struct stat *sb); |
bigbiff bigbiff | 6b600f9 | 2014-01-05 18:13:43 -0500 | [diff] [blame] | 33 | int fixDataDataContexts(void); |
bigbiff bigbiff | 731df79 | 2014-02-20 18:26:13 -0500 | [diff] [blame] | 34 | int fixContextsRecursively(std::string path, int level); |
bigbiff bigbiff | 872a3b9 | 2013-10-18 20:50:25 -0400 | [diff] [blame] | 35 | |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 36 | struct package { |
| 37 | string pkgName; |
| 38 | string codePath; |
| 39 | string appDir; |
| 40 | string app; |
| 41 | string dDir; |
| 42 | int gid; |
| 43 | int uid; |
| 44 | package *next; |
| 45 | }; |
| 46 | bool debug; |
| 47 | bool remove_data; |
Dees_Troy | 201d76b | 2012-11-16 17:12:02 +0000 | [diff] [blame] | 48 | bool multi_user; |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 49 | package* head; |
bigbiff bigbiff | 6b600f9 | 2014-01-05 18:13:43 -0500 | [diff] [blame] | 50 | package* temp; |
bigbiff bigbiff | a0f8a59 | 2012-10-09 21:01:03 -0400 | [diff] [blame] | 51 | string packageFile; |
| 52 | }; |