blob: f61a9a17237393f94c45cefd6a6de8d40662c432 [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:
thata3d31fb2014-12-21 22:27:40 +010019 fixPermissions();
20 ~fixPermissions();
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040021 int fixPerms(bool enable_debug, bool remove_data_for_missing_apps);
thata3d31fb2014-12-21 22:27:40 +010022 int fixContexts();
bigbiff bigbiff6b600f92014-01-05 18:13:43 -050023 int fixDataInternalContexts(void);
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040024
25 private:
thata3d31fb2014-12-21 22:27:40 +010026 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_Troy201d76b2012-11-16 17:12:02 +000035 int fixDataData(string dataDir);
thata3d31fb2014-12-21 22:27:40 +010036 int restorecon(string entry, struct stat *sb);
bigbiff bigbiff6b600f92014-01-05 18:13:43 -050037 int fixDataDataContexts(void);
thata3d31fb2014-12-21 22:27:40 +010038 int fixContextsRecursively(string path, int level);
bigbiff bigbiff872a3b92013-10-18 20:50:25 -040039
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040040 struct package {
41 string pkgName;
42 string codePath;
43 string appDir;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040044 string dDir;
45 int gid;
46 int uid;
47 package *next;
48 };
49 bool debug;
50 bool remove_data;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040051 package* head;
bigbiff bigbiffa0f8a592012-10-09 21:01:03 -040052};