diff --git a/client/pk-console.c b/client/pk-console.c index 6197312..2c2f97f 100644 --- a/client/pk-console.c +++ b/client/pk-console.c @@ -1851,6 +1851,7 @@ main (int argc, char *argv[]) guint cache_age = G_MAXUINT; gint retval_copy = 0; gboolean plain = FALSE; + gboolean allow_unauthenticated = FALSE; gboolean program_version = FALSE; gboolean run_mainloop = TRUE; GOptionContext *context; @@ -1886,6 +1887,9 @@ main (int argc, char *argv[]) { "cache-age", 'c', 0, G_OPTION_ARG_INT, &cache_age, /* TRANSLATORS: command line argument, just output without fancy formatting */ _("The maximum metadata cache age. Use -1 for 'never'."), NULL}, + { "allow-unauthenticated", '\0', 0, G_OPTION_ARG_NONE, &allow_unauthenticated, + /* command line argument, do we ask questions */ + _("Allow unauthenticated packages"), NULL }, { NULL} }; @@ -1974,6 +1978,7 @@ main (int argc, char *argv[]) "interactive", !noninteractive, "only-download", only_download, "cache-age", cache_age, + "only-trusted", !allow_unauthenticated, NULL); /* set the proxy */ diff --git a/lib/packagekit-glib2/pk-task.c b/lib/packagekit-glib2/pk-task.c index d81944d..d1f7531 100644 --- a/lib/packagekit-glib2/pk-task.c +++ b/lib/packagekit-glib2/pk-task.c @@ -50,12 +50,14 @@ struct _PkTaskPrivate GPtrArray *array; gboolean simulate; gboolean only_download; + gboolean only_trusted; }; enum { PROP_0, PROP_SIMULATE, PROP_ONLY_PREPARE, + PROP_ONLY_TRUSTED, PROP_LAST }; @@ -1250,7 +1252,10 @@ pk_task_install_files_async (PkTask *task, gchar **files, GCancellable *cancella state->task = g_object_ref (task); if (cancellable != NULL) state->cancellable = g_object_ref (cancellable); - state->transaction_flags = pk_bitfield_value (PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED); + if (task->priv->only_trusted) + state->transaction_flags = pk_bitfield_value (PK_TRANSACTION_FLAG_ENUM_ONLY_TRUSTED); + else + state->transaction_flags = 0; state->files = g_strdupv (files); state->progress_callback = progress_callback; state->progress_user_data = progress_user_data; @@ -2362,6 +2367,42 @@ pk_task_get_only_download (PkTask *task) return task->priv->only_download; } + +/** + * pk_task_set_only_trusted: + * @task: a valid #PkTask instance + * @only_trusted: %TRUE to allow only authenticated packages + * + * If only authenticated packages should be allowed in the + * transaction. + * + * Since: 0.9.5 + **/ +void +pk_task_set_only_trusted (PkTask *task, gboolean only_trusted) +{ + g_return_if_fail (PK_IS_TASK (task)); + task->priv->only_trusted = only_trusted; + g_object_notify (G_OBJECT (task), "only-download"); +} + +/** + * pk_task_get_only_trusted: + * @task: a valid #PkTask instance + * + * Gets if we allow only authenticated packages in the transactoin. + * + * Return value: %TRUE if we allow only authenticated packages + * + * Since: 0.9.5 + **/ +gboolean +pk_task_get_only_trusted (PkTask *task) +{ + g_return_val_if_fail (PK_IS_TASK (task), FALSE); + return task->priv->only_trusted; +} + /** * pk_task_get_property: **/ @@ -2378,6 +2419,9 @@ pk_task_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec case PROP_ONLY_PREPARE: g_value_set_boolean (value, priv->only_download); break; + case PROP_ONLY_TRUSTED: + g_value_set_boolean (value, priv->only_trusted); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2400,6 +2444,9 @@ pk_task_set_property (GObject *object, guint prop_id, const GValue *value, GPara case PROP_ONLY_PREPARE: priv->only_download = g_value_get_boolean (value); break; + case PROP_ONLY_TRUSTED: + priv->only_trusted = g_value_get_boolean (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2438,6 +2485,15 @@ pk_task_class_init (PkTaskClass *klass) G_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_ONLY_PREPARE, pspec); + /** + * PkTask:only-trusted: + * + * Since: 0.9.5 + */ + pspec = g_param_spec_boolean ("only-trusted", NULL, NULL, + TRUE, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ONLY_TRUSTED, pspec); g_type_class_add_private (klass, sizeof (PkTaskPrivate)); }