daemon-unix: Properly handle missing users or groups.
authorChristian Ehrhardt <christian.ehrhardt@canonical.com>
Mon, 25 Apr 2016 07:12:19 +0000 (09:12 +0200)
committerBen Pfaff <blp@ovn.org>
Mon, 16 May 2016 21:11:03 +0000 (14:11 -0700)
commiteaf2aa9e23e0ae2a7380ca297f947f6e1219a555
tree647be2da6df033242ad8da82fc5f742ccd485ba5
parent04418350ec06b04e5799a25c6e3c99e13ee4af04
daemon-unix: Properly handle missing users or groups.

From the manpages of getgrnam_r (getpwnam_r is similar):
"If no matching group record was found, these functions return 0 and
store NULL in *result."

The code checked only against errors, but non existing users didn't set
e != 0 therefore the code could try to set arbitrary uid/gid values.

Fixes: e91b927d lib/daemon: support --user option for all OVS daemon
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/daemon-unix.c