~mvo/aptdaemon/mvo

« back to all changes in this revision

Viewing changes to aptdaemon/core.py

  • Committer: Michael Vogt
  • Date: 2009-10-09 08:04:23 UTC
  • Revision ID: michael.vogt@ubuntu.com-20091009080423-h22mizy7f313xjm8
* aptdaemon/client.py:
  - add set_http_proxy() method to the transaction
* aptdaemon/core.py:
  - add new dbus Property "HttpProxy"
* aptdaemon/gtkwidgets.py:
  - setup http proxy from gconf automatically
* data/org.debian.apt.policy.in:
  - change from "allow_active" "yes" to "auth_admin_keep"
    The reasons is that now that a unpriviledged user can
    set a proxy this may leak passwords from sources.list
    (deb http://user:pass@machine/) when a rouge proxy is set

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
        self.uid = uid
150
150
        self.locale = None
151
151
        self.allow_unauthenticated = False
 
152
        self.http_proxy = ""
152
153
        self.terminal = None
153
154
        self.debconf = None
154
155
        self.kwargs = None
678
679
        else:
679
680
            self.locale = "%s.%s" % (lang, encoding)
680
681
 
 
682
    def _set_http_proxy(self, proxy):
 
683
        """Set a http network proxy 
 
684
           
 
685
           Keyword arguments:
 
686
           host - the proxy server
 
687
           port - the proxy port
 
688
        """
 
689
        if  proxy != "":
 
690
            if (not proxy.startswith("http://") or 
 
691
                not ":" in proxy):
 
692
                raise errors.InvalidProxyError(proxy)
 
693
        logging.debug("http proxy set to '%s'" % proxy)
 
694
        self.http_proxy = proxy
 
695
        apt_pkg.Config.Set("Acquire::http::Proxy", self.http_proxy)
 
696
 
681
697
    def _set_allow_unauthenticated(self, allow_unauthenticated):
682
698
        """Set the handling of unauthenticated packages 
683
699
 
879
895
                deferred.add_callback(lambda x: self._set_locale(value))
880
896
            elif property == "AllowUnauthenticated":
881
897
                deferred.add_callback(lambda x: self._set_allow_unauthenticated(value))
 
898
            elif property == "HttpProxy":
 
899
                deferred.add_callback(lambda x: self._set_http_proxy(value))
882
900
            else:
883
901
                raise dbus.exceptions.DBusException("Unknown or read only "
884
902
                                                    "property: %s" % property)
915
933
                    "DebconfSocket": self.debconf,
916
934
                    "Paused": self.paused,
917
935
                    "AllowUnauthenticated": self.allow_unauthenticated,
 
936
                    "HttpProxy": self.http_proxy,
918
937
                    }
919
938
        else:
920
939
            return {}