coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Wrong permissions on directories when invoking `uu-install -Dm644`

Open kylemanna opened this issue 2 years ago • 4 comments

Issue

The uu-install implementation handles the argument combination of -Dm644 which is commonly use in C/C++ install tools differently then coreutils.

The uu-install implementation sets the -m644 permissions on the directories it creates and fails to copy the file as the execute bit is mentioning on the directories.

Meanwhile, install creates directories with 755 and then creates the final file with 644 permissions as specified.

Example test cases

uutils

$ /usr/bin/uu-install --version
/usr/bin/uu-install 0.0.17
$ /usr/bin/uu-install -Dm644 file.txt uutils644/a/b/c/d
/usr/bin/uu-install: cannot install 'file.txt' to 'uutils644/a/b/c/d': Permission denied
$ exa --no-user -l --tree uu*
drwxr-xr-x - 13 Feb 17:34 uutils644
drwxr-xr-x - 13 Feb 17:34 └── a
drwxr-xr-x - 13 Feb 17:34    └── b
drw-r--r-- - 13 Feb 17:34       └── c
$ /usr/bin/install --version | head -n1
install (GNU coreutils) 9.1
$ /usr/bin/install -Dm644 file.txt core644/a/b/c/d
$ exa --no-user -l --tree core*
drwxr-xr-x - 13 Feb 17:36 core644
drwxr-xr-x - 13 Feb 17:36 └── a
drwxr-xr-x - 13 Feb 17:36    └── b
drwxr-xr-x - 13 Feb 17:36       └── c
.rw-r--r-- 0 13 Feb 17:36          └── d

It appears the default behavior without -m644 matches coreutils as expected:

$ /usr/bin/uu-install -D file.txt uutils/a/b/c/d
$ exa --no-user -l --tree uu*
drwxr-xr-x - 13 Feb 17:34 uutils
drwxr-xr-x - 13 Feb 17:34 └── a
drwxr-xr-x - 13 Feb 17:34    └── b
drwxr-xr-x - 13 Feb 17:34       └── c
.rwxr-xr-x 0 13 Feb 17:34          └── d

$ /usr/bin/install -Dm644 file.txt core644/a/b/c/d
$ exa --no-user -l --tree core*
drwxr-xr-x - 13 Feb 17:36 core
drwxr-xr-x - 13 Feb 17:36 └── a
drwxr-xr-x - 13 Feb 17:36    └── b
drwxr-xr-x - 13 Feb 17:36       └── c
.rwxr-xr-x 0 13 Feb 17:36          └── d

kylemanna avatar Feb 13 '23 23:02 kylemanna

Thanks for the clear report!

tertsdiepraam avatar Feb 13 '23 23:02 tertsdiepraam

Found another issue that's probably related, I can create another issue if you like or update the description.

Running install -o $UID -g $GID -d dir/a/b fails to set the permissions on the final directory (b) in this case.

Arch Linux uses this in makechrootpkg which is broken by this. Code for usage is here.

$ sudo /usr/bin/install -o 1000 -g 1000 -d core/a/b
$ sudo /usr/bin/uu-install -o 1000 -g 1000 -d uu/a/b

$  exa -lng --tree core uu

drwxr-xr-x - 0    0    13 Feb 18:28 core
drwxr-xr-x - 0    0    13 Feb 18:28 └── a
drwxr-xr-x - 1000 1000 13 Feb 18:28    └── b

drwxr-xr-x - 0    0    13 Feb 18:28 uu
drwxr-xr-x - 0    0    13 Feb 18:28 └── a
drwxr-xr-x - 0    0    13 Feb 18:28    └── b

Note that coreutils implementation sets the requested permissions of core/a/b to the uid+gid passed in but uu-install does not.

kylemanna avatar Feb 14 '23 00:02 kylemanna

It's probably a slightly different codepath so I think a separate issue makes sense. Thanks!

tertsdiepraam avatar Feb 14 '23 00:02 tertsdiepraam

Created #4361 to track the -o -g -d issue.

kylemanna avatar Feb 14 '23 01:02 kylemanna