blob: 48a52074e3cf334404b2ee57a06269c9d53fc4ba [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);
bigbiff bigbiff6b600f92014-01-05 18:13:43 -050020 int fixDataInternalContexts(void);
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040021
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 bigbiffa0f8a592012-10-09 21:01:03 -040027 int getPackages();
28 int fixSystemApps();
29 int fixDataApps();
30 int fixAllFiles(string directory, int gid, int uid, string file_perms);
Dees_Troy201d76b2012-11-16 17:12:02 +000031 int fixDataData(string dataDir);
bigbiff bigbiff872a3b92013-10-18 20:50:25 -040032 int restorecon(std::string entry, struct stat *sb);
bigbiff bigbiff6b600f92014-01-05 18:13:43 -050033 int fixDataDataContexts(void);
bigbiff bigbiff872a3b92013-10-18 20:50:25 -040034
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040035 struct package {
36 string pkgName;
37 string codePath;
38 string appDir;
39 string app;
40 string dDir;
41 int gid;
42 int uid;
43 package *next;
44 };
45 bool debug;
46 bool remove_data;
Dees_Troy201d76b2012-11-16 17:12:02 +000047 bool multi_user;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040048 package* head;
bigbiff bigbiff6b600f92014-01-05 18:13:43 -050049 package* temp;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040050 string packageFile;
51};