Skip to content

install: compare the owner with -C even when only -g is given - #15928

Open
Ybucaille wants to merge 2 commits into
uutils:mainfrom
Ybucaille:install-compare-owner
Open

Ybucaille wants to merge 2 commits into
uutils:mainfrom
Ybucaille:install-compare-owner

Conversation

@Ybucaille

Copy link
Copy Markdown
Contributor

Closes #15766

With -C, need_copy() only compared the destination's owner when -o was given. With -g alone, an identical file owned by another user was kept as is (exit 0), instead of being replaced by one owned by the invoker. The reverse was off too: -C -o USER without -g compared against the effective uid instead of USER, so the file got recopied on every run.

This applies @sylvestre's suggested fix from the issue. need_copy() now always checks the owner, against the -o uid or the effective uid, and the helper is renamed needs_copy_for_group() since it only handles the group now. I added the issue's assertion to test_install_root_combined. That test needs root, so I also checked the case by hand in a user namespace, where the result now matches GNU install.

// Without -o, -C must still give the file to the invoker.
run_and_check(&["-Cv", "-g2", "a", "b"], "b", 0, 2);

run_and_check(&["-Cv", "-o2", "c", "d"], "d", 2, 0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you please also cover the -o only case from the issue? e.g. rerun -Cv -o2 c d and check stdout is empty (no recopy)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, the test now reruns -Cv -o2 c d and checks nothing is printed. Since it needs root, I also checked it by hand in a user namespace: main copies the file again, this branch doesn't, same as GNU. Updated in 89f4b9e.

This branch has not been deployed

No deployments
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.

install: -C ignores owner mismatch when -g is given without -o

2 participants