<?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>15454</bug_id>
          
          <creation_ts>2024-03-22 15:48:56 +0000</creation_ts>
          <short_desc>wic:  rootdirectory of the partition is always owned by root</short_desc>
          <delta_ts>2026-05-28 15:28:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>6</classification_id>
          <classification>Yocto Project Subprojects</classification>
          <product>Wic</product>
          <component>wic</component>
          <version>v0.3.0</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>ACCEPTED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>v0.4.0</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Pavel Zhukov">pavel</reporter>
          <assigned_to name="Trevor Woerner">twoerner</assigned_to>
          <cc>alexandre.belloni</cc>
    
    <cc>JPEWhacker</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>twoerner</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>98584</commentid>
    <comment_count>0</comment_count>
    <who name="Pavel Zhukov">pavel</who>
    <bug_when>2024-03-22 15:48:56 +0000</bug_when>
    <thetext>if image contains a directory (/mydir as an example) which is owned by non-root user and the directory has to be placed on separate partition then root directory of the partition will be created with root:root ownership [1] and directory is not accessible by the original owner after booting.

Here is an example: 

package.bb 

do_install(){
    install -D --owner=user --group=user -m0755 ${D}/mydir
}

wks file:
part /mydir  --source rootfs --rootfs-dir=${IMAGE_ROOTFS}/mydir  --fixed-size 50000 --label=newpart --align 4096 --fstype=ext4

as the result rootfs contains /mydir directory which is owned by &quot;user:user&quot; which is expected but once &quot;newpart&quot; partition is mounted /mydir is owned by root:root and not accessible by &quot;user&quot; anymore. This issue affects only root directory of the partition. Subdirectories&apos; and files&apos; ownership is intact. 



pkg_postinst_ontarget can be used to reset permissions as a workaround however proper fix would be better.

[1]
https://github.com/openembedded/openembedded-core/blob/master/scripts/lib/wic/plugins/source/rootfs.py#L185</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98653</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2024-03-28 14:37:46 +0000</bug_when>
    <thetext>Alex (CCed) thinks there is a way to work-around the problem.
--YP bug review</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98654</commentid>
    <comment_count>2</comment_count>
    <who name="Joshua Watt">JPEWhacker</who>
    <bug_when>2024-03-28 14:43:07 +0000</bug_when>
    <thetext>This is intentional and the way mounting works in general. If you want mydir to be owned by user:user after mounting, you need to change the root directory of the image being mounted there to be owned by that user.

IOW, the root directory permissions of a mount replace the permissions of the directory where it is mounted.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98655</commentid>
    <comment_count>3</comment_count>
    <who name="Joshua Watt">JPEWhacker</who>
    <bug_when>2024-03-28 14:43:36 +0000</bug_when>
    <thetext>See previous comment</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98728</commentid>
    <comment_count>4</comment_count>
    <who name="Pavel Zhukov">pavel</who>
    <bug_when>2024-04-09 12:39:54 +0000</bug_when>
    <thetext>(In reply to Joshua Watt from comment #2)
&gt; This is intentional and the way mounting works in general. If you want mydir
&gt; to be owned by user:user after mounting, you need to change the root
&gt; directory of the image being mounted there to be owned by that user.
&gt; 
&gt; IOW, the root directory permissions of a mount replace the permissions of
&gt; the directory where it is mounted.

This is correct. And this bug has been created exactly with this purpose.
If wic plugin creates mount for such directory the root directory of such image should be owned by the user.
https://github.com/openembedded/openembedded-core/blob/master/scripts/lib/wic/plugins/source/rootfs.py#L185 instead of default mkdir call</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>