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