1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

lws_get_effective_uid_gid

This helper lets you find out the eventual uid / gid lws will run
under before the root privileges are actually dropped
This commit is contained in:
Andy Green 2018-08-02 19:15:19 +08:00
parent 69d9cf2e6b
commit 9df3557ef9
2 changed files with 22 additions and 0 deletions

View file

@ -2894,6 +2894,13 @@ lws_finalize_startup(struct lws_context *context)
return 0;
}
LWS_VISIBLE LWS_EXTERN void
lws_get_effective_uid_gid(struct lws_context *context, int *uid, int *gid)
{
*uid = context->uid;
*gid = context->gid;
}
int
lws_snprintf(char *str, size_t size, const char *format, ...)
{

View file

@ -5930,6 +5930,21 @@ lws_get_parent(const struct lws *wsi);
LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT
lws_get_child(const struct lws *wsi);
/**
* lws_get_effective_uid_gid() - find out eventual uid and gid while still root
*
* \param context: lws context
* \param uid: pointer to uid result
* \param gid: pointer to gid result
*
* This helper allows you to find out what the uid and gid for the process will
* be set to after the privileges are dropped, beforehand. So while still root,
* eg in LWS_CALLBACK_PROTOCOL_INIT, you can arrange things like cache dir
* and subdir creation / permissions down /var/cache dynamically.
*/
LWS_VISIBLE LWS_EXTERN void
lws_get_effective_uid_gid(struct lws_context *context, int *uid, int *gid);
/**
* lws_get_udp() - get wsi's udp struct
*