diff options
author | Graham Dumpleton <Graham.Dumpleton@gmail.com> | 2015-10-12 16:44:33 +1100 |
---|---|---|
committer | Graham Dumpleton <Graham.Dumpleton@gmail.com> | 2015-10-12 16:44:33 +1100 |
commit | 73ff103f38fcf8b6c2f5cfac427cf493b3d87b7d (patch) | |
tree | a4acb487c308cf6ed506b5a8eaf7e21ccef08518 | |
parent | 76302e6831a81664bdb10b5590ba2780bb7892c0 (diff) | |
download | mod_wsgi-73ff103f38fcf8b6c2f5cfac427cf493b3d87b7d.tar.gz |
Don't attempt to set environment variables when no password entry for user ID.
-rw-r--r-- | docs/release-notes/version-4.4.19.rst | 8 | ||||
-rw-r--r-- | src/server/wsgi_interp.c | 28 |
2 files changed, 24 insertions, 12 deletions
diff --git a/docs/release-notes/version-4.4.19.rst b/docs/release-notes/version-4.4.19.rst index af251fb..372429b 100644 --- a/docs/release-notes/version-4.4.19.rst +++ b/docs/release-notes/version-4.4.19.rst @@ -9,3 +9,11 @@ Version 4.4.19 of mod_wsgi can be obtained from: For details on the availability of Windows binaries see: https://github.com/GrahamDumpleton/mod_wsgi/tree/master/win32 + +Bugs Fixed +---------- + +1. Daemon mode processes were crashing when attempting to set ``USER``, +``USERNAME``, ``LOGNAME`` or ``HOME`` when no password entry could be +found for the current user ID. Now do not attempt to set these if the +user ID doesn't have a password file entry. diff --git a/src/server/wsgi_interp.c b/src/server/wsgi_interp.c index 01f6bb3..a347e9e 100644 --- a/src/server/wsgi_interp.c +++ b/src/server/wsgi_interp.c @@ -631,7 +631,7 @@ InterpreterObject *newInterpreterObject(const char *name) pwent = getpwuid(geteuid()); - if (getenv("USER")) { + if (pwent && getenv("USER")) { #if PY_MAJOR_VERSION >= 3 key = PyUnicode_FromString("USER"); value = PyUnicode_Decode(pwent->pw_name, @@ -649,7 +649,7 @@ InterpreterObject *newInterpreterObject(const char *name) Py_DECREF(value); } - if (getenv("USERNAME")) { + if (pwent && getenv("USERNAME")) { #if PY_MAJOR_VERSION >= 3 key = PyUnicode_FromString("USERNAME"); value = PyUnicode_Decode(pwent->pw_name, @@ -667,7 +667,7 @@ InterpreterObject *newInterpreterObject(const char *name) Py_DECREF(value); } - if (getenv("LOGNAME")) { + if (pwent && getenv("LOGNAME")) { #if PY_MAJOR_VERSION >= 3 key = PyUnicode_FromString("LOGNAME"); value = PyUnicode_Decode(pwent->pw_name, @@ -718,20 +718,24 @@ InterpreterObject *newInterpreterObject(const char *name) struct passwd *pwent; pwent = getpwuid(geteuid()); + + if (pwent) { #if PY_MAJOR_VERSION >= 3 - key = PyUnicode_FromString("HOME"); - value = PyUnicode_Decode(pwent->pw_dir, strlen(pwent->pw_dir), - Py_FileSystemDefaultEncoding, - "surrogateescape"); + key = PyUnicode_FromString("HOME"); + value = PyUnicode_Decode(pwent->pw_dir, + strlen(pwent->pw_dir), + Py_FileSystemDefaultEncoding, + "surrogateescape"); #else - key = PyString_FromString("HOME"); - value = PyString_FromString(pwent->pw_dir); + key = PyString_FromString("HOME"); + value = PyString_FromString(pwent->pw_dir); #endif - PyObject_SetItem(object, key, value); + PyObject_SetItem(object, key, value); - Py_DECREF(key); - Py_DECREF(value); + Py_DECREF(key); + Py_DECREF(value); + } } Py_DECREF(module); |