@@ -57,11 +57,17 @@ struct Config {
5757 dev : u64 ,
5858
5959 /// Set security context (SELinux/SMACK).
60- #[ cfg( any( feature = "selinux" , feature = "smack" ) ) ]
60+ #[ cfg( any(
61+ all( feature = "selinux" , any( target_os = "android" , target_os = "linux" ) ) ,
62+ all( feature = "smack" , target_os = "linux" ) ,
63+ ) ) ]
6164 set_security_context : bool ,
6265
6366 /// Specific security context (SELinux/SMACK).
64- #[ cfg( any( feature = "selinux" , feature = "smack" ) ) ]
67+ #[ cfg( any(
68+ all( feature = "selinux" , any( target_os = "android" , target_os = "linux" ) ) ,
69+ all( feature = "smack" , target_os = "linux" ) ,
70+ ) ) ]
6571 context : Option < String > ,
6672}
6773
@@ -96,7 +102,7 @@ fn mknod(file_name: &str, config: Config) -> i32 {
96102 }
97103
98104 // Apply SELinux context if requested
99- #[ cfg( feature = "selinux" ) ]
105+ #[ cfg( all ( feature = "selinux" , any ( target_os = "android" , target_os = "linux" ) ) ) ]
100106 if config. set_security_context {
101107 use std:: io:: Write as _;
102108
@@ -112,7 +118,7 @@ fn mknod(file_name: &str, config: Config) -> i32 {
112118 }
113119
114120 // Apply SMACK context if requested
115- #[ cfg( feature = "smack" ) ]
121+ #[ cfg( all ( feature = "smack" , target_os = "linux" ) ) ]
116122 if config. set_security_context {
117123 use std:: io:: Write as _;
118124
@@ -150,9 +156,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
150156 . expect ( "Missing argument 'NAME'" ) ;
151157
152158 // Extract the security context related flags and options
153- #[ cfg( any( feature = "selinux" , feature = "smack" ) ) ]
159+ #[ cfg( any(
160+ all( feature = "selinux" , any( target_os = "android" , target_os = "linux" ) ) ,
161+ all( feature = "smack" , target_os = "linux" ) ,
162+ ) ) ]
154163 let set_security_context = matches. get_flag ( options:: SECURITY_CONTEXT ) ;
155- #[ cfg( any( feature = "selinux" , feature = "smack" ) ) ]
164+ #[ cfg( any(
165+ all( feature = "selinux" , any( target_os = "android" , target_os = "linux" ) ) ,
166+ all( feature = "smack" , target_os = "linux" ) ,
167+ ) ) ]
156168 let context = matches. get_one :: < String > ( options:: CONTEXT ) . cloned ( ) ;
157169
158170 let dev = match (
@@ -181,9 +193,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
181193 file_type : file_type. clone ( ) ,
182194 use_umask,
183195 dev,
184- #[ cfg( any( feature = "selinux" , feature = "smack" ) ) ]
196+ #[ cfg( any(
197+ all( feature = "selinux" , any( target_os = "android" , target_os = "linux" ) ) ,
198+ all( feature = "smack" , target_os = "linux" ) ,
199+ ) ) ]
185200 set_security_context : set_security_context || context. is_some ( ) ,
186- #[ cfg( any( feature = "selinux" , feature = "smack" ) ) ]
201+ #[ cfg( any(
202+ all( feature = "selinux" , any( target_os = "android" , target_os = "linux" ) ) ,
203+ all( feature = "smack" , target_os = "linux" ) ,
204+ ) ) ]
187205 context,
188206 } ;
189207
0 commit comments