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

Daniel P. Berrangé berrange at redhat.com
Tue Aug 21 09:03:35 UTC 2018


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 ?

> The function virRotatingFileWriterDelete is now unused but may be used
> in the future and is therefore still defined.
> 
> Signed-off-by: Marc Hartmayer <mhartmay at linux.ibm.com>
> Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
> ---
> 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.

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 :|




More information about the libvir-list mailing list