aboutsummaryrefslogtreecommitdiffstats
path: root/src/fbuilder/build_home.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbuilder/build_home.c')
-rw-r--r--src/fbuilder/build_home.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/src/fbuilder/build_home.c b/src/fbuilder/build_home.c
index 683009b71..b3ec6cffd 100644
--- a/src/fbuilder/build_home.c
+++ b/src/fbuilder/build_home.c
@@ -23,30 +23,6 @@
23static FileDB *db_skip = NULL; 23static FileDB *db_skip = NULL;
24static FileDB *db_out = NULL; 24static FileDB *db_out = NULL;
25 25
26static void load_whitelist_common(void) {
27 FILE *fp = fopen(SYSCONFDIR "/whitelist-common.inc", "r");
28 if (!fp) {
29 fprintf(stderr, "Error: cannot open whitelist-common.inc\n");
30 exit(1);
31 }
32
33 char buf[MAX_BUF];
34 while (fgets(buf, MAX_BUF, fp)) {
35 if (strncmp(buf, "whitelist ${HOME}/", 18) != 0)
36 continue;
37 char *fn = buf + 18;
38 char *ptr = strchr(buf, '\n');
39 if (!ptr)
40 continue;
41 *ptr = '\0';
42
43 // add the file to skip list
44 db_skip = filedb_add(db_skip, fn);
45 }
46
47 fclose(fp);
48}
49
50void process_home(const char *fname, char *home, int home_len) { 26void process_home(const char *fname, char *home, int home_len) {
51 assert(fname); 27 assert(fname);
52 assert(home); 28 assert(home);
@@ -141,7 +117,7 @@ void process_home(const char *fname, char *home, int home_len) {
141 } 117 }
142 118
143 // skip files and directories in whitelist-common.inc 119 // skip files and directories in whitelist-common.inc
144 if (filedb_find(db_skip, toadd)) { 120 if (strlen(toadd) == 0 || filedb_find(db_skip, toadd)) {
145 if (dir) 121 if (dir)
146 free(dir); 122 free(dir);
147 continue; 123 continue;
@@ -162,7 +138,7 @@ void build_home(const char *fname, FILE *fp) {
162 assert(fname); 138 assert(fname);
163 139
164 // load whitelist common 140 // load whitelist common
165 load_whitelist_common(); 141 db_skip = filedb_load_whitelist(db_skip, "whitelist-common.inc", "whitelist ${HOME}/");
166 142
167 // find user home directory 143 // find user home directory
168 struct passwd *pw = getpwuid(getuid()); 144 struct passwd *pw = getpwuid(getuid());