@@ -489,7 +489,7 @@ fn directory(paths: &[OsString], b: &Behavior) -> UResult<()> {
489489 }
490490
491491 // Set SELinux context for all created directories if needed
492- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
492+ #[ cfg( all( feature = "selinux" , any ( target_os = "linux" , target_os = "android" ) ) ) ]
493493 if should_set_selinux_context ( b) {
494494 let context = get_context_for_selinux ( b) ;
495495 set_selinux_context_for_directories_install ( path_to_create. as_path ( ) , context) ;
@@ -514,7 +514,7 @@ fn directory(paths: &[OsString], b: &Behavior) -> UResult<()> {
514514 show_if_err ! ( chown_optional_user_group( path, b) ) ;
515515
516516 // Set SELinux context for directory if needed
517- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
517+ #[ cfg( all( feature = "selinux" , any ( target_os = "linux" , target_os = "android" ) ) ) ]
518518 if b. default_context {
519519 show_if_err ! ( set_selinux_default_context( path) ) ;
520520 } else if b. context . is_some ( ) {
@@ -683,7 +683,10 @@ fn standard(mut paths: Vec<OsString>, b: &Behavior) -> UResult<()> {
683683 }
684684
685685 // Set SELinux context for all created directories if needed
686- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
686+ #[ cfg( all(
687+ feature = "selinux" ,
688+ any( target_os = "linux" , target_os = "android" )
689+ ) ) ]
687690 if should_set_selinux_context ( b) {
688691 let context = get_context_for_selinux ( b) ;
689692 set_selinux_context_for_directories_install ( to_create, context) ;
@@ -717,7 +720,10 @@ fn standard(mut paths: Vec<OsString>, b: &Behavior) -> UResult<()> {
717720 }
718721
719722 // Set SELinux context for all created directories if needed
720- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
723+ #[ cfg( all(
724+ feature = "selinux" ,
725+ any( target_os = "linux" , target_os = "android" )
726+ ) ) ]
721727 if should_set_selinux_context ( b) {
722728 let context = get_context_for_selinux ( b) ;
723729 set_selinux_context_for_directories_install ( to_create, context) ;
@@ -1090,7 +1096,7 @@ fn finalize_installed_file(
10901096 preserve_timestamps ( from, to) ?;
10911097 }
10921098
1093- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
1099+ #[ cfg( all( feature = "selinux" , any ( target_os = "linux" , target_os = "android" ) ) ) ]
10941100 if b. privileged {
10951101 if b. preserve_context {
10961102 uucore:: selinux:: preserve_security_context ( from, to)
@@ -1154,7 +1160,7 @@ fn get_context_for_selinux(b: &Behavior) -> Option<&String> {
11541160 }
11551161}
11561162
1157- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
1163+ #[ cfg( all( feature = "selinux" , any ( target_os = "linux" , target_os = "android" ) ) ) ]
11581164fn should_set_selinux_context ( b : & Behavior ) -> bool {
11591165 b. privileged && ( b. context . is_some ( ) || b. default_context )
11601166}
@@ -1250,7 +1256,7 @@ fn need_copy(from: &Path, to: &Path, b: &Behavior) -> bool {
12501256 }
12511257
12521258 if b. privileged {
1253- #[ cfg( all( feature = "selinux" , target_os = "linux" ) ) ]
1259+ #[ cfg( all( feature = "selinux" , any ( target_os = "linux" , target_os = "android" ) ) ) ]
12541260 if b. preserve_context && contexts_differ ( from, to) {
12551261 return true ;
12561262 }
0 commit comments