+
Skip to content

Conversation

sylvestre
Copy link
Contributor

Should make tests/chgrp/from pass

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/tail/inotify-dir-recreate (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/chgrp/from is no longer failing!
Congrats! The gnu test tests/df/over-mount-device is no longer failing!

Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/misc/stdbuf is no longer failing!
GNU test failed: tests/cp/cross-dev-symlink. tests/cp/cross-dev-symlink is passing on 'main'. Maybe you have to rebase?
Congrats! The gnu test tests/chgrp/from is no longer failing!

@jfinkels
Copy link
Collaborator

I added a similar function name_to_gid in chroot, in case it helps you

@sylvestre
Copy link
Contributor Author

indeed but as it uses ChrootError, it will require a bunch of refactor for 4 lines
maybe as a good first bugs later?

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/tail/inotify-dir-recreate (fails in this run but passes in the 'main' branch)
Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/chgrp/from is no longer failing!

Copy link
Collaborator

@jfinkels jfinkels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, but it makes sense to me!

const USAGE: &str = help_usage!("chgrp.md");

fn parse_gid_from_str(group: &str) -> Result<u32, String> {
if let Some(gid_str) = group.strip_prefix(':') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the option is --from=:foo, could foo be a group name? This code assumes it is always a numeric group ID, I think. The docs (for chown, but I think it applies to chgrp also) seem to imply that it can be a group name: https://www.gnu.org/software/coreutils/manual/html_node/chown-invocation.html

Also, the docs for chgrp say

Change a file’s ownership only if it has current attributes specified by old-owner. old-owner has the same form as new-owner described above.

new-owner is described in the chown documentation as allowing anything of the form [USER] [: [GROUP]]. If that's true, then we should check for user names and IDs too.

All of these can be fixed separately (and common code refactored from chgrp, chown, and chroot), I just wanted to share my understanding of the GNU documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably yeah
I think it can be done as a follow up :)

@jfinkels jfinkels linked an issue Jan 14, 2025 that may be closed by this pull request
Comment on lines 468 to 484
#[test]
#[cfg(not(target_vendor = "apple"))]
fn test_from_with_invalid_group() {
let (at, mut ucmd) = at_and_ucmd!();
at.touch("test_file");
#[cfg(not(target_os = "android"))]
let err_msg = "chgrp: invalid group: 'nonexistent_group'\n";
#[cfg(target_os = "android")]
let err_msg = "chgrp: invalid group: 'staff'\n";

ucmd.arg("--from")
.arg("nonexistent_group")
.arg("staff")
.arg("test_file")
.fails()
.stderr_is(err_msg);
}
Copy link
Contributor

@cakebaker cakebaker Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails on my machine. And I don't know if the error message is deliberately different from GNU chgrp. With GNU it is about an invalid user and not about an invalid group.

$ cargo run --features=unix -q chgrp --from nonexistent_group staff README.md
chgrp: invalid group: 'staff'
$ chgrp --from nonexistent_group staff README.md
chgrp: invalid user: ‘nonexistent_group’

Copy link

GNU testsuite comparison:

Skipping an intermittent issue tests/timeout/timeout (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/chgrp/from is no longer failing!

@cakebaker
Copy link
Contributor

Did you see that a bunch of CI jobs fail?

Copy link

GNU testsuite comparison:

GNU test failed: tests/tail/truncate. tests/tail/truncate is passing on 'main'. Maybe you have to rebase?
Skipping an intermittent issue tests/misc/usage_vs_getopt (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/chgrp/from is no longer failing!

Copy link

GNU testsuite comparison:

Skip an intermittent issue tests/timeout/timeout (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cksum/cksum-c is no longer failing!
Skipping an intermittent issue tests/misc/stdbuf (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/chgrp/from is no longer failing!

@sylvestre
Copy link
Contributor Author

Did you see that a bunch of CI jobs fail?

missed it, thanks!
fixed now!

@cakebaker cakebaker merged commit 10f43ec into uutils:main Jan 24, 2025
65 checks passed
@cakebaker
Copy link
Contributor

Congrats! The gnu test tests/chgrp/from is no longer failing!

Great :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chgrp: add --from option

3 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载