Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chmod: errors with -R flag on dangling link but shouldn't #7214

Open
jfinkels opened this issue Jan 26, 2025 · 3 comments
Open

chmod: errors with -R flag on dangling link but shouldn't #7214

jfinkels opened this issue Jan 26, 2025 · 3 comments
Labels

Comments

@jfinkels
Copy link
Collaborator

Environment: Ubuntu 24.04, uutils main branch (git commit 2430e2a), GNU coreutils v9.6.8-fbfd88-dirty

Steps to reproduce: Create a link to a file that doesn't exist and then try to change the link's permissions with the -R flag:

mkdir dir
ln -s target dangling-link  # target doesn't exist
chmod 755 --no-dereference -R -P dangling-link

What happens now: uutils chmod terminates with an error message

chmod: cannot operate on dangling symlink 'dangling-link'

What I expected to happen: GNU chmod succeeds with no output.

Notes: With both uutils and GNU, the permissions of the link itself are not actually changed, but I think that's expected for symbolic links:

$ ls -l dangling-link
lrwxrwxrwx 1 jeffrey jeffrey 6 Jan 26 10:51 dangling-link -> target

Also, the -R flag I think has no other effect in this test case, as there is no directory here to recurse into.

This is causing a failure in the GNU test file tests/chmod/symlinks.sh.

@wasiqibnzahid
Copy link

Hello, I am interested in solving this, would it be okay if I start working on this?
Thanks

@sylvestre
Copy link
Contributor

Sure :)

@jfinkels
Copy link
Collaborator Author

The -P flag seems to be one of three new flags that control how symbolic links are traversed. From the --help:

The following options modify how a hierarchy is traversed when the -R
option is also specified.  If more than one is specified, only the final
one takes effect. -H is the default.

  -H                     if a command line argument is a symbolic link
                         to a directory, traverse it
  -L                     traverse every symbolic link to a directory
                         encountered
  -P                     do not traverse any symbolic links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants