[Kimchi-devel] [PATCH] Changed the proxy.py to search for the http user used in Arch Linux

Aline Manera alinefm at linux.vnet.ibm.com
Wed Dec 2 18:54:46 UTC 2015



On 02/12/2015 13:38, stephan.conrad at gmail.com wrote:
> From: Stephan Conrad <stephan.conrad at gmail.com>
>
> Signed-off-by: Stephan Conrad <stephan.conrad at 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




More information about the Kimchi-devel mailing list