Bug 9887 - Directory permissions are overwritten during install
Summary: Directory permissions are overwritten during install
Status: RESOLVED FIXED
Alias: None
Product: opkg
Classification: Yocto Project Subprojects
Component: opkg (show other bugs)
Version: 0.3.2
Hardware: x86 x86_64
: Undecided normal
Target Milestone: 0.3.4
Assignee: Alejandro del Castillo
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-07-06 19:00 UTC by Paul Spangler
Modified: 2018-01-21 09:24 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
Example package to show behavior (660 bytes, application/octet-stream)
2016-07-06 19:00 UTC, Paul Spangler
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Spangler 2016-07-06 19:00:43 UTC
Created attachment 3271 [details]
Example package to show behavior

Installing a package that puts files in an already existing directory will overwrite the owner and permissions of the directory to whatever was specified in the package. This is in contrast to dpkg, which preserves the owner and permissions of the existing directory.

See attached example package with Architecture all that installs a single text file to /dir/subdir.

Expectation (dpkg)
------------------
$ dpkg --version
Debian `dpkg' package management program version 1.16.1.2 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
$ sudo mkdir -p /dir/subdir
$ sudo chmod 700 /dir/subdir
$ sudo chmod 755 /dir
$ ls -l /
...
drwxr-xr-x   3 root root  4096 Jul  6 13:32 dir
...
$ ls -l /dir
drwx------ 2 root root 4096 Jul  6 13:32 subdir
$ sudo dpkg -i ~/perm-bug-1.0.0.0.ipk 
Selecting previously unselected package perm-bug.
(Reading database ... 1929438 files and directories currently installed.)
Unpacking perm-bug (from .../perm-bug-1.0.0.0.ipk) ...
Setting up perm-bug (1.0.0.0) ...
$ ls -l /
...
drwxr-xr-x   3 root root  4096 Jul  6 13:32 dir
...
$ ls -l /dir/
drwx------ 2 root root 4096 Jul  6 13:35 subdir

Actual Result (opkg)
--------------------
# opkg -v
opkg version 0.3.2
# mkdir -p /dir/subdir
# chmod 700 /dir/subdir
# chmod 755 /dir
# ls -l /
...
drwxr-xr-x    3 root     root          4096 Jul  6 18:39 dir
...
# ls -l /dir
drwx------    2 root     root          4096 Jul  6 18:39 subdir
# opkg install perm-bug-1.0.0.0.ipk
Installing pkg perm-bug - 1.0.0.0
Configuring perm-bug.
# ls -l /
...
drwxrwxr-x    3 root     root          4096 Jul  6 18:35 dir
...
# ls -l /dir
drwxrwxr-x    2 root     root          4096 Jul  6 18:40 subdir
Comment 1 Alejandro del Castillo 2016-11-02 20:05:42 UTC
Fixed on commit 90e127aaf9a347fa6c48df321c2b3c013555fd87
Comment 2 Paul Spangler 2017-10-16 16:51:23 UTC
(In reply to comment #1)
> Fixed on commit 90e127aaf9a347fa6c48df321c2b3c013555fd87

The permissions do get preserved now, but it looks like the owner doesn't. The same test package still serves as a way to reproduce, but insert an extra chown prior to installing the package (steps assume a user named "user" exists on the system):

Expectation (dpkg)
------------------
$ dpkg --version
Debian 'dpkg' package management program version 1.18.4 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.
$ sudo mkdir -p /dir/subdir
$ sudo chmod 700 /dir/subdir
$ sudo chmod 755 /dir
$ sudo chown user:user /dir
$ sudo chown user:user /dir/subdir
$ ls -l / | grep dir
drwxr-xr-x   3 user user  4096 Oct 16 11:34 dir
$ ls -l /dir
drwx------ 2 user user 4096 Oct 16 11:34 subdir
$ sudo dpkg -i ~/perm-bug-1.0.0.0.ipk 
Selecting previously unselected package perm-bug.
(Reading database ... 481088 files and directories currently installed.)
Unpacking perm-bug (from .../perm-bug-1.0.0.0.ipk) ...
Setting up perm-bug (1.0.0.0) ...
$ ls -l / | grep dir
drwxr-xr-x   3 user user  4096 Oct 16 11:34 dir
$ ls -l /dir
total 4
drwx------ 2 user user 4096 Oct 16 11:35 subdir

Actual Result (opkg)
--------------------
# opkg -v
opkg version 0.3.4 (libsolv 0.6.24)
# mkdir -p /dir/subdir
# chmod 700 /dir/subdir
# chmod 755 /dir
# chown user:user /dir
# chown user:user /dir/subdir
# ls -l / | grep dir
drwxr-xr-x    3 user     user          1024 Oct 16 16:38 dir
# ls -l /dir
drwx------    2 user     user          1024 Oct 16 16:38 subdir
# opkg install ~/perm-bug-1.0.0.0.ipk
Installing perm-bug (1.0.0.0) on root
Configuring perm-bug.
# ls -l / | grep dir
drwxr-xr-x    3 root     root          1024 Jul  6  2016 dir
# ls -l /dir
drwx------    2 root     root          1024 Oct 16 16:39 subdir


Note that dpkg preserved the user owner, while opkg used the owner from the package (root).
Comment 3 Alejandro del Castillo 2017-11-08 22:08:18 UTC
this is an issue with libarchive. Paul already opened a PR to get this fixed [1]

[1] https://github.com/libarchive/libarchive/pull/962
Comment 4 Alejandro del Castillo 2018-01-21 09:24:33 UTC
libarchive fix was merged on libarchive. Verified correct opkg behavior with libarchive fix.