From: Ye Holmes <yehol...@outlook.com> Output warning in case changing the ownership of ubus' home directory has failed. Besides, this avoids treating unused result warning as error by GCC (with glibc-2.31, version 10.2):
procd-2020-12-12-7f12c89d/state.c: In function 'state_enter': procd-2020-12-12-7f12c89d/state.c:147:4: error: ignoring return value of 'chown' declared with attribute 'warn_unused_result' [-Werror=unused-result] 147 | chown(p->pw_dir, p->pw_uid, p->pw_gid); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Ye Holmes <yehol...@outlook.com> --- state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/state.c b/state.c index 44f56c6..d68776f 100644 --- a/state.c +++ b/state.c @@ -144,7 +144,8 @@ static void state_enter(void) if (p) { LOG("- ubus -\n"); mkdir(p->pw_dir, 0755); - chown(p->pw_dir, p->pw_uid, p->pw_gid); + if (chown(p->pw_dir, p->pw_uid, p->pw_gid)) + fprintf(stderr, "Failed to change ownership for %s\n", p->pw_dir); } else { LOG("- ubus (running as root!) -\n"); } -- 2.25.1 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel