From: Andy Green Date: Thu, 25 Feb 2016 07:15:41 +0000 (+0800) Subject: unix privs change group before user X-Git-Tag: upstream/1.7.3~13 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d2a95e0c82920184d27686d03c001323e4175ff7;p=platform%2Fupstream%2Flibwebsockets.git unix privs change group before user Otherwise we no longer have privs to change the group after doing the user Signed-off-by: Andy Green --- diff --git a/lib/lws-plat-unix.c b/lib/lws-plat-unix.c index ab8c9b1..354e9c6 100644 --- a/lib/lws-plat-unix.c +++ b/lib/lws-plat-unix.c @@ -270,6 +270,10 @@ lws_plat_set_socket_options(struct lws_context *context, int fd) LWS_VISIBLE void lws_plat_drop_app_privileges(struct lws_context_creation_info *info) { + if (info->gid != -1) + if (setgid(info->gid)) + lwsl_warn("setgid: %s\n", strerror(LWS_ERRNO)); + if (info->uid != -1) { struct passwd *p = getpwuid(info->uid); @@ -282,10 +286,6 @@ lws_plat_drop_app_privileges(struct lws_context_creation_info *info) } else lwsl_warn("getpwuid: unable to find uid %d", info->uid); } - if (info->gid != -1) - if (setgid(info->gid)) - lwsl_warn("setgid: %s\n", strerror(LWS_ERRNO)); - } static void