@@ -12,6 +12,16 @@ use crate::sealed::Sealed;
12
12
use crate :: sys;
13
13
use crate :: sys_common:: { AsInner , AsInnerMut , FromInner , IntoInner } ;
14
14
15
+ #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
16
+ type UserId = u32 ;
17
+ #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
18
+ type GroupId = u32 ;
19
+
20
+ #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ]
21
+ type UserId = u16 ;
22
+ #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ]
23
+ type GroupId = u16 ;
24
+
15
25
/// Unix-specific extensions to the [`process::Command`] builder.
16
26
///
17
27
/// This trait is sealed: it cannot be implemented outside the standard library.
@@ -22,32 +32,17 @@ pub trait CommandExt: Sealed {
22
32
/// `setuid` call in the child process. Failure in the `setuid`
23
33
/// call will cause the spawn to fail.
24
34
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
25
- fn uid (
26
- & mut self ,
27
- #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
28
- id : u32 ,
29
- #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ] id : u16 ,
30
- ) -> & mut process:: Command ;
35
+ fn uid ( & mut self , id : UserId ) -> & mut process:: Command ;
31
36
32
37
/// Similar to `uid`, but sets the group ID of the child process. This has
33
38
/// the same semantics as the `uid` field.
34
39
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
35
- fn gid (
36
- & mut self ,
37
- #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
38
- id : u32 ,
39
- #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ] id : u16 ,
40
- ) -> & mut process:: Command ;
40
+ fn gid ( & mut self , id : GroupId ) -> & mut process:: Command ;
41
41
42
42
/// Sets the supplementary group IDs for the calling process. Translates to
43
43
/// a `setgroups` call in the child process.
44
44
#[ unstable( feature = "setgroups" , issue = "90747" ) ]
45
- fn groups (
46
- & mut self ,
47
- #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ] groups : & [ u32 ] ,
48
- #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ]
49
- groups : & [ u16 ] ,
50
- ) -> & mut process:: Command ;
45
+ fn groups ( & mut self , groups : & [ GroupId ] ) -> & mut process:: Command ;
51
46
52
47
/// Schedules a closure to be run just before the `exec` function is
53
48
/// invoked.
@@ -161,32 +156,17 @@ pub trait CommandExt: Sealed {
161
156
162
157
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
163
158
impl CommandExt for process:: Command {
164
- fn uid (
165
- & mut self ,
166
- #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
167
- id : u32 ,
168
- #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ] id : u16 ,
169
- ) -> & mut process:: Command {
159
+ fn uid ( & mut self , id : UserId ) -> & mut process:: Command {
170
160
self . as_inner_mut ( ) . uid ( id) ;
171
161
self
172
162
}
173
163
174
- fn gid (
175
- & mut self ,
176
- #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ]
177
- id : u32 ,
178
- #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ] id : u16 ,
179
- ) -> & mut process:: Command {
164
+ fn gid ( & mut self , id : GroupId ) -> & mut process:: Command {
180
165
self . as_inner_mut ( ) . gid ( id) ;
181
166
self
182
167
}
183
168
184
- fn groups (
185
- & mut self ,
186
- #[ cfg( not( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ) ] groups : & [ u32 ] ,
187
- #[ cfg( any( target_os = "vxworks" , target_os = "espidf" , target_os = "horizon" ) ) ]
188
- groups : & [ u16 ] ,
189
- ) -> & mut process:: Command {
169
+ fn groups ( & mut self , groups : & [ GroupId ] ) -> & mut process:: Command {
190
170
self . as_inner_mut ( ) . groups ( groups) ;
191
171
self
192
172
}
0 commit comments