Skip to content

Commit

Permalink
Do not allow the user to specify the proxy in PackageKit.conf
Browse files Browse the repository at this point in the history
Allowing the user to specify it in the repo file, the config file and the
session is kinda crazy. PackageKit is a helper for the session rather than a
policy daemon, so allowing a system-wide override is kinda crazy.
  • Loading branch information
hughsie committed Nov 27, 2013
1 parent 0b3c7a7 commit 3afcfcd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 63 deletions.
15 changes: 0 additions & 15 deletions etc/PackageKit.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ DefaultBackend=@defaultbackend@
# default=false
UseSyslog=false

# Proxy settings, uncomment as required
#
# NOTE: PackageKit does not use these settings, they are passed to backends.
# Backends may ignore these values. If either of ProxyHTTP or ProxyFTP
# are set then the users proxy settings are ignored.
#
# They are in the format username:password@server:port
#
# ProxyHTTP=username:[email protected]:8080
# ProxyHTTPS=username:[email protected]:8080
# ProxyFTP=server.lan:21
# ProxySOCKS=server.lan:21
# NoProxy=internal.webserver
# PAC=/etc/proxy.pac

# Scan installed desktop files when we update or install packages
#
# NOTE: Don't enable this for backends that are slow doing SearchFile()
Expand Down
18 changes: 0 additions & 18 deletions src/pk-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct PkEnginePrivate
GTimer *timer;
gboolean notify_clients_of_upgrade;
gboolean shutdown_as_soon_as_possible;
gboolean using_hardcoded_proxy;
PkTransactionList *transaction_list;
PkTransactionDb *transaction_db;
PkBackend *backend;
Expand Down Expand Up @@ -551,13 +550,6 @@ pk_engine_action_obtain_proxy_authorization_finished_cb (PolkitAuthority *author
goto out;
}

/* admin already set value, so silently refuse value */
if (priv->using_hardcoded_proxy) {
g_debug ("cannot override admin set proxy");
g_dbus_method_invocation_return_value (state->context, NULL);
goto out;
}

/* try to set the new proxy and save to database */
ret = pk_engine_set_proxy_internal (state->engine,
state->sender,
Expand Down Expand Up @@ -1747,7 +1739,6 @@ static void
pk_engine_init (PkEngine *engine)
{
gchar *filename;
gchar *proxy_http;
GError *error = NULL;

engine->priv = PK_ENGINE_GET_PRIVATE (engine);
Expand Down Expand Up @@ -1811,13 +1802,6 @@ pk_engine_init (PkEngine *engine)
}
#endif

/* set the default proxy */
proxy_http = pk_conf_get_string (engine->priv->conf, "ProxyHTTP");

/* ignore the users proxy setting */
if (proxy_http != NULL)
engine->priv->using_hardcoded_proxy = TRUE;

/* get the StateHasChanged timeouts */
engine->priv->timeout_priority = (guint) pk_conf_get_int (engine->priv->conf, "StateChangedTimeoutPriority");
engine->priv->timeout_normal = (guint) pk_conf_get_int (engine->priv->conf, "StateChangedTimeoutNormal");
Expand Down Expand Up @@ -1851,8 +1835,6 @@ pk_engine_init (PkEngine *engine)
/* initialize plugins */
pk_engine_plugin_phase (engine,
PK_PLUGIN_PHASE_INIT);

g_free (proxy_http);
}

/**
Expand Down
50 changes: 20 additions & 30 deletions src/pk-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -1807,40 +1807,30 @@ pk_transaction_set_session_state (PkTransaction *transaction,
goto out;
}

/* get from config file */
proxy_http = pk_conf_get_string (priv->conf, "ProxyHTTP");
proxy_https = pk_conf_get_string (priv->conf, "ProxyHTTPS");
proxy_ftp = pk_conf_get_string (priv->conf, "ProxyFTP");
proxy_socks = pk_conf_get_string (priv->conf, "ProxySOCKS");
no_proxy = pk_conf_get_string (priv->conf, "NoProxy");
pac = pk_conf_get_string (priv->conf, "PAC");

/* fall back to database */
if (proxy_http == NULL) {
ret = pk_transaction_db_get_proxy (priv->transaction_db,
priv->uid,
session,
&proxy_http,
&proxy_https,
&proxy_ftp,
&proxy_socks,
&no_proxy,
&pac);
if (!ret) {
g_set_error_literal (error, 1, 0,
"failed to get the proxy from the database");
goto out;
}
/* get from database */
ret = pk_transaction_db_get_proxy (priv->transaction_db,
priv->uid,
session,
&proxy_http,
&proxy_https,
&proxy_ftp,
&proxy_socks,
&no_proxy,
&pac);
if (!ret) {
g_set_error_literal (error, 1, 0,
"failed to get the proxy from the database");
goto out;
}

/* try to set the new proxy */
pk_backend_job_set_proxy (priv->job,
proxy_http,
proxy_https,
proxy_ftp,
proxy_socks,
no_proxy,
pac);
proxy_http,
proxy_https,
proxy_ftp,
proxy_socks,
no_proxy,
pac);

/* try to set the new uid and cmdline */
cmdline = g_strdup_printf ("PackageKit: %s",
Expand Down

0 comments on commit 3afcfcd

Please sign in to comment.