Skip to content

Commit

Permalink
Merge pull request #4943 from cakebaker/remove_users_crate
Browse files Browse the repository at this point in the history
Remove users crate
  • Loading branch information
sylvestre authored Jun 4, 2023
2 parents abfceda + 29f011e commit 1895d1b
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 29 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ rlimit = "0.9.1"

[target.'cfg(unix)'.dev-dependencies]
nix = { workspace=true, features=["process", "signal", "user"] }
rust-users = { version="0.11", package="users" }
rand_pcg = "0.3"

[build-dependencies]
Expand Down
12 changes: 6 additions & 6 deletions tests/by-util/test_chgrp.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// spell-checker:ignore (words) nosuchgroup groupname

use crate::common::util::TestScenario;
use rust_users::get_effective_gid;
use uucore::process::getegid;

#[test]
fn test_invalid_option() {
Expand Down Expand Up @@ -53,7 +53,7 @@ fn test_invalid_group() {

#[test]
fn test_1() {
if get_effective_gid() != 0 {
if getegid() != 0 {
new_ucmd!().arg("bin").arg(DIR).fails().stderr_contains(
// linux fails with "Operation not permitted (os error 1)"
// because of insufficient permissions,
Expand All @@ -66,7 +66,7 @@ fn test_1() {

#[test]
fn test_fail_silently() {
if get_effective_gid() != 0 {
if getegid() != 0 {
for opt in ["-f", "--silent", "--quiet", "--sil", "--qui"] {
new_ucmd!()
.arg(opt)
Expand Down Expand Up @@ -137,7 +137,7 @@ fn test_reference() {
// skip for root or MS-WSL
// * MS-WSL is bugged (as of 2019-12-25), allowing non-root accounts su-level privileges for `chgrp`
// * for MS-WSL, succeeds and stdout == 'group of /etc retained as root'
if !(get_effective_gid() == 0 || uucore::os::is_wsl_1()) {
if !(getegid() == 0 || uucore::os::is_wsl_1()) {
new_ucmd!()
.arg("-v")
.arg("--reference=/etc/passwd")
Expand Down Expand Up @@ -203,7 +203,7 @@ fn test_missing_files() {
#[test]
#[cfg(target_os = "linux")]
fn test_big_p() {
if get_effective_gid() != 0 {
if getegid() != 0 {
new_ucmd!()
.arg("-RP")
.arg("bin")
Expand All @@ -218,7 +218,7 @@ fn test_big_p() {
#[test]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn test_big_h() {
if get_effective_gid() != 0 {
if getegid() != 0 {
assert!(
new_ucmd!()
.arg("-RH")
Expand Down
4 changes: 2 additions & 2 deletions tests/by-util/test_chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use crate::common::util::{is_ci, run_ucmd_as_root, CmdResult, TestScenario};
#[cfg(any(target_os = "linux", target_os = "android"))]
use rust_users::get_effective_uid;
use uucore::process::geteuid;

// Apparently some CI environments have configuration issues, e.g. with 'whoami' and 'id'.
// If we are running inside the CI and "needle" is in "stderr" skipping this test is
Expand Down Expand Up @@ -701,7 +701,7 @@ fn test_root_preserve() {
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn test_big_p() {
if get_effective_uid() != 0 {
if geteuid() != 0 {
new_ucmd!()
.arg("-RP")
.arg("bin")
Expand Down
12 changes: 6 additions & 6 deletions tests/by-util/test_date.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::common::util::TestScenario;
use regex::Regex;
#[cfg(all(unix, not(target_os = "macos")))]
use rust_users::get_effective_uid;
use uucore::process::geteuid;

#[test]
fn test_invalid_arg() {
Expand Down Expand Up @@ -213,7 +213,7 @@ fn test_date_format_literal() {
#[test]
#[cfg(all(unix, not(target_os = "macos")))]
fn test_date_set_valid() {
if get_effective_uid() == 0 {
if geteuid() == 0 {
new_ucmd!()
.arg("--set")
.arg("2020-03-12 13:30:00+08:00")
Expand All @@ -234,7 +234,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 !(get_effective_uid() == 0 || uucore::os::is_wsl_1()) {
if !(geteuid() == 0 || uucore::os::is_wsl_1()) {
let result = new_ucmd!()
.arg("--set")
.arg("2020-03-11 21:45:00+08:00")
Expand All @@ -261,7 +261,7 @@ fn test_date_set_mac_unavailable() {
#[cfg(all(unix, not(target_os = "macos")))]
/// TODO: expected to fail currently; change to succeeds() when required.
fn test_date_set_valid_2() {
if get_effective_uid() == 0 {
if geteuid() == 0 {
let result = new_ucmd!()
.arg("--set")
.arg("Sat 20 Mar 2021 14:53:01 AWST") // spell-checker:disable-line
Expand Down Expand Up @@ -325,7 +325,7 @@ fn test_date_for_file() {
#[cfg(all(unix, not(target_os = "macos")))]
/// TODO: expected to fail currently; change to succeeds() when required.
fn test_date_set_valid_3() {
if get_effective_uid() == 0 {
if geteuid() == 0 {
let result = new_ucmd!()
.arg("--set")
.arg("Sat 20 Mar 2021 14:53:01") // Local timezone
Expand All @@ -339,7 +339,7 @@ fn test_date_set_valid_3() {
#[cfg(all(unix, not(target_os = "macos")))]
/// TODO: expected to fail currently; change to succeeds() when required.
fn test_date_set_valid_4() {
if get_effective_uid() == 0 {
if geteuid() == 0 {
let result = new_ucmd!()
.arg("--set")
.arg("2020-03-11 21:45:00") // Local timezone
Expand Down
6 changes: 3 additions & 3 deletions tests/by-util/test_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

use crate::common::util::{is_ci, TestScenario};
use filetime::FileTime;
use rust_users::{get_effective_gid, get_effective_uid};
use std::os::unix::fs::PermissionsExt;
#[cfg(not(any(windows, target_os = "freebsd")))]
use std::process::Command;
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::thread::sleep;
use uucore::process::{getegid, geteuid};

#[test]
fn test_invalid_arg() {
Expand Down Expand Up @@ -322,7 +322,7 @@ fn test_install_target_new_file_with_group() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "file";
let dir = "target_dir";
let gid = get_effective_gid();
let gid = getegid();

at.touch(file);
at.mkdir(dir);
Expand All @@ -349,7 +349,7 @@ fn test_install_target_new_file_with_owner() {
let (at, mut ucmd) = at_and_ucmd!();
let file = "file";
let dir = "target_dir";
let uid = get_effective_uid();
let uid = geteuid();

at.touch(file);
at.mkdir(dir);
Expand Down

0 comments on commit 1895d1b

Please sign in to comment.