[libvirt] [PATCH] Prevent streams from becoming libvirtd controlling TTY

From: "Daniel P. Berrange" <berrange@redhat.com> When opening a stream to a device which is a TTY, that device may become the controlling TTY of libvirtd, if libvirtd was daemonized. This in turn means when the other end of the stream closes, libvirtd gets SIGHUP, causing it to reload its config. Prevent this by forcing O_NOCTTY on all streams that are opened Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/fdstream.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fdstream.c b/src/fdstream.c index cc2dfe9..9a6f042 100644 --- a/src/fdstream.c +++ b/src/fdstream.c @@ -582,6 +582,8 @@ virFDStreamOpenFileInternal(virStreamPtr st, VIR_DEBUG("st=%p path=%s oflags=%x offset=%llu length=%llu mode=%o", st, path, oflags, offset, length, mode); + oflags |= O_NOCTTY; + if (oflags & O_CREAT) fd = open(path, oflags, mode); else -- 1.8.1.4

On 03/13/2013 11:24 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
When opening a stream to a device which is a TTY, that device may become the controlling TTY of libvirtd, if libvirtd was daemonized. This in turn means when the other end of the stream closes, libvirtd gets SIGHUP, causing it to reload its config. Prevent this by forcing O_NOCTTY on all streams that are opened
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/fdstream.c | 2 ++ 1 file changed, 2 insertions(+)
ACK. Bet you had fun tracking down that dark corner of POSIX. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Wed, Mar 13, 2013 at 04:33:34PM -0600, Eric Blake wrote:
On 03/13/2013 11:24 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
When opening a stream to a device which is a TTY, that device may become the controlling TTY of libvirtd, if libvirtd was daemonized. This in turn means when the other end of the stream closes, libvirtd gets SIGHUP, causing it to reload its config. Prevent this by forcing O_NOCTTY on all streams that are opened
Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/fdstream.c | 2 ++ 1 file changed, 2 insertions(+)
ACK. Bet you had fun tracking down that dark corner of POSIX.
I can think of many appropriate words for what I had to do to discover this. 'fun' is not one of them :-P Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Eric Blake