Re: [PATCH] util: Don't delete the original file for truncation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 21, 2018 at 11:03 AM +0200, "Daniel P. Berrangé" <berrange@xxxxxxxxxx> wrote:
> On Tue, Aug 21, 2018 at 10:49:28AM +0200, Marc Hartmayer wrote:
>> Truncate means that if a file exists it's length will be truncated to
>> 0, but the mode and the owner shall be unchanged. The current behavior
>> is that the original file is deleted and a new file is created. Let's
>> fix this by using O_TRUNC.
>
> This is just describing what you've changed, leaving out why you are
> trying todo this ?

Two things:

 1. The behavior for a console that logs all data to a file has changed
    with the patch series “qemu: use FD passing for chardev UNIX
    sockets”. Before this patch series the owner of the log file was the
    QEMU process user (since the QEMU process was responsible for
    creating it). Now it’s the virtlogd user.

    e.g.

    <console type='file'>
      <source path='/tmp/console.log'/>
      <target type='serial'/>
    </console>

 2. What is currently done by virtlogd is not a truncation (at least
    IMHO). An alternative to this patch would be to rename the parameter
    (API change… so probably no option) or document the behavior.

>
>> The function virRotatingFileWriterDelete is now unused but may be used
>> in the future and is therefore still defined.
>>
>> Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxx>
>> Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
>> ---
>> Note:
>>
>> This change has the (potentially unwanted) security effect that the
>> owner/group of the log file does not change. Before this patch the old
>> log file was deleted and the newly created log file was owned by the
>> virtlogd user. Now, if a user has created the log file before, he can
>> read the logs. If we don't wanna have this effect we can either
>> adjust/add a virtlogd API or do a chown within the calling driver
>> (e.g. QEMU driver).
>
> Pre-creating the log file and/or messing around with ownership are
> not things we ever intended to support.

Okay. What should happen if the log file is already pre-created?
Silently overwrite/delete?

>
> Regards,
> Daniel
> --
> |: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
> |: https://libvirt.org         -o-            https://fstop138.berrange.com :|
> |: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
>
--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux