This repository was archived by the owner on Jan 6, 2023. It is now read-only.
File tree 6 files changed +93
-0
lines changed
test/functional/file-name-debuginfo
6 files changed +93
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ dist_check_SCRIPTS = \
111
111
test/functional/contentsize-across-versions-includes/test.bats \
112
112
test/functional/delete-no-version-bump/test.bats \
113
113
test/functional/file-name-blacklisted/test.bats \
114
+ test/functional/file-name-debuginfo/test.bats \
114
115
test/functional/format-no-decrement/test.bats \
115
116
test/functional/full-run-delta/test.bats \
116
117
test/functional/full-run/test.bats \
Original file line number Diff line number Diff line change @@ -175,7 +175,9 @@ extern void release_configuration_data(void);
175
175
extern char * config_image_base (void );
176
176
extern char * config_output_dir (void );
177
177
extern char * config_empty_dir (void );
178
+ extern char * config_debuginfo_path (const char * path );
178
179
extern int config_initial_version (void );
180
+ extern bool config_ban_debuginfo (void );
179
181
180
182
extern void read_current_version (char * filename );
181
183
extern void write_new_version (char * filename , int version );
Original file line number Diff line number Diff line change 2
2
emptydir =/var/lib/update/empty/
3
3
imagebase =/var/lib/update/image/
4
4
outputdir =/var/lib/update/www/
5
+
6
+ [Debuginfo]
7
+ banned =true
8
+ lib =/usr/lib/debug/
9
+ src =/usr/src/debug/
Original file line number Diff line number Diff line change @@ -305,6 +305,32 @@ static bool illegal_characters(const char *filename)
305
305
return false;
306
306
}
307
307
308
+ static bool illegal_path (const char * path )
309
+ {
310
+ bool ret = false;
311
+ char * lib ;
312
+ char * src ;
313
+
314
+ lib = config_debuginfo_path ("lib" );
315
+ src = config_debuginfo_path ("src" );
316
+
317
+ // Don't allow debuginfo into the manifests
318
+ if (lib && (strncmp (path , lib , strlen (lib )) == 0 )) {
319
+ ret = true;
320
+ goto out ;
321
+ }
322
+
323
+ if (src && (strncmp (path , src , strlen (src )) == 0 )) {
324
+ ret = true;
325
+ goto out ;
326
+ }
327
+
328
+ out :
329
+ free (lib );
330
+ free (src );
331
+ return ret ;
332
+ }
333
+
308
334
static struct file * add_file (struct manifest * manifest ,
309
335
const char * entry_name ,
310
336
char * sub_filename ,
@@ -314,6 +340,13 @@ static struct file *add_file(struct manifest *manifest,
314
340
GError * err = NULL ;
315
341
struct file * file ;
316
342
343
+ if (config_ban_debuginfo () && illegal_path (sub_filename )) {
344
+ printf ("WARNING: File %s is banned ...skipping.\n" , sub_filename );
345
+ free (sub_filename );
346
+ free (fullname );
347
+ return NULL ;
348
+ }
349
+
317
350
if (illegal_characters (entry_name )) {
318
351
printf ("WARNING: Filename %s includes illegal character(s) ...skipping.\n" , sub_filename );
319
352
free (sub_filename );
Original file line number Diff line number Diff line change @@ -67,6 +67,20 @@ int config_initial_version(void)
67
67
return version ;
68
68
}
69
69
70
+ bool config_ban_debuginfo (void )
71
+ {
72
+ assert (keyfile != NULL );
73
+
74
+ return g_key_file_get_boolean (keyfile , "Debuginfo" , "banned" , NULL );
75
+ }
76
+
77
+ char * config_debuginfo_path (const char * comp )
78
+ {
79
+ assert (keyfile != NULL );
80
+
81
+ return g_key_file_get_value (keyfile , "Debuginfo" , comp , NULL );
82
+ }
83
+
70
84
bool read_configuration_file (char * filename )
71
85
{
72
86
GError * error = NULL ;
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bats
2
+
3
+ # common functions
4
+ load " ../swupdlib"
5
+
6
+ setup () {
7
+ clean_test_dir
8
+ init_test_dir
9
+
10
+ init_server_ini
11
+ set_latest_ver 0
12
+ init_groups_ini os-core
13
+ init_groups_ini test-bundle
14
+
15
+ set_os_release 10 os-core
16
+ track_bundle 10 os-core
17
+ set_os_release 10 test-bundle
18
+ track_bundle 10 test-bundle
19
+
20
+ gen_file_plain 10 test-bundle " /usr/lib/debug/foo"
21
+ gen_file_plain 10 test-bundle " /usr/src/debug/bar"
22
+ gen_file_plain 10 test-bundle " /usr/bin/foobar"
23
+ }
24
+
25
+ @test " debuginfo files pruned" {
26
+ run sudo sh -c " $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3"
27
+ echo " $output "
28
+ # This should not be pruned
29
+ [[ 1 -eq $( grep ' /usr/bin/foobar$' $DIR /www/10/Manifest.test-bundle | wc -l) ]]
30
+ [[ 1 -eq $( grep ' /usr/lib/debug$' $DIR /www/10/Manifest.test-bundle | wc -l) ]]
31
+ [[ 1 -eq $( grep ' /usr/src/debug$' $DIR /www/10/Manifest.test-bundle | wc -l) ]]
32
+ # These should be pruned
33
+ [[ 0 -eq $( grep ' /usr/src/debug/bar$' $DIR /www/10/Manifest.test-bundle | wc -l) ]]
34
+ [[ 0 -eq $( grep ' /usr/lib/debug/foo$' $DIR /www/10/Manifest.test-bundle | wc -l) ]]
35
+
36
+ }
37
+
38
+ # vi: ft=sh ts=8 sw=2 sts=2 et tw=80
You can’t perform that action at this time.
0 commit comments