blob: e57d7bff3872c09567ce8907121b7d6e886063dd [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 bigbiff731df792014-02-20 18:26:13 -050034 int fixContextsRecursively(std::string path, int level);
bigbiff bigbiff872a3b92013-10-18 20:50:25 -040035
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040036 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_Troy201d76b2012-11-16 17:12:02 +000048 bool multi_user;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040049 package* head;
bigbiff bigbiff6b600f92014-01-05 18:13:43 -050050 package* temp;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040051 string packageFile;
52};