install: -D ignores --owner/--group for intermediate directories

Bug #2035233 reported by Tired Sysadmin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
coreutils (Ubuntu)
New
Undecided
Unassigned

Bug Description

This is on 22.04.3, using coreutils 8.32-4.1ubuntu1.

We're wanting to populate an existing home directory with some starting example files. The system will be running on an AWS EC2 instance, so I'll use their default username "ubuntu" for this example:

# touch sourcefile
# mkdir -m 0755 existingdest
# chown ubuntu:ubuntu existingdest

We use install(1) to do the copying, permission and ownership management, and creating intermediate directories with its -D option:

# install -vD --owner=ubuntu --group=ubuntu --mode=0644 sourcefile existingdest/intermediate/destfile
install: creating directory 'existingdest/intermediate'
'sourcefile' -> 'existingdest/intermediate/destfile'

That part looks good, however...

# ls -lFd existingdest
drwxr-xr-x 3 ubuntu ubuntu 4096 Sep 12 15:54 existingdest/
# ls -lF existingdest
total 4
drwxr-xr-x 2 root root 4096 Sep 12 15:54 intermediate/
# ls -lF existingdest/intermediate/
total 0
-rw-r--r-- 1 ubuntu ubuntu 0 Sep 12 15:54 destfile

...while the pre-existing directory was left alone (correct) and the newly-created file has the specified ownership and permissions (also correct), the intermediate directories it created are still owned by root.

I would not expect the creation of 'intermediate' to use the specified --mode because a directory with 0644 would be hilariously unhelpful. I would, however, expect the given --owner and --group to have played a part. That they didn't is violating the Law of Least Surprise, at least to me; if this isn't a bug, it should at least be documented.

(I tried looking around https://github.com/coreutils/coreutils/blob/master/src/install.c to see if there was something obvious I was missing, but their coding style is not easy to read on a webpage.)

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.