munin-monitoring/munin-c — pull request #17 by mattthias (2013-12-14 16:24:53+00:00)
Title: node: Don't ignore return value of setgid / setuid

With activated hardening flags -Werror=unused-result breaks the build if return values are ignored.This patch is needed for the Debian packaging.
I'am not sure if the explicit check for the group id is really needed. Is it possible that setgid() returns zero on success but the group isnt correct set?

Reproduce on Debian:
* Get munin-c

git clone https://github.com/munin-monitoring/munin-c.git
* Install hardening-wrapper

apt-get install hardening-wrapper
* Set environment variable DEB_BUILD_HARDENING

export DEB_BUILD_HARDENING=1
* Build munin-c

autoreconf -i -I m4 && ./configure && make

make[1]: Entering directory `/tmp/munin-c/src/node'
CC node.o
node.c: In function 'setenvvars_conf':
node.c:467:3: error: ignoring return value of 'setgid', declared with attribute warn_unused_result [-Werror=unused-result]
(void)setgid(pconf.gid);
^
node.c:474:3: error: ignoring return value of 'setuid', declared with attribute warn_unused_result [-Werror=unused-result]
(void)setuid(pconf.uid);
^
cc1: all warnings being treated as errors
make[1]: *** [node.o] Error 1