From dacad8d9b9bf0ab360ca857244eeecc42e4fd77c Mon Sep 17 00:00:00 2001 From: Unbit Date: Thu, 19 Dec 2013 17:06:49 +0100 Subject: [PATCH] added magic vars for uid and gid --- core/uwsgi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/uwsgi.c b/core/uwsgi.c index 53544df6..02a7afdc 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -2044,6 +2044,12 @@ void uwsgi_setup(int argc, char *argv[], char *envp[]) { uwsgi.magic_table['V'] = UWSGI_VERSION; uwsgi.magic_table['k'] = uwsgi_num2str(uwsgi.cpus); uwsgi.magic_table['['] = "\033"; + uwsgi.magic_table['u'] = uwsgi_num2str((int)getuid()); + struct passwd *pw = getpwuid(getuid()); + uwsgi.magic_table['U'] = pw ? pw->pw_name : uwsgi.magic_table['u']; + uwsgi.magic_table['g'] = uwsgi_num2str((int)getgid()); + struct group *gr = getgrgid(getgid()); + uwsgi.magic_table['G'] = gr ? gr->gr_name : uwsgi.magic_table['g']; // you can embed a ini file in the uWSGi binary with default options #ifdef UWSGI_EMBED_CONFIG