@@ -45,6 +45,7 @@ use serde::{Deserialize, Serialize};
4545
4646use self :: baseline:: InstallBlockDeviceOpts ;
4747use crate :: containerenv:: ContainerExecutionInfo ;
48+ use crate :: lsm;
4849use crate :: mount:: Filesystem ;
4950use crate :: spec:: ImageReference ;
5051use crate :: store:: Storage ;
@@ -525,15 +526,9 @@ impl SourceInfo {
525526 Self :: new ( imageref, None , root, false , false )
526527 }
527528
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 > {
536530 let cancellable = ostree:: gio:: Cancellable :: NONE ;
531+
537532 let commit = Task :: new ( "Reading ostree commit" , "ostree" )
538533 . args ( [ "--repo=/ostree/repo" , "rev-parse" , "--single" ] )
539534 . quiet ( )
@@ -545,7 +540,22 @@ impl SourceInfo {
545540 . 0 ;
546541 let root = root. downcast_ref :: < ostree:: RepoFile > ( ) . unwrap ( ) ;
547542 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+ } ;
549559 Ok ( Self {
550560 imageref,
551561 digest,
0 commit comments