lueschem / edi

Embedded development infrastructure.
https://www.get-edi.io
GNU Lesser General Public License v3.0
39 stars 12 forks source link

Improve Proxy Handling on Ubuntu 18.04 Desktop #35

Closed lueschem closed 6 years ago

lueschem commented 6 years ago

Issue Type

Environment detail

+ cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
+ python3 --version
Python 3.6.5
+ ansible-playbook --version
ansible-playbook 2.5.1
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/lueschm1/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
+ lxc --version
3.0.0
+ dpkg -l
+ grep \(lxd\|ansible\)
ii  ansible                                    2.5.1+dfsg-1                         all          Configuration management, deployment, and task execution system
ii  lxd                                        3.0.0-0ubuntu4                       amd64        Container hypervisor based on LXC - daemon
ii  lxd-client                                 3.0.0-0ubuntu4                       amd64        Container hypervisor based on LXC - client

Desired Behaviour

sudo edi ... and edi ... shall use the same proxy settings.

Actual Behaviour

sudo edi ... does not take the proxy settings of the current user into account. The difference between Ubuntu 18.04 and Ubuntu 16.04 is that Ubuntu 16.04 had the possibility to apply the proxy settings system wide while for 18.04 it is only applied per user.

lueschem commented 6 years ago

Possible solution:

Apply the following algorithm:

  1. Try to fetch the proxy with printenv http_proxy (make sure there is no sudo involved)
  2. If it fails or the proxy is empty, check if gsettings is available and try to retrieve the proxy (see also https://developer.gnome.org/ProxyConfiguration/)

Hint: With sudo -E edi ... the (proxy) environment variables can be preserved.

lueschem commented 6 years ago

Notes about gsettings: Schema: https://github.com/GNOME/gsettings-desktop-schemas/blob/master/schemas/org.gnome.system.proxy.gschema.xml.in

Sample output:

lueschem@lueschem-xps:~$ gsettings list-recursively org.gnome.system.proxy
--> unused --> org.gnome.system.proxy use-same-proxy false
org.gnome.system.proxy mode 'manual'
org.gnome.system.proxy autoconfig-url 'http://foo.bar'
org.gnome.system.proxy ignore-hosts ['localhost', '127.0.0.0/8', '::1']
org.gnome.system.proxy.ftp host 'foo:bar@127.0.0.3'
org.gnome.system.proxy.ftp port 8080
org.gnome.system.proxy.socks host ''
org.gnome.system.proxy.socks port 8080
org.gnome.system.proxy.http host 'foo:bar@127.0.0.3'
org.gnome.system.proxy.http port 8080
org.gnome.system.proxy.http use-authentication false
org.gnome.system.proxy.http authentication-password ''
org.gnome.system.proxy.http authentication-user ''
--> unused --> org.gnome.system.proxy.http enabled false
org.gnome.system.proxy.https host ''
org.gnome.system.proxy.https port 8080

If org.gnome.system.proxy mode is set to 'auto' log a warning and do not set a proxy.

lueschem commented 6 years ago

Python bindings: https://pygobject.readthedocs.io/en/latest/