Ubuntu 18.05 with gcc-7.5 yields following error:
ubox/log/logd.c:263:3: error: ignoring return value of ‘setuid’, declared with attribute warn_unused_result [-Werror=unused-result]
setuid(p->pw_uid);
^~~~~~~~~~~~~~~~~
ubox/log/logd.c:264:3: error: ignoring return value of ‘setgid’, declared with attribute warn_unused_result [-Werror=unused-result]
setgid(p->pw_gid);
^~~~~~~~~~~~~~~~~
Fixes: 9ef886819dd4 ("logd: self-degrade to 'logd' user after opening pipes")
Signed-off-by: Petr Štetiar <ynezz@true.cz>
ubus_auto_connect(&conn);
p = getpwnam("logd");
if (p) {
- setuid(p->pw_uid);
- setgid(p->pw_gid);
+ if (setuid(p->pw_uid) < 0) {
+ fprintf(stderr, "setuid() failed: %s\n", strerror(errno));
+ exit(1);
+ }
+
+ if (setgid(p->pw_gid) < 0) {
+ fprintf(stderr, "setgid() failed: %s\n", strerror(errno));
+ exit(1);
+ }
}
uloop_run();
log_shutdown();