From fa1064db879083d23a0bb4325d0e891a19ee8424 Mon Sep 17 00:00:00 2001 From: "roberto@debian32" Date: Fri, 28 Oct 2011 16:10:26 +0200 Subject: [PATCH] added --umask --- uwsgi.c | 19 +++++++++++++++++++ uwsgi.h | 1 + 2 files changed, 20 insertions(+) diff --git a/uwsgi.c b/uwsgi.c index 0741fcab..0beee5c1 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -70,6 +70,7 @@ static struct option long_base_options[] = { {"abstract-socket", no_argument, 0, 'a'}, {"chmod-socket", optional_argument, 0, 'C'}, {"chown-socket", required_argument, 0, LONG_ARGS_CHOWN_SOCKET}, + {"umask", required_argument, 0, LONG_ARGS_UMASK}, #ifdef __linux__ {"freebind", no_argument, &uwsgi.freebind, 1}, #endif @@ -2928,6 +2929,7 @@ static int manage_base_opt(int i, char *optarg) { struct uwsgi_cron *uc, *old_uc; struct uwsgi_socket *uwsgi_sock = NULL; int zerg_fd; + mode_t umask_mode; switch (i) { @@ -3717,6 +3719,23 @@ static int manage_base_opt(int i, char *optarg) { case LONG_ARGS_CHOWN_SOCKET: uwsgi.chown_socket = optarg; return 1; + case LONG_ARGS_UMASK: + if (strlen(optarg) < 3) { + uwsgi_log("invalid umask: %s\n", optarg); + } + umask_mode = 0; + if (strlen(optarg) == 3) { + umask_mode = (umask_mode << 3) + (optarg[0] - '0'); + umask_mode = (umask_mode << 3) + (optarg[1] - '0'); + umask_mode = (umask_mode << 3) + (optarg[2] - '0'); + } + else { + umask_mode = (umask_mode << 3) + (optarg[1] - '0'); + umask_mode = (umask_mode << 3) + (optarg[2] - '0'); + umask_mode = (umask_mode << 3) + (optarg[3] - '0'); + } + umask(umask_mode); + return 1; case 'C': uwsgi.chmod_socket = 1; if (optarg) { diff --git a/uwsgi.h b/uwsgi.h index 686a805a..6a8d5cbd 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -537,6 +537,7 @@ struct uwsgi_opt { #define LONG_ARGS_FARM 17157 #define LONG_ARGS_MULES 17158 #define LONG_ARGS_PROCNAME_PREFIX_SP 17159 +#define LONG_ARGS_UMASK 17160 #define UWSGI_OK 0