Re: [PATCH] output virsh log to file

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

 



Actually I had a closer look at this patch, and there are some problems (thanks to Jim Meyering who pointed these out). For example:

Using sprintf into a fixed size message buffer with no other checks may cause a buffer overflow:

+    sprintf(msg_buf, "[%d.%02d.%02d %02d:%02d:%02d ",

You should check the return value of write:

+    /* write log */
+    write(logdef.log_fd, msg_buf, msg_len);

You don't need to zero out the stat structure before calling stat:

+    memset(&st, 0x00, sizeof(struct stat));
+    if (stat(logdef.path_buff, &st) == 0) {

What happens if this call fails?

+            rename(logdef.path_buff, bak_new_path);

But my broader point is: What use would this feature be, since you can capture the output of virsh easily using shell redirection? The Xen 'xm' command doesn't have this feature and I don't know if anyone has asked for it.

Rich.

--
Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/
Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod
Street, Windsor, Berkshire, SL4 1TE, United Kingdom.  Registered in
England and Wales under Company Registration No. 03798903

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[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]