[PATCH] Changed the proxy.py

From: Stephan Conrad <stephan.conrad@gmail.com> I changed the proxy.py to search for the http user which is used in Arch Linux. The new way to lookup if a user exist do not use an exception and is also extenable for other users. Stephan Conrad (1): Changed the proxy.py to search for the http user used in Arch Linux src/wok/proxy.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) -- 2.6.2

From: Stephan Conrad <stephan.conrad@gmail.com> Signed-off-by: Stephan Conrad <stephan.conrad@gmail.com> --- src/wok/proxy.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wok/proxy.py b/src/wok/proxy.py index 10008da..574a3b3 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -47,11 +47,13 @@ def _create_proxy_config(options): # User that will run the worker process of the proxy. Fedora, # RHEL and Suse creates an user called 'nginx' when installing # the proxy. Ubuntu creates an user 'www-data' for it. - user_proxy = 'nginx' - try: - pwd.getpwnam(user_proxy) - except KeyError: - user_proxy = 'www-data' + user_proxy = None + user_list = ('nginx', 'www-data', 'http') + sys_users = [p.pw_name for p in pwd.getpwall()] + for user in user_list: + if user in sys_users: + user_proxy = user + break config_dir = paths.conf_dir nginx_config_dir = paths.nginx_conf_dir -- 2.6.2

On 02/12/2015 13:38, stephan.conrad@gmail.com wrote:
From: Stephan Conrad <stephan.conrad@gmail.com>
Signed-off-by: Stephan Conrad <stephan.conrad@gmail.com> --- src/wok/proxy.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/wok/proxy.py b/src/wok/proxy.py index 10008da..574a3b3 100644 --- a/src/wok/proxy.py +++ b/src/wok/proxy.py @@ -47,11 +47,13 @@ def _create_proxy_config(options): # User that will run the worker process of the proxy. Fedora, # RHEL and Suse creates an user called 'nginx' when installing # the proxy. Ubuntu creates an user 'www-data' for it. - user_proxy = 'nginx' - try: - pwd.getpwnam(user_proxy) - except KeyError: - user_proxy = 'www-data'
+ user_proxy = None + user_list = ('nginx', 'www-data', 'http') + sys_users = [p.pw_name for p in pwd.getpwall()] + for user in user_list: + if user in sys_users: + user_proxy = user + break
You can use set() to make it simpler and get the intersection between the 2 groups of information. common_users = list(set(user_list) & set(sys_users)) if len(common_users) == 0: # should we raise an exception? else: user_proxy = common_users[0]
config_dir = paths.conf_dir nginx_config_dir = paths.nginx_conf_dir
participants (2)
-
Aline Manera
-
stephan.conrad@gmail.com