File tree 2 files changed +5
-5
lines changed
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ use std::os::unix::fs::{MetadataExt, PermissionsExt};
19
19
use std:: path:: { Path , PathBuf } ;
20
20
21
21
use error_chain:: { bail, ChainedError } ;
22
- use users:: get_current_uid ;
22
+ use users:: get_effective_uid ;
23
23
24
24
use crate :: errors:: { Result , ResultExt } ;
25
25
@@ -79,7 +79,7 @@ fn ensure_safe_permissions(path: &Path) -> Result<()> {
79
79
80
80
// owned by user or root
81
81
let uid = metadata. uid ( ) ;
82
- if uid != 0 && uid != get_current_uid ( ) {
82
+ if uid != 0 && uid != get_effective_uid ( ) {
83
83
bail ! ( "bad ownership on {}: {}" , path. display( ) , uid) ;
84
84
}
85
85
@@ -218,7 +218,7 @@ mod tests {
218
218
219
219
#[ test]
220
220
fn test_read_keys ( ) {
221
- if get_current_uid ( ) == 0 {
221
+ if get_effective_uid ( ) == 0 {
222
222
panic ! ( "can't run tests as root" ) ;
223
223
}
224
224
Original file line number Diff line number Diff line change @@ -90,15 +90,15 @@ fn run() -> Result<()> {
90
90
mod tests {
91
91
use super :: * ;
92
92
93
- use users:: { get_current_uid , get_current_username } ;
93
+ use users:: { get_current_username , get_effective_uid } ;
94
94
95
95
fn wrap_switch_user ( username : & str ) -> Result < User > {
96
96
switch_user ( & OsString :: from ( username) ) . map ( |( u, _g) | u)
97
97
}
98
98
99
99
#[ test]
100
100
fn test_switch_user ( ) {
101
- if get_current_uid ( ) == 0 {
101
+ if get_effective_uid ( ) == 0 {
102
102
panic ! ( "can't run tests as root" ) ;
103
103
}
104
104
assert_eq ! (
You can’t perform that action at this time.
0 commit comments