allow non-numeric uid and gid

This commit is contained in:
roberto@ubuntu64
2010-08-22 18:31:18 +02:00
parent 0f0d5b2a5f
commit d71ea1404d
2 changed files with 24 additions and 0 deletions
+20
View File
@@ -2741,9 +2741,29 @@ void manage_opt(int i, char *optarg) {
break;
case LONG_ARGS_GID:
uwsgi.gid = atoi(optarg);
if (!uwsgi.gid) {
struct group *ugroup = getgrnam(optarg);
if (ugroup) {
uwsgi.gid = ugroup->gr_gid ;
}
else {
uwsgi_log("group %s not found.\n", optarg);
exit(1);
}
}
break;
case LONG_ARGS_UID:
uwsgi.uid = atoi(optarg);
if (!uwsgi.uid) {
struct passwd *upasswd = getpwnam(optarg);
if (upasswd) {
uwsgi.uid = upasswd->pw_uid ;
}
else {
uwsgi_log("user %s not found.\n", optarg);
exit(1);
}
}
break;
case LONG_ARGS_BINARY_PATH:
uwsgi.binary_path = optarg;
+4
View File
@@ -19,6 +19,10 @@
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <sys/utsname.h>
// linux has not strlcpy