@@ -23,7 +23,7 @@ mod options {
2323 pub const TYPE : & str = "type" ;
2424 pub const MAJOR : & str = "major" ;
2525 pub const MINOR : & str = "minor" ;
26- pub const SELINUX : & str = "z" ;
26+ pub const SECURITY_CONTEXT : & str = "z" ;
2727 pub const CONTEXT : & str = "context" ;
2828}
2929
@@ -54,10 +54,10 @@ pub struct Config<'a> {
5454
5555 pub dev : dev_t ,
5656
57- /// Set `SELinux` security context.
58- pub set_selinux_context : bool ,
57+ /// Set security context (SELinux/SMACK) .
58+ pub set_security_context : bool ,
5959
60- /// Specific `SELinux` context.
60+ /// Specific security context (SELinux/SMACK) .
6161 pub context : Option < & ' a String > ,
6262}
6363
@@ -88,7 +88,7 @@ fn mknod(file_name: &str, config: Config) -> i32 {
8888
8989 // Apply SELinux context if requested
9090 #[ cfg( feature = "selinux" ) ]
91- if config. set_selinux_context {
91+ if config. set_security_context {
9292 if let Err ( e) = uucore:: selinux:: set_selinux_security_context (
9393 std:: path:: Path :: new ( file_name) ,
9494 config. context ,
@@ -102,16 +102,10 @@ fn mknod(file_name: &str, config: Config) -> i32 {
102102
103103 // Apply SMACK context if requested
104104 #[ cfg( feature = "smack" ) ]
105- if config. set_selinux_context && uucore:: smack:: is_smack_enabled ( ) {
106- if let Some ( ctx) = config. context {
107- if let Err ( e) =
108- uucore:: smack:: set_smack_label_for_path ( std:: path:: Path :: new ( file_name) , ctx)
109- {
110- // if it fails, delete the file
111- let _ = std:: fs:: remove_file ( file_name) ;
112- eprintln ! ( "{}: {}" , uucore:: util_name( ) , e) ;
113- return 1 ;
114- }
105+ if config. set_security_context {
106+ if let Err ( e) = uucore:: smack:: set_smack_label_for_new_file ( file_name, config. context ) {
107+ eprintln ! ( "{}: {}" , uucore:: util_name( ) , e) ;
108+ return 1 ;
115109 }
116110 }
117111
@@ -139,8 +133,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
139133 . get_one :: < String > ( "name" )
140134 . expect ( "Missing argument 'NAME'" ) ;
141135
142- // Extract the SELinux related flags and options
143- let set_selinux_context = matches. get_flag ( options:: SELINUX ) ;
136+ // Extract the security context related flags and options
137+ let set_security_context = matches. get_flag ( options:: SECURITY_CONTEXT ) ;
144138 let context = matches. get_one :: < String > ( options:: CONTEXT ) ;
145139
146140 let dev = match (
@@ -168,7 +162,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
168162 mode,
169163 use_umask,
170164 dev,
171- set_selinux_context : set_selinux_context || context. is_some ( ) ,
165+ set_security_context : set_security_context || context. is_some ( ) ,
172166 context,
173167 } ;
174168
@@ -219,7 +213,7 @@ pub fn uu_app() -> Command {
219213 . value_parser ( value_parser ! ( u64 ) ) ,
220214 )
221215 . arg (
222- Arg :: new ( options:: SELINUX )
216+ Arg :: new ( options:: SECURITY_CONTEXT )
223217 . short ( 'Z' )
224218 . help ( translate ! ( "mknod-help-selinux" ) )
225219 . action ( ArgAction :: SetTrue ) ,
0 commit comments