mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
reduce usage of nix::unistd::geteuid
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) agroupthatdoesntexist auserthatdoesntexist cuuser groupname notexisting passgrp
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
use uucore::process::geteuid;
|
||||
use uutests::util::{CmdResult, TestScenario, is_ci, run_ucmd_as_root};
|
||||
use uutests::util_name;
|
||||
use uutests::{at_and_ucmd, new_ucmd};
|
||||
@@ -750,7 +748,7 @@ fn test_root_preserve() {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[test]
|
||||
fn test_big_p() {
|
||||
if geteuid() != 0 {
|
||||
if !rustix::process::geteuid().is_root() {
|
||||
new_ucmd!()
|
||||
.arg("-RP")
|
||||
.arg("bin")
|
||||
|
||||
@@ -12,7 +12,7 @@ use jiff::tz::TimeZone;
|
||||
use jiff::{Timestamp, ToSpan};
|
||||
use regex::Regex;
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
use uucore::process::geteuid;
|
||||
use rustix::process::geteuid;
|
||||
use uutests::util::TestScenario;
|
||||
#[cfg(unix)]
|
||||
use uutests::util::is_locale_available;
|
||||
@@ -425,7 +425,7 @@ fn test_date_format_literal() {
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn test_date_set_valid() {
|
||||
if geteuid() == 0 {
|
||||
if geteuid().is_root() {
|
||||
new_ucmd!()
|
||||
.arg("--set")
|
||||
.arg("2020-03-12 13:30:00+08:00")
|
||||
@@ -446,7 +446,7 @@ fn test_date_set_invalid() {
|
||||
#[test]
|
||||
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
|
||||
fn test_date_set_permissions_error() {
|
||||
if !(geteuid() == 0 || uucore::os::is_wsl_1()) {
|
||||
if !(geteuid().is_root() || uucore::os::is_wsl_1()) {
|
||||
let result = new_ucmd!()
|
||||
.arg("--set")
|
||||
.arg("2020-03-11 21:45:00+08:00")
|
||||
@@ -460,7 +460,7 @@ fn test_date_set_permissions_error() {
|
||||
#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
|
||||
fn test_date_set_hyphen_prefixed_values() {
|
||||
// test -s flag accepts hyphen-prefixed values like "-3 days"
|
||||
if !(geteuid() == 0 || uucore::os::is_wsl_1()) {
|
||||
if !(geteuid().is_root() || uucore::os::is_wsl_1()) {
|
||||
let test_cases = vec!["-1 hour", "-2 days", "-3 weeks", "-1 month"];
|
||||
|
||||
for date_str in test_cases {
|
||||
@@ -494,7 +494,7 @@ fn test_date_set_mac_unavailable() {
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn test_date_set_valid_2() {
|
||||
if geteuid() == 0 {
|
||||
if geteuid().is_root() {
|
||||
new_ucmd!()
|
||||
.arg("--set")
|
||||
.arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line
|
||||
@@ -575,7 +575,7 @@ fn test_date_for_file_mtime() {
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn test_date_set_valid_3() {
|
||||
if geteuid() == 0 {
|
||||
if geteuid().is_root() {
|
||||
new_ucmd!()
|
||||
.arg("--set")
|
||||
.arg("Sat 20 Mar 2021 14:53:01") // Local timezone
|
||||
@@ -588,7 +588,7 @@ fn test_date_set_valid_3() {
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
fn test_date_set_valid_4() {
|
||||
if geteuid() == 0 {
|
||||
if geteuid().is_root() {
|
||||
new_ucmd!()
|
||||
.arg("--set")
|
||||
.arg("2020-03-11 21:45:00") // Local timezone
|
||||
|
||||
Reference in New Issue
Block a user