<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 24, 2017 at 3:49 PM, Richard W.M. Jones <span dir="ltr"><<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Sun, Dec 24, 2017 at 02:15:44PM +0200, Yaniv Kaul wrote:<br>
> I'm copying a file into a VM using virt-copy-in - which is great, but the<br>
> file is wrongly labeled.<br>
> How can I fix that?<br>
<br>
</span>Hi Yaniv,<br>
<br>
The easiest thing is to run this after doing the virt-copy-in:<br>
<br>
  virt-customize -a disk.img --selinux-relabel<br>
<br>
which will run this code:<br>
<br>
  <a href="https://github.com/libguestfs/libguestfs/blob/master/customize/SELinux_relabel.ml#L27" rel="noreferrer" target="_blank">https://github.com/libguestfs/<wbr>libguestfs/blob/master/<wbr>customize/SELinux_relabel.ml#<wbr>L27</a><br>
<br>
That requires an extra launch of the appliance, so if you were very<br>
concerned about doing this most efficiently then you could do<br>
something like this instead:<br>
<br>
  guestfish -a disk.img -i <<EOF<br>
    copy-in files [...] /target/dir<br>
    selinux-relabel /etc/selinux/targeted/<wbr>contexts/files/file_contexts / force:true<br>
  EOF<br></blockquote><div><br></div><div>Thanks - this is exactly what I've decided to use first.</div><div>I'll run virt-customize if I need to do more work (specifically, I believe it'll relabel everything, etc. - not sure I need it right now).</div><div>Y.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
That isn't quite the same as the virt-customize code above, and in<br>
particular it assumes that you're using the "targeted" policy and you<br>
don't have the buggy version of RHEL 6, but it's near enough for most<br>
purposes.  If you want to do any better you'd need to write a custom<br>
script in Python or whatever.<br>
<br>
Rich.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~<wbr>rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
virt-top is 'top' for virtual machines.  Tiny program with many<br>
powerful monitoring features, net stats, disk stats, logging, etc.<br>
<a href="http://people.redhat.com/~rjones/virt-top" rel="noreferrer" target="_blank">http://people.redhat.com/~<wbr>rjones/virt-top</a><br>
</font></span></blockquote></div><br></div></div>