@@ -45,6 +45,7 @@ use serde::{Deserialize, Serialize};
45
45
46
46
use self :: baseline:: InstallBlockDeviceOpts ;
47
47
use crate :: containerenv:: ContainerExecutionInfo ;
48
+ use crate :: lsm;
48
49
use crate :: mount:: Filesystem ;
49
50
use crate :: spec:: ImageReference ;
50
51
use crate :: store:: Storage ;
@@ -525,15 +526,9 @@ impl SourceInfo {
525
526
Self :: new ( imageref, None , root, false , false )
526
527
}
527
528
528
- /// Construct a new source information structure
529
- fn new (
530
- imageref : ostree_container:: ImageReference ,
531
- digest : Option < String > ,
532
- root : & Dir ,
533
- in_host_mountns : bool ,
534
- have_host_container_storage : bool ,
535
- ) -> Result < Self > {
529
+ fn have_selinux_from_repo ( root : & Dir ) -> Result < bool > {
536
530
let cancellable = ostree:: gio:: Cancellable :: NONE ;
531
+
537
532
let commit = Task :: new ( "Reading ostree commit" , "ostree" )
538
533
. args ( [ "--repo=/ostree/repo" , "rev-parse" , "--single" ] )
539
534
. quiet ( )
@@ -545,7 +540,22 @@ impl SourceInfo {
545
540
. 0 ;
546
541
let root = root. downcast_ref :: < ostree:: RepoFile > ( ) . unwrap ( ) ;
547
542
let xattrs = root. xattrs ( cancellable) ?;
548
- let selinux = crate :: lsm:: xattrs_have_selinux ( & xattrs) ;
543
+ Ok ( crate :: lsm:: xattrs_have_selinux ( & xattrs) )
544
+ }
545
+
546
+ /// Construct a new source information structure
547
+ fn new (
548
+ imageref : ostree_container:: ImageReference ,
549
+ digest : Option < String > ,
550
+ root : & Dir ,
551
+ in_host_mountns : bool ,
552
+ have_host_container_storage : bool ,
553
+ ) -> Result < Self > {
554
+ let selinux = if Path :: new ( "/ostree/repo" ) . try_exists ( ) ? {
555
+ Self :: have_selinux_from_repo ( root) ?
556
+ } else {
557
+ lsm:: have_selinux_policy ( root) ?
558
+ } ;
549
559
Ok ( Self {
550
560
imageref,
551
561
digest,
0 commit comments