<div dir="ltr"><div>Thanks Ricardo... that helps me.<br><br></div>Scott<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 2, 2018 at 11:18 AM, Ricardo Ribalda Delgado <span dir="ltr">&lt;<a href="mailto:ricardo.ribalda@gmail.com" target="_blank">ricardo.ribalda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Scott<br>
<br>
In this case I believe that it is a bug in wic, for no reason the user<br>
id of bitbake should be leaked into the rootfs.<br>
<br>
Regards<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, May 2, 2018 at 6:44 PM, Scott Rifenbark &lt;<a href="mailto:srifenbark@gmail.com">srifenbark@gmail.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I have a couple Wic-related areas in the Yocto documentation.  Wondering if<br>
&gt; this affects documentation.  I don&#39;t particularly have sections dedicated to<br>
&gt; using specific canned wic files such as the &quot;directdisk-multi-rootfs&quot; file.<br>
&gt; However, if there is some mentioning or changing of the docs to help avoid<br>
&gt; this I could see what I could do.<br>
&gt;<br>
&gt; The sections related to Wic are:<br>
&gt;<br>
&gt;    *<br>
&gt; <a href="https://www.yoctoproject.org/docs/2.5/dev-manual/dev-manual.html#creating-partitioned-images-using-wic" rel="noreferrer" target="_blank">https://www.yoctoproject.org/<wbr>docs/2.5/dev-manual/dev-<wbr>manual.html#creating-<wbr>partitioned-images-using-wic</a><br>
&gt;    *<br>
&gt; <a href="https://www.yoctoproject.org/docs/2.5/ref-manual/ref-manual.html#ref-kickstart" rel="noreferrer" target="_blank">https://www.yoctoproject.org/<wbr>docs/2.5/ref-manual/ref-<wbr>manual.html#ref-kickstart</a><br>
&gt;<br>
&gt; Thanks,<br>
&gt; Scott<br>
&gt;<br>
&gt; On Wed, May 2, 2018 at 9:31 AM, Volker Vogelhuber<br>
&gt; &lt;<a href="mailto:v.vogelhuber@digitalendoscopy.de">v.vogelhuber@<wbr>digitalendoscopy.de</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I never got any response to my message (until now). So AFAIK I solved the<br>
&gt;&gt; problem with the following patch:<br>
&gt;&gt;<br>
&gt;&gt; diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py<br>
&gt;&gt; index 84fe85d62b..66ab757aec 100644<br>
&gt;&gt; --- a/scripts/lib/wic/partition.py<br>
&gt;&gt; +++ b/scripts/lib/wic/partition.py<br>
&gt;&gt; @@ -204,15 +204,10 @@ class Partition():<br>
&gt;&gt;<br>
&gt;&gt;          Currently handles ext2/3/4, btrfs and vfat.<br>
&gt;&gt;          &quot;&quot;&quot;<br>
&gt;&gt; -        p_prefix = os.environ.get(&quot;PSEUDO_PREFIX&quot;<wbr>, &quot;%s/usr&quot; %<br>
&gt;&gt; native_sysroot)<br>
&gt;&gt; -        p_localstatedir = os.environ.get(&quot;PSEUDO_<wbr>LOCALSTATEDIR&quot;,<br>
&gt;&gt; -                                         &quot;%s/../pseudo&quot; %<br>
&gt;&gt; get_bitbake_var(&quot;IMAGE_ROOTFS&quot;<wbr>))<br>
&gt;&gt; -        p_passwd = os.environ.get(&quot;PSEUDO_PASSWD&quot;<wbr>, rootfs_dir)<br>
&gt;&gt; +        pseudo = &quot;export PSEUDO_PREFIX=%s/usr;&quot; % native_sysroot<br>
&gt;&gt; +        pseudo += &quot;export PSEUDO_LOCALSTATEDIR=%s/../<wbr>pseudo;&quot; %<br>
&gt;&gt; self.rootfs_dir<br>
&gt;&gt; +        pseudo += &quot;export PSEUDO_PASSWD=%s;&quot; % rootfs_dir<br>
&gt;&gt;          p_nosymlinkexp = os.environ.get(&quot;PSEUDO_<wbr>NOSYMLINKEXP&quot;, &quot;1&quot;)<br>
&gt;&gt; -        pseudo = &quot;export PSEUDO_PREFIX=%s;&quot; % p_prefix<br>
&gt;&gt; -        pseudo += &quot;export PSEUDO_LOCALSTATEDIR=%s;&quot; % p_localstatedir<br>
&gt;&gt; -        pseudo += &quot;export PSEUDO_PASSWD=%s;&quot; % p_passwd<br>
&gt;&gt; -        pseudo += &quot;export PSEUDO_NOSYMLINKEXP=%s;&quot; % p_nosymlinkexp<br>
&gt;&gt;          pseudo += &quot;%s &quot; % get_bitbake_var(&quot;FAKEROOTCMD&quot;)<br>
&gt;&gt;<br>
&gt;&gt;          rootfs = &quot;%s/rootfs_%s.%s.%s&quot; % (cr_workdir, self.label,<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On 02.05.2018 17:51, Ricardo Ribalda Delgado wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I just got hit by this one. It is specially nasty because nfsroot<br>
&gt;&gt;&gt; fails to boot if the uids are wrong.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; What is the status on this?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On Mon, Jan 22, 2018 at 11:39 AM, Volker Vogelhuber<br>
&gt;&gt;&gt; &lt;<a href="mailto:v.vogelhuber@digitalendoscopy.de">v.vogelhuber@<wbr>digitalendoscopy.de</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; I finally found out, what&#39;s the reason why the included recovery rootfs<br>
&gt;&gt;&gt;&gt; has<br>
&gt;&gt;&gt;&gt; the wrong UIDs, while the main image has the correct one. The reason<br>
&gt;&gt;&gt;&gt; seems<br>
&gt;&gt;&gt;&gt; to be the PSEUDO_LOCALSTATEDIR variable that is set to the state dir of<br>
&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt; main image in both cases.<br>
&gt;&gt;&gt;&gt; I debugged all the calls up to the environment setup in partition.py&#39;s<br>
&gt;&gt;&gt;&gt; prepare_rootfs method where a check for an existing PSEUDO_LOCALSTATEDIR<br>
&gt;&gt;&gt;&gt; environment variable is done. That seems to be the problem.<br>
&gt;&gt;&gt;&gt; Instead of using the correct value passed to the prepare_rootfs method,<br>
&gt;&gt;&gt;&gt; an<br>
&gt;&gt;&gt;&gt; existing ENV value is used that points to the state dir of the main<br>
&gt;&gt;&gt;&gt; image<br>
&gt;&gt;&gt;&gt; instead of the recovery one&#39;s. I guess the reason is that in<br>
&gt;&gt;&gt;&gt; bitbake.conf<br>
&gt;&gt;&gt;&gt; the PSEUDO_LOCALSTATEDIR is set to the image currently build (which is<br>
&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt; main image and not the recovery image only referenced by the main<br>
&gt;&gt;&gt;&gt; image). So<br>
&gt;&gt;&gt;&gt; because that environment variable is already set, the call to mkfs.ext4<br>
&gt;&gt;&gt;&gt; for<br>
&gt;&gt;&gt;&gt; the recovery image uses the wrong PSEUDO_LOCALSTATEDIR and does not<br>
&gt;&gt;&gt;&gt; apply<br>
&gt;&gt;&gt;&gt; the correct UID.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Any ideas how to fix that? I tend to just remove the patch introduced by<br>
&gt;&gt;&gt;&gt; Ed<br>
&gt;&gt;&gt;&gt; Bartosh three years ago<br>
&gt;&gt;&gt;&gt; (<a href="https://patchwork.openembedded.org/patch/90419/" rel="noreferrer" target="_blank">https://patchwork.<wbr>openembedded.org/patch/90419/</a>)<br>
&gt;&gt;&gt;&gt; because I don&#39;t need a custom PSEUDO_PREFIX. But maybe not everyone<br>
&gt;&gt;&gt;&gt; agrees.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 19.01.2018 17:00, Volker Vogelhuber wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I&#39;m currently trying to create a multi RootFS WIC image as mentioned in<br>
&gt;&gt;&gt;&gt;&gt; directdisk-multi-rootfs.wks. For that I have two image recipes. One<br>
&gt;&gt;&gt;&gt;&gt; that<br>
&gt;&gt;&gt;&gt;&gt; is creating only an ext4 image (image-recovery), and the second that is<br>
&gt;&gt;&gt;&gt;&gt; also<br>
&gt;&gt;&gt;&gt;&gt; creating a WIC image (image-main). I used the IMAGE_FSTYPES variable<br>
&gt;&gt;&gt;&gt;&gt; for<br>
&gt;&gt;&gt;&gt;&gt; that. The WKS file for the second image is integrating the recovery<br>
&gt;&gt;&gt;&gt;&gt; image by<br>
&gt;&gt;&gt;&gt;&gt; specifying --rootfs-dir=image-recovery in it&#39;s part description.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; # primary / recovery image<br>
&gt;&gt;&gt;&gt;&gt; part / --source rootfs --rootfs-dir=image-main --exclude-path mnt/data/<br>
&gt;&gt;&gt;&gt;&gt; mnt/data2/ --fstype=ext4 --label primary_rootfs --align 1024 --size 700<br>
&gt;&gt;&gt;&gt;&gt; --overhead-factor=1.0<br>
&gt;&gt;&gt;&gt;&gt; part /recovery --source rootfs --rootfs-dir=image-recovery<br>
&gt;&gt;&gt;&gt;&gt; --fstype=ext4<br>
&gt;&gt;&gt;&gt;&gt; --label recovery_rootfs --align 1024 --size 640 --overhead-factor=1.0<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; The UIDs of the second rootfs (image-main) are correctly set to 0<br>
&gt;&gt;&gt;&gt;&gt; within<br>
&gt;&gt;&gt;&gt;&gt; the file system when calling mkfs.ext4 during prepare_rootfs_ext. For<br>
&gt;&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; recovery rootfs the UID is always set to my own (host) one which is of<br>
&gt;&gt;&gt;&gt;&gt; course not valid for the image where that UID does not exist.<br>
&gt;&gt;&gt;&gt;&gt; I tried calling the mkfs.ext4 command myself from a terminal and for<br>
&gt;&gt;&gt;&gt;&gt; whatever reason an image created out of the rootfs folder of the second<br>
&gt;&gt;&gt;&gt;&gt; image (image-main) recipe is deployed with the correct UID 0, while the<br>
&gt;&gt;&gt;&gt;&gt; rootfs folder of the first image (image-recovery) recipe always uses<br>
&gt;&gt;&gt;&gt;&gt; the UID<br>
&gt;&gt;&gt;&gt;&gt; of the source folder/files.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I search the code of e2fsprogs for the line that sets the UID and added<br>
&gt;&gt;&gt;&gt;&gt; a<br>
&gt;&gt;&gt;&gt;&gt; printf in set_inode_extra. There I can see clearly that the source UID<br>
&gt;&gt;&gt;&gt;&gt; for<br>
&gt;&gt;&gt;&gt;&gt; the file is 0 for the rootfs of the image-main rootfs folder while it<br>
&gt;&gt;&gt;&gt;&gt; is<br>
&gt;&gt;&gt;&gt;&gt; 10000 (my own UID) for the image-recovery. I wonder how the UID of the<br>
&gt;&gt;&gt;&gt;&gt; image-main rootfs folder can be zero when I don&#39;t call any command with<br>
&gt;&gt;&gt;&gt;&gt; root<br>
&gt;&gt;&gt;&gt;&gt; permissions. I searched for a preparation step where the UIDs are<br>
&gt;&gt;&gt;&gt;&gt; managed in<br>
&gt;&gt;&gt;&gt;&gt; the scripts folder of Yocto, but didn&#39;t found any hint for the whole<br>
&gt;&gt;&gt;&gt;&gt; behavior. So while it is good that the rootfs partition of the main<br>
&gt;&gt;&gt;&gt;&gt; rootfs<br>
&gt;&gt;&gt;&gt;&gt; has the UID set correctly to zero, I can&#39;t understand why it happens.<br>
&gt;&gt;&gt;&gt;&gt; On the<br>
&gt;&gt;&gt;&gt;&gt; other side I can understand why the UID of the recovery rootfs is set<br>
&gt;&gt;&gt;&gt;&gt; to my<br>
&gt;&gt;&gt;&gt;&gt; own one, but it stops me from booting that rootfs because the UIDs of<br>
&gt;&gt;&gt;&gt;&gt; the<br>
&gt;&gt;&gt;&gt;&gt; files and folders are set to a user that does not exist on the target<br>
&gt;&gt;&gt;&gt;&gt; system.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Can someone please explain to me, how that UID handling is meant to be<br>
&gt;&gt;&gt;&gt;&gt; done?<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; --<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; ______________________________<wbr>_________________<br>
&gt;&gt; Openembedded-core mailing list<br>
&gt;&gt; <a href="mailto:Openembedded-core@lists.openembedded.org">Openembedded-core@lists.<wbr>openembedded.org</a><br>
&gt;&gt; <a href="http://lists.openembedded.org/mailman/listinfo/openembedded-core" rel="noreferrer" target="_blank">http://lists.openembedded.org/<wbr>mailman/listinfo/openembedded-<wbr>core</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">-- <br>
Ricardo Ribalda<br>
</font></span></blockquote></div><br></div>