<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>9887</bug_id>
          
          <creation_ts>2016-07-06 19:00:43 +0000</creation_ts>
          <short_desc>Directory permissions are overwritten during install</short_desc>
          <delta_ts>2018-01-21 09:24:33 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>opkg</product>
          <component>opkg</component>
          <version>0.3.2</version>
          <rep_platform>x86</rep_platform>
          <op_sys>x86_64</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>0.3.4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Paul Spangler">paul.spangler</reporter>
          <assigned_to name="Alejandro del Castillo">alejandro.delcastillo</assigned_to>
          
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>63683</commentid>
    <comment_count>0</comment_count>
      <attachid>3271</attachid>
    <who name="Paul Spangler">paul.spangler</who>
    <bug_when>2016-07-06 19:00:43 +0000</bug_when>
    <thetext>Created attachment 3271
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&apos; 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>67877</commentid>
    <comment_count>1</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2016-11-02 20:05:42 +0000</bug_when>
    <thetext>Fixed on commit 90e127aaf9a347fa6c48df321c2b3c013555fd87</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>77611</commentid>
    <comment_count>2</comment_count>
    <who name="Paul Spangler">paul.spangler</who>
    <bug_when>2017-10-16 16:51:23 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Fixed on commit 90e127aaf9a347fa6c48df321c2b3c013555fd87

The permissions do get preserved now, but it looks like the owner doesn&apos;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 &quot;user&quot; exists on the system):

Expectation (dpkg)
------------------
$ dpkg --version
Debian &apos;dpkg&apos; 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).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78081</commentid>
    <comment_count>3</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2017-11-08 22:08:18 +0000</bug_when>
    <thetext>this is an issue with libarchive. Paul already opened a PR to get this fixed [1]

[1] https://github.com/libarchive/libarchive/pull/962</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79171</commentid>
    <comment_count>4</comment_count>
    <who name="Alejandro del Castillo">alejandro.delcastillo</who>
    <bug_when>2018-01-21 09:24:33 +0000</bug_when>
    <thetext>libarchive fix was merged on libarchive. Verified correct opkg behavior with libarchive fix.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>3271</attachid>
            <date>2016-07-06 19:00:43 +0000</date>
            <delta_ts>2016-07-06 19:00:43 +0000</delta_ts>
            <desc>Example package to show behavior</desc>
            <filename>perm-bug-1.0.0.0.ipk</filename>
            <type>application/octet-stream</type>
            <size>660</size>
            <attacher name="Paul Spangler">paul.spangler</attacher>
            
              <data encoding="base64">ITxhcmNoPgpkZWJpYW4tYmluYXJ5ICAgMTQ2NzgzMDExNyAgMCAgICAgMCAgICAgMTAwNzc1ICA0
ICAgICAgICAgYAoyLjAKY29udHJvbC50YXIuZ3ogIDE0Njc4MzAxMTcgIDAgICAgIDAgICAgIDEw
MDc3NSAgMjcxICAgICAgIGAKH4sIAGVPfVcAA+2R3UrEMBCFc52nmBfYbtJuDRQRlb1Z/KG44n2M
YR1MkzJNQN/ebhdUeuFeFVnsF8IQZsI5ycmWbHKEEEqVsK8943o4yFwVKl+pclWCkDKXBYNyemuM
pS5q6q1QCPG3uWP98eNOhGxpgo8U3IQax/IvhBrln5/lkoGY0NMX/zz/Wps3vbMVtJaaxXPa8SdL
HQZfgczEfvErMq8YrYmJ+jntHL/T6GO/LVVwv4Fb9OkdHqx2i0dsLHy3Ozj36CheesxMaC742naG
sI2DwKa+geuE7sUSrG0ToD2Y4dtebJhosDO8JgyE8aOCMFzUjm9DIvPT9F9/48zMzMzJ8QnL5ZVM
AAoAAApkYXRhLnRhci5neiAgICAgMTQ2NzgzMDExNyAgMCAgICAgMCAgICAgMTAwNzc1ICAxOTUg
ICAgICAgYAofiwgAZU99VwAD7ZJtCsIwDIZ7lJ6g6+dyES9Q3XRDodJ14G5vZfOHAzcm60TMQyGE
9McbnrCMJIdzDmDoo0bGtW+EBAVSg9GGciGkUISa9NEIaZtgfYzinQtT/+bm4+V+BJYVtU98Ax/4
BxDofwt6/027T3gGy/0rmaP/TXjxf7XdxdmChdvkqkuZ9a/103+uQET/8Qo4oXzNEO/4c/+7qm5o
fKEq6aCfHp0f+sPZnkr27YwIgiDI+twB/2DEuwAOAAAK
</data>

          </attachment>
      

    </bug>

</bugzilla>