Skip to content

Commit

Permalink
unix privs change group before user
Browse files Browse the repository at this point in the history
Otherwise we no longer have privs to change the group after doing the user

Signed-off-by: Andy Green <andy.green@linaro.org>
  • Loading branch information
Andy Green committed Feb 25, 2016
1 parent a110180 commit 0a9bd7e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/lws-plat-unix.c
Expand Up @@ -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);

Expand All @@ -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
Expand Down

0 comments on commit 0a9bd7e

Please sign in to comment.