Skip to content

Commit ff69042

Browse files
authored
Increase test portability (#1247)
2 parents 6c85a21 + cb95dd9 commit ff69042

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/common/resolve.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,10 @@ mod test {
369369
fn canonicalization() {
370370
assert_eq!(canonicalize("/").unwrap(), Path::new("/"));
371371
assert!(canonicalize("").is_err());
372-
if cfg!(any(target_os = "linux", target_os = "macos")) {
373-
// this test REQUIRES /usr/bin/unxz to be a symlink for /usr/bin/xz
372+
if cfg!(any(target_os = "linux")) {
373+
// this test REQUIRES /usr/bin/unxz to be a symlink for /usr/bin/xz or /usr/bin/busybox
374+
assert!(Path::new("/bin").is_symlink());
375+
assert!(Path::new("/usr/bin/unxz").is_symlink());
374376
assert_eq!(
375377
canonicalize("/usr/bin/unxz").unwrap(),
376378
Path::new("/usr/bin/unxz")
@@ -381,7 +383,8 @@ mod test {
381383
Path::new("/usr/bin/unxz")
382384
);
383385
} else if cfg!(target_os = "freebsd") {
384-
// this test REQUIRES /usr/bin/pkill to be a symlink for /usr/bin/pgrep
386+
// this test REQUIRES /usr/bin/pkill to be a symlink
387+
assert!(Path::new("/usr/bin/pkill").is_symlink());
385388
assert_eq!(
386389
canonicalize("/usr/bin/pkill").unwrap(),
387390
Path::new("/usr/bin/pkill")

src/system/audit.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![cfg_attr(not(feature = "sudoedit"), allow(dead_code))]
2+
use std::collections::HashSet;
23
use std::ffi::{CStr, CString};
34
use std::fs::{DirBuilder, File, Metadata, OpenOptions};
45
use std::io::{self, Error, ErrorKind};
@@ -50,10 +51,7 @@ pub(crate) fn sudo_call<T>(
5051
if cfg!(test)
5152
&& target_user.uid == cur_user_id
5253
&& target_group.gid == cur_group_id
53-
&& target_groups
54-
.iter()
55-
.filter(|x| **x != target_group.gid)
56-
.eq(cur_groups.iter().filter(|x| **x != cur_group_id))
54+
&& target_groups.iter().collect::<HashSet<_>>() == cur_groups.iter().collect::<HashSet<_>>()
5755
{
5856
// we are not actually switching users, simply run the closure
5957
// (this would also be safe in production mode, but it is a needless check)

0 commit comments

Comments
 (0)