blob: 6439dac609b8c56c86ecd890e0a5cf2cdf76c640 [file] [log] [blame]
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -04001#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 bigbiff84a3f1a2013-12-28 18:32:15 -050011#include <errno.h>
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040012#include "gui/rapidxml.hpp"
13#include "twrp-functions.hpp"
14
15using namespace std;
16
17class fixPermissions {
18 public:
19 int fixPerms(bool enable_debug, bool remove_data_for_missing_apps);
20
21 private:
22 int pchown(std::string fn, int puid, int pgid);
23 int pchmod(std::string fn, string mode);
24 vector <string> listAllDirectories(std::string path);
25 vector <string> listAllFiles(std::string path);
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040026 int getPackages();
27 int fixSystemApps();
28 int fixDataApps();
29 int fixAllFiles(string directory, int gid, int uid, string file_perms);
Dees_Troy201d76b2012-11-16 17:12:02 +000030 int fixDataData(string dataDir);
bigbiff bigbiff872a3b92013-10-18 20:50:25 -040031 int fixDataDataContexts(void);
32 int restorecon(std::string entry, struct stat *sb);
33
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040034 struct package {
35 string pkgName;
36 string codePath;
37 string appDir;
38 string app;
39 string dDir;
40 int gid;
41 int uid;
42 package *next;
43 };
44 bool debug;
45 bool remove_data;
Dees_Troy201d76b2012-11-16 17:12:02 +000046 bool multi_user;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040047 package* head;
48 package* temp;
49 string packageFile;
50};