@@ -3,6 +3,7 @@ use std::env;
3
3
use std:: ops:: Deref ;
4
4
5
5
use anyhow:: { Context , Result } ;
6
+ use cap_std_ext:: cap_std;
6
7
use cap_std_ext:: cap_std:: fs:: Dir ;
7
8
use cap_std_ext:: dirext:: CapStdExtDirExt ;
8
9
use clap:: ValueEnum ;
@@ -88,15 +89,18 @@ impl Storage {
88
89
}
89
90
let sysroot_dir = crate :: utils:: sysroot_dir ( & self . sysroot ) ?;
90
91
91
- if self . sysroot . booted_deployment ( ) . is_none ( ) {
92
- anyhow:: bail!( "Not a bootc system (this shouldn't be possible)" ) ;
93
- }
94
-
95
- // load the sepolicy from the booted ostree deployment so the imgstorage can be
96
- // properly labeled with /var/lib/container/storage labels
97
- let dep = self . sysroot . booted_deployment ( ) . unwrap ( ) ;
98
- let dep_fs = deployment_fd ( & self . sysroot , & dep) ?;
99
- let sepolicy = & ostree:: SePolicy :: new_at ( dep_fs. as_raw_fd ( ) , gio:: Cancellable :: NONE ) ?;
92
+ let sepolicy = if self . sysroot . booted_deployment ( ) . is_none ( ) {
93
+ // fallback to policy from container root
94
+ // this should only happen during cleanup of a broken install
95
+ let container_root = Dir :: open_ambient_dir ( "/" , cap_std:: ambient_authority ( ) ) ?;
96
+ & ostree:: SePolicy :: new_at ( container_root. as_raw_fd ( ) , gio:: Cancellable :: NONE ) ?
97
+ } else {
98
+ // load the sepolicy from the booted ostree deployment so the imgstorage can be
99
+ // properly labeled with /var/lib/container/storage labels
100
+ let dep = self . sysroot . booted_deployment ( ) . unwrap ( ) ;
101
+ let dep_fs = deployment_fd ( & self . sysroot , & dep) ?;
102
+ & ostree:: SePolicy :: new_at ( dep_fs. as_raw_fd ( ) , gio:: Cancellable :: NONE ) ?
103
+ } ;
100
104
101
105
let imgstore = crate :: imgstorage:: Storage :: create ( & sysroot_dir, & self . run , Some ( sepolicy) ) ?;
102
106
Ok ( self . imgstore . get_or_init ( || imgstore) )
0 commit comments