Re: [PATCH 2/2] virt-login-shell joins users into lxc container.

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

 



On Wed, Jul 31, 2013 at 01:15:51PM -0600, Eric Blake wrote:
> On 07/31/2013 12:57 PM, Daniel P. Berrange wrote:
> 
> >> +    if (virFork(&cpid) < 0)
> >> +	goto cleanup;
> >> +
> ...
> >> +	}
> >> +
> >> +	if ((ngroups = virGetGroupList(uid, gid, &groups)) < 0)
> >> +	    return EXIT_FAILURE;
> > 
> > virGetGroupList isn't safe to call after fork(). Need to
> > move it earlier in this function.
> 
> Technically, it is only unsafe to call after fork() if the parent
> process was multi-threaded.  But as virt-login-shell is single-threaded,
> we can get away with it here.

I work on the assumption that all programs are multi-threaded, or will
be at some point in their future, even if the developer doesn't think
they are/willbe. You never know when some function/library you call
may secretly create a thread behind your back. For example, virsh was
single threaded, until we put in the special background thread to run
the event loop in.

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

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