[packagekit] packagekit: Branch 'master' - 10 commits

Richard Hughes hughsient at kemper.freedesktop.org
Sun Oct 21 08:35:56 PDT 2007


 .gitignore                      |    4 
 backends/BACKENDS               |    6 -
 backends/alpm/pk-backend-alpm.c |   44 ++++++++++
 backends/box/pk-backend-box.c   |  124 ++++++++++++++++++++++++++---
 configure.ac                    |  169 +++++++++++++++++++++++-----------------
 html/pk-download.html           |    2 
 src/Makefile.am                 |   10 ++
 src/pk-security-dummy.c         |    3 
 src/pk-security-polkit.c        |    2 
 src/run-pk.sh                   |    9 +-
 10 files changed, 283 insertions(+), 90 deletions(-)

New commits:
commit a5e6116f8fecc0d4d5415009a04a73ed8b65e7c5
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Sat Oct 20 23:41:58 2007 -0400

    Add *.swp, tags, and *.patch to .gitignore

diff --git a/.gitignore b/.gitignore
index c8a84df..39b82ac 100644
--- a/.gitignore
+++ b/.gitignore
@@ -47,4 +47,6 @@ gtk-doc.make
 *~
 *.pc
 py-compile
-
+*.swp
+tags
+*.patch
commit 143cab1bb67cb9b8c200f29055105f6fc29abae9
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Sat Oct 20 19:20:23 2007 +0000

    [box] allow filtering when searching by a file

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 5f225c7..53e1d44 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -151,6 +151,12 @@ find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter
 
 	parse_filter (filter, &installed, &available, &devel, &nondevel, &gui, &text);
 
+	if (installed == TRUE) {
+		search_filter = search_filter | PKG_INSTALLED;
+	}
+	if (available == TRUE) {
+		search_filter = search_filter | PKG_AVAILABLE;
+	}
 	if (devel == TRUE) {
 		search_filter = search_filter | PKG_DEVEL;
 	}
@@ -172,10 +178,13 @@ find_packages_real (PkBackend *backend, const gchar *search, const gchar *filter
 	db = db_open();
 
 	if (mode == SEARCH_TYPE_FILE) {
-		/* TODO: allow filtering */
-		list = box_db_repos_search_file (db, search);
-		add_packages_from_list (backend, list, FALSE);
-		box_db_repos_package_list_free (list);
+		if (installed == FALSE && available == FALSE) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, "invalid search mode");
+		} else	{
+			list = box_db_repos_search_file_with_filter (db, search, search_filter);
+			add_packages_from_list (backend, list, FALSE);
+			box_db_repos_package_list_free (list);
+		}
 	} else if (mode == SEARCH_TYPE_RESOLVE) {
 		list = box_db_repos_packages_search_one (db, (gchar *)search);
 		add_packages_from_list (backend, list, FALSE);
commit d90e4a6bbda1d30e5ec798ee36333762d2ccb7e4
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Sat Oct 20 16:29:18 2007 +0000

    [box] Release memory in case of error. Simplified implementation of get_depends and get_requires functions.

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 1c0ecca..5f225c7 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -32,12 +32,16 @@
 #include <libbox/libbox-db-repos.h>
 
 enum PkgSearchType {
-    SEARCH_TYPE_NAME = 0,
-    SEARCH_TYPE_DETAILS = 1,
-    SEARCH_TYPE_FILE = 2,
-    SEARCH_TYPE_RESOLVE = 3
+	SEARCH_TYPE_NAME = 0,
+	SEARCH_TYPE_DETAILS = 1,
+	SEARCH_TYPE_FILE = 2,
+	SEARCH_TYPE_RESOLVE = 3
 };
 
+enum DepsType {
+	DEPS_TYPE_DEPENDS = 0,
+	DEPS_TYPE_REQUIRES = 1
+};
 
 typedef struct {
 	gchar *search;
@@ -47,6 +51,7 @@ typedef struct {
 
 typedef struct {
 	gchar *package_id;
+	gint type;
 } ThreadData;
 
 
@@ -262,7 +267,10 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	pi = pk_package_id_new_from_string (d->package_id);
 	if (pi == NULL) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
-		db_close(db);
+		pk_package_id_free (pi);
+		db_close (db);
+		g_free (d->package_id);
+		g_free (d);
 		return FALSE;
 	}
 
@@ -271,12 +279,15 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	/* only one element is returned */
 	list = box_db_repos_packages_search_by_data(db, pi->name, pi->version);
 
-	ps = (PackageSearch*) list->data;
 	if (list == NULL) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "cannot find package by id");
-		db_close(db);
+		pk_package_id_free (pi);
+		db_close (db);
+		g_free (d->package_id);
+		g_free (d);
 		return FALSE;
 	}
+	ps = (PackageSearch*) list->data;
 
 	files = box_db_repos_get_files_string (db, pi->name, pi->version);
 
@@ -295,68 +306,43 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 }
 
 static gboolean
-backend_get_depends_thread (PkBackend *backend, gpointer data)
+backend_get_depends_requires_thread (PkBackend *backend, gpointer data)
 {
 	PkPackageId *pi;
 	GList *list;
 	ThreadData *d = (ThreadData*) data;
 	sqlite3 *db;
 
-	db = db_open();
+	db = db_open ();
 
 	pi = pk_package_id_new_from_string (d->package_id);
 	if (pi == NULL) {
 		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
-		db_close(db);
+		db_close (db);
+		g_free (d->package_id);
+		g_free (d);
 		return FALSE;
 	}
 
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
 
-	list = box_db_repos_get_depends(db, pi->name);
-	add_packages_from_list (backend, list, FALSE);
-	box_db_repos_package_list_free (list);
-	pk_package_id_free (pi);
-
-	db_close(db);
-
-	g_free (d->package_id);
-	g_free (d);
-
-	return TRUE;
-}
-
-static gboolean
-backend_get_requires_thread (PkBackend *backend, gpointer data)
-{
-	PkPackageId *pi;
-	GList *list;
-	ThreadData *d = (ThreadData*) data;
-	sqlite3 *db;
-
-	db = db_open();
-
-	pi = pk_package_id_new_from_string (d->package_id);
-	if (pi == NULL) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
-		db_close(db);
-		return FALSE;
-	}
-
-	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+	if (d->type == DEPS_TYPE_DEPENDS)
+		list = box_db_repos_get_depends(db, pi->name);
+	else if (d->type == DEPS_TYPE_REQUIRES)
+		list = box_db_repos_get_requires(db, pi->name);
 
-	list = box_db_repos_get_requires(db, pi->name);
 	add_packages_from_list (backend, list, FALSE);
 	box_db_repos_package_list_free (list);
 	pk_package_id_free (pi);
 
-	db_close(db);
+	db_close (db);
 
 	g_free (d->package_id);
 	g_free (d);
 
 	return TRUE;
 }
+
 /* ===================================================================== */
 
 /**
@@ -406,7 +392,8 @@ backend_get_depends (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_get_depends_thread, data);
+		data->type = DEPS_TYPE_DEPENDS;
+		pk_backend_thread_helper (backend, backend_get_depends_requires_thread, data);
 	}
 }
 
@@ -444,7 +431,8 @@ backend_get_requires (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_get_requires_thread, data);
+		data->type = DEPS_TYPE_REQUIRES;
+		pk_backend_thread_helper (backend, backend_get_depends_requires_thread, data);
 	}
 }
 
commit 8d9798db382f92553aacaa42049db0a5e2319732
Author: Andreas Obergrusberger <tradiaz at yahoo.de>
Date:   Sat Oct 20 12:30:30 2007 -0700

    add get_repo_list to alpm backend

diff --git a/backends/BACKENDS b/backends/BACKENDS
index 75313cc..3e2b80a 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -18,7 +18,7 @@ get-depends       |        |  X  |     |  X  |      |
 get-requires      |   X    |     |     |  X  |      |
 get-description   |   X    |  X  |  X  |  X  |      |
 get-update-detail |        |     |     |     |      |
-get-repo-list     |        |     |     |     |      |
+get-repo-list     |        |     |     |     |  X   |
 repo-enable       |        |     |     |     |      |
 repo-set-data     |        |     |     |     |      |
 cancel-transaction|        |     |     |     |      |
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 0e3af37..fd1da1c 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -35,6 +35,7 @@
 
 static int progress_percentage;
 static int subprogress_percentage;
+PkBackend *install_backend = NULL;
 
 typedef struct _PackageSource
 {
@@ -65,7 +66,9 @@ void
 trans_prog_cb (pmtransprog_t prog, const char *pkgname, int percent,
                        int n, int remain)
 {
+  pk_debug ("Percentage is %i", percent);
   subprogress_percentage = percent;
+  pk_backend_change_percentage ((PkBackend *)install_backend, subprogress_percentage);
 }
 
 gboolean
@@ -90,6 +93,13 @@ update_progress (void *data)
   return TRUE;
 }
 
+gpointer
+state_notify (void *backend)
+{
+  g_timeout_add (300, update_subprogress, backend);
+  return backend;
+}
+
 alpm_list_t *
 my_list_mmerge (alpm_list_t *left, alpm_list_t *right, alpm_list_fn_cmp fn)
 {
@@ -383,12 +393,14 @@ backend_initialize (PkBackend *backend)
 static void
 backend_install_package (PkBackend *backend, const gchar *package_id)
 {
+  pk_debug ("hello %i", (int)backend);
   g_return_if_fail (backend != NULL);
   //alpm_list_t *syncdbs = alpm_option_get_syncdbs ();
   alpm_list_t *result = NULL;
   alpm_list_t *problems = NULL;
   PkPackageId *id = pk_package_id_new_from_string (package_id);
   pmtransflag_t flags = 0;
+  GThread *progress = NULL;
 
   flags |= PM_TRANS_FLAG_NODEPS;
 
@@ -436,6 +448,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
       pk_package_id_free (id);
       return;
     }
+  pk_debug ("init");
 
   alpm_trans_addtarget (id->name);
 
@@ -451,6 +464,16 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
       return;
     }
 
+  pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING,
+			    package_id,
+			    "An HTML widget for GTK+ 2.0");
+
+  progress = g_thread_create (state_notify,
+		  	(void *)backend,
+			TRUE,
+			NULL);
+ install_backend = backend; 
+
   if (alpm_trans_commit (&problems) != 0)
     {
       pk_backend_error_code (backend,
@@ -732,6 +755,25 @@ backend_install_file (PkBackend *backend, const gchar *path)
   pk_backend_finished (backend);
 }
 
+void
+backend_get_repo_list (PkBackend *backend)
+{
+  g_return_if_fail (backend != NULL);
+  backend_initialize (backend);
+  alpm_list_t *repos = alpm_option_get_syncdbs ();
+  if (repos == NULL)
+    pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR,
+				       alpm_strerror (pm_errno));
+  for (; repos; repos = alpm_list_next (repos))
+    {
+      pk_backend_repo_detail (backend, alpm_db_get_name ((pmdb_t *)repos), 
+			  /*alpm_db_get_url ((pmdb_t *)repos)*/ NULL, TRUE);
+    }
+  alpm_list_free (repos);
+  pk_backend_finished (backend);
+}
+  
+
 
 PK_BACKEND_OPTIONS (
 	"alpm",						/* description */
@@ -759,7 +801,7 @@ PK_BACKEND_OPTIONS (
 	backend_search_name,				/* search_name */
 	backend_install_package,			/* update_package */
 	NULL,						/* update_system */
-	NULL,						/* get_repo_list */
+	backend_get_repo_list,				/* get_repo_list */
 	NULL,						/* repo_enable */
 	NULL						/* repo_set_data */
 );
commit dc1c7327422b78d6ab78b337aef7eec71c080638
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Sat Oct 20 11:38:03 2007 +0000

    I think, box is 50% complete

diff --git a/html/pk-download.html b/html/pk-download.html
index 05e3a5c..a1c8115 100644
--- a/html/pk-download.html
+++ b/html/pk-download.html
@@ -93,8 +93,8 @@ For instance:
 <ul>
 <li>yum (95% complete)</li>
 <li>conary (70% complete)</li>
+<li>box (50% complete)</li>
 <li>apt (40% complete)</li>
-<li>box (10% complete)</li>
 <li>pacman/alpm (10% complete)</li>
 </ul>
 
commit 789ad57b33b1d92c14f717642d4023a38263bdbb
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Sat Oct 20 11:10:14 2007 +0000

    [box] implemented get_requires()

diff --git a/backends/BACKENDS b/backends/BACKENDS
index 26b4373..75313cc 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -15,7 +15,7 @@ install-file      |        |     |     |  X  |      |
 remove-package    |   X    |  X  |     |  X  |  X   |
 update-package    |        |     |     |  X  |      |
 get-depends       |        |  X  |     |  X  |      |
-get-requires      |   X    |     |     |     |      |
+get-requires      |   X    |     |     |  X  |      |
 get-description   |   X    |  X  |  X  |  X  |      |
 get-update-detail |        |     |     |     |      |
 get-repo-list     |        |     |     |     |      |
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index c2d0d90..1c0ecca 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -325,6 +325,38 @@ backend_get_depends_thread (PkBackend *backend, gpointer data)
 
 	return TRUE;
 }
+
+static gboolean
+backend_get_requires_thread (PkBackend *backend, gpointer data)
+{
+	PkPackageId *pi;
+	GList *list;
+	ThreadData *d = (ThreadData*) data;
+	sqlite3 *db;
+
+	db = db_open();
+
+	pi = pk_package_id_new_from_string (d->package_id);
+	if (pi == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+		db_close(db);
+		return FALSE;
+	}
+
+	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
+	list = box_db_repos_get_requires(db, pi->name);
+	add_packages_from_list (backend, list, FALSE);
+	box_db_repos_package_list_free (list);
+	pk_package_id_free (pi);
+
+	db_close(db);
+
+	g_free (d->package_id);
+	g_free (d);
+
+	return TRUE;
+}
 /* ===================================================================== */
 
 /**
@@ -398,6 +430,25 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 }
 
 /**
+ * backend_get_requires:
+ */
+static void
+backend_get_requires (PkBackend *backend, const gchar *package_id)
+{
+	ThreadData *data = g_new0(ThreadData, 1);
+
+	g_return_if_fail (backend != NULL);
+
+	if (data == NULL) {
+		pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory");
+		pk_backend_finished (backend);
+	} else {
+		data->package_id = g_strdup(package_id);
+		pk_backend_thread_helper (backend, backend_get_requires_thread, data);
+	}
+}
+
+/**
  * backend_get_updates:
  */
 static void
@@ -545,7 +596,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* cancel */
 	backend_get_depends,			/* get_depends */
 	backend_get_description,		/* get_description */
-	NULL,					/* get_requires */
+	backend_get_requires,			/* get_requires */
 	NULL,					/* get_update_detail */
 	backend_get_updates,			/* get_updates */
 	backend_install_package,		/* install_package */
commit 41cab28ad99458cde4cc5c03dadff24f7bc87a09
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date:   Sat Oct 20 10:42:21 2007 +0000

    [box] implemented get_depends()

diff --git a/backends/BACKENDS b/backends/BACKENDS
index 6df148a..26b4373 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -14,7 +14,7 @@ install-package   |   X    |  X  |     |  X  |  X   |
 install-file      |        |     |     |  X  |      |
 remove-package    |   X    |  X  |     |  X  |  X   |
 update-package    |        |     |     |  X  |      |
-get-depends       |        |  X  |     |     |      |
+get-depends       |        |  X  |     |  X  |      |
 get-requires      |   X    |     |     |     |      |
 get-description   |   X    |  X  |  X  |  X  |      |
 get-update-detail |        |     |     |     |      |
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 9a4985b..c2d0d90 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -294,6 +294,37 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	return TRUE;
 }
 
+static gboolean
+backend_get_depends_thread (PkBackend *backend, gpointer data)
+{
+	PkPackageId *pi;
+	GList *list;
+	ThreadData *d = (ThreadData*) data;
+	sqlite3 *db;
+
+	db = db_open();
+
+	pi = pk_package_id_new_from_string (d->package_id);
+	if (pi == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+		db_close(db);
+		return FALSE;
+	}
+
+	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
+	list = box_db_repos_get_depends(db, pi->name);
+	add_packages_from_list (backend, list, FALSE);
+	box_db_repos_package_list_free (list);
+	pk_package_id_free (pi);
+
+	db_close(db);
+
+	g_free (d->package_id);
+	g_free (d);
+
+	return TRUE;
+}
 /* ===================================================================== */
 
 /**
@@ -329,6 +360,25 @@ backend_get_filters (PkBackend *backend, PkEnumList *elist)
 }
 
 /**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id)
+{
+	ThreadData *data = g_new0(ThreadData, 1);
+
+	g_return_if_fail (backend != NULL);
+
+	if (data == NULL) {
+		pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory");
+		pk_backend_finished (backend);
+	} else {
+		data->package_id = g_strdup(package_id);
+		pk_backend_thread_helper (backend, backend_get_depends_thread, data);
+	}
+}
+
+/**
  * backend_get_description:
  */
 static void
@@ -493,7 +543,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* get_groups */
 	backend_get_filters,			/* get_filters */
 	NULL,					/* cancel */
-	NULL,					/* get_depends */
+	backend_get_depends,			/* get_depends */
 	backend_get_description,		/* get_description */
 	NULL,					/* get_requires */
 	NULL,					/* get_update_detail */
commit 0025dce8a44996ed336a0df3bdee9c2c5f14ca30
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Fri Oct 19 12:16:38 2007 -0400

    Add a backend parameter to run-pk.sh
    
    Use 'run-pk.sh BACKEND_NAME' to launch packagekitd with the given
    backend, or 'run-pk.sh' (no arguments) to use the dummy backend.

diff --git a/src/run-pk.sh b/src/run-pk.sh
index 283da33..2e24c64 100755
--- a/src/run-pk.sh
+++ b/src/run-pk.sh
@@ -1,4 +1,11 @@
+#!/bin/sh
+
+if [ "$1x" = "x" ]; then
+    BACKEND=dummy
+else
+    BACKEND=$1
+fi
 export G_DEBUG=fatal_criticals
 killall packagekitd
-./packagekitd --verbose --disable-timer --backend=dummy | tee debug.log
+./packagekitd --verbose --disable-timer --backend=$BACKEND | tee debug.log
 
commit 7269e42f203cdd546817a099d6a021e2cf9567aa
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 19 23:46:41 2007 +0100

    users have to manually specify --with-security-framework to get the dummy backend, this option is too dangerous to be a fall through

diff --git a/configure.ac b/configure.ac
index db686f3..8578cb7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -191,17 +191,17 @@ dnl - Compile time default choice of security framework
 dnl ---------------------------------------------------------------------------
 AC_ARG_WITH([security_framework],
 	    AS_HELP_STRING([--with-security-framework=<option>],
-			   [Default backend to use polkit,dummy (dummy)]))
+			   [Default security framework to use polkit,dummy]))
 # try and guess this if nothing is listed
 if test x$with_security_framework = x; then
 	if test -f /usr/bin/polkit-list-actions ; then
 		with_security_framework=polkit
 	else
-		with_security_framework=dummy
+		AC_MSG_ERROR([--with-security-framework explicitly required when not using PolicyKit or RBAC])
 	fi
 fi
 
-AC_DEFINE(security_framework, "$with_security_framework", [default backend prefix])
+AC_DEFINE(security_framework, "$with_security_framework", [default security framework])
 AC_SUBST(security_framework, "$with_security_framework")
 
 if test x$with_security_framework = xpolkit; then
@@ -217,7 +217,7 @@ if test x$with_security_framework = xpolkit; then
 	fi
 	AC_DEFINE(USE_SECURITY_POLKIT, "polkit", [if we should use PolicyKit])
 elif test x$with_security_framework = xdummy; then
-	AC_DEFINE(USE_SECURITY_DUMMY, "dummy", [if we should use a dummy auth backend])
+	AC_DEFINE(USE_SECURITY_DUMMY, "dummy", [if we should use a dummy security framework])
 fi
 
 AM_CONDITIONAL(SECURITY_TYPE_DUMMY, [test x$with_security_framework = xdummy], [using dummy security framework])
@@ -436,6 +436,8 @@ echo "
 
 # warn that dummy is basically broken
 if test x$with_security_framework = xdummy; then
-	echo "YOU ARE NOT USING A SECURE DAEMON. ALL USERS CAN DO ANYTHING!"
+	echo "*******************************************************************"
+	echo "** YOU ARE NOT USING A SECURE DAEMON. ALL USERS CAN DO ANYTHING! **"
+	echo "*******************************************************************"
 fi
 
diff --git a/src/pk-security-dummy.c b/src/pk-security-dummy.c
index afb7d22..1d51d60 100644
--- a/src/pk-security-dummy.c
+++ b/src/pk-security-dummy.c
@@ -91,7 +91,8 @@ pk_security_class_init (PkSecurityClass *klass)
 static void
 pk_security_init (PkSecurity *security)
 {
-	pk_warning ("THERE IS NO SECURITY MODEL BEING USED!!!");
+	pk_debug ("Using dummy security framework");
+	pk_warning ("*** THERE IS NO SECURITY MODEL BEING USED!!! ***");
 }
 
 /**
diff --git a/src/pk-security-polkit.c b/src/pk-security-polkit.c
index b304259..acf03f0 100644
--- a/src/pk-security-polkit.c
+++ b/src/pk-security-polkit.c
@@ -172,6 +172,8 @@ pk_security_init (PkSecurity *security)
 
 	security->priv = PK_SECURITY_GET_PRIVATE (security);
 
+	pk_debug ("Using PolicyKit security framework");
+
 	/* get a connection to the bus */
 	dbus_error_init (&dbus_error);
 	security->priv->connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error);
commit 9cd4aa8a6abb9cf0aca8d3ba433aacaffc8a07f0
Author: Richard Hughes <richard at hughsie.com>
Date:   Fri Oct 19 23:25:38 2007 +0100

    give a compile time option for a security framework
    WARNING: Using a 'dummy' framework essentially is no security. Do not do this.

diff --git a/configure.ac b/configure.ac
index ecf4e8c..db686f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -12,7 +12,7 @@ AM_CONFIG_HEADER(config.h)
 # increment;
 # CURRENT	If the API or ABI interface has changed (reset REVISION to 0)
 # REVISION	If the API and ABI remains the same, but bugs are fixed.
-# AGE		If libpackagekit can be linked into executables which can be 
+# AGE		If libpackagekit can be linked into executables which can be
 # 		built with previous versions of this library. Don't use.
 LT_CURRENT=2
 LT_REVISION=0
@@ -37,8 +37,8 @@ dnl ---------------------------------------------------------------------------
 dnl - Extra verbose warning switches
 dnl ---------------------------------------------------------------------------
 if test "$GCC" = "yes"; then
-    CPPFLAGS="$CPPFLAGS -Werror -Wcast-align -Wno-uninitialized"
-    CPPFLAGS="$CPPFLAGS -Wall"
+	CPPFLAGS="$CPPFLAGS -Werror -Wcast-align -Wno-uninitialized"
+	CPPFLAGS="$CPPFLAGS -Wall"
 fi
 
 dnl ---------------------------------------------------------------------------
@@ -94,16 +94,6 @@ PKG_CHECK_MODULES(LIBNM, \
 AC_SUBST(LIBNM_CFLAGS)
 AC_SUBST(LIBNM_LIBS)
 
-PKG_CHECK_MODULES(POLKIT, \
- polkit-dbus >= $POLKIT_DBUS_REQUIRED \
- polkit-grant >= $POLKIT_GRANT_REQUIRED)
-
-AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
-              [polkit-policy-file-validate], [polkit-policy-file-validate])
-if test -z "$POLKIT_POLICY_FILE_VALIDATE"; then
-   AC_MSG_ERROR([polkit-policy-file-validate not found])
-fi
-
 dnl ---------------------------------------------------------------------------
 dnl - Is docbook2man available?
 dnl ---------------------------------------------------------------------------
@@ -124,11 +114,11 @@ AC_SUBST(LOCALSTATEDIR, $localstatedir)
 
 AC_ARG_WITH([packagekit_user],
 	    AS_HELP_STRING([--with-packagekit-user=<user>],
-	                   [User for running the PackageKit daemon (root)]))
+			   [User for running the PackageKit daemon (root)]))
 if test -z "$with_packagekit_user" ; then
-    PACKAGEKIT_USER=root
+	PACKAGEKIT_USER=root
 else
-    PACKAGEKIT_USER=$with_packagekit_user
+	PACKAGEKIT_USER=$with_packagekit_user
 fi
 AC_SUBST(PACKAGEKIT_USER)
 AC_DEFINE_UNQUOTED(PACKAGEKIT_USER,"$PACKAGEKIT_USER", [User for running the PackageKit daemon])
@@ -140,9 +130,9 @@ AC_ARG_ENABLE(tests, [  --enable-tests          Build self tests],enable_tests=$
 AC_MSG_CHECKING([whether to support tests])
 have_tests=no
 if test x$enable_tests = xyes ; then
-    have_tests=yes
+	have_tests=yes
 	AC_MSG_RESULT([yes])
-    AC_DEFINE(HAVE_TESTS, 1, [Define if we want to use the self tests])
+	AC_DEFINE(HAVE_TESTS, 1, [Define if we want to use the self tests])
 else
 	AC_MSG_RESULT([no])
 fi
@@ -152,11 +142,11 @@ dnl ---------------------------------------------------------------------------
 dnl - Are we specifying a different dbus root ?
 dnl ---------------------------------------------------------------------------
 AC_ARG_WITH(dbus-sys,
-              [AC_HELP_STRING([--with-dbus-sys=<dir>],
-              [where D-BUS system.d directory is])])
+	      [AC_HELP_STRING([--with-dbus-sys=<dir>],
+	      [where D-BUS system.d directory is])])
 AC_ARG_WITH(dbus-services,
-              [AC_HELP_STRING([--with-dbus-services=<dir>],
-              [where D-BUS system-services directory is])])
+	      [AC_HELP_STRING([--with-dbus-services=<dir>],
+	      [where D-BUS system-services directory is])])
 if ! test -z "$with_dbus_sys" ; then
 	DBUS_SYS_DIR="$with_dbus_sys"
 else
@@ -177,26 +167,63 @@ AC_ARG_ENABLE(docbook-docs, [  --enable-docbook-docs   build documentation (requ
 AC_PATH_PROG(XMLTO, xmlto, no)
 AC_MSG_CHECKING([whether to build DocBook documentation])
 if test x$XMLTO = xno ; then
-    have_docbook=no
+	have_docbook=no
 else
-    have_docbook=yes
+	have_docbook=yes
 fi
 if test x$enable_docbook_docs = xauto ; then
-    if test x$have_docbook = xno ; then
-        enable_docbook_docs=no
-    else
-        enable_docbook_docs=yes
-    fi
+	if test x$have_docbook = xno ; then
+		enable_docbook_docs=no
+	else
+		enable_docbook_docs=yes
+	fi
 fi
 if test x$enable_docbook_docs = xyes; then
-    if test x$have_docbook = xno; then
-	AC_MSG_ERROR([Building DocBook docs explicitly required, but DocBook not found])
-    fi
+	if test x$have_docbook = xno; then
+		AC_MSG_ERROR([Building DocBook docs explicitly required, but DocBook not found])
+	fi
 fi
 AM_CONDITIONAL(DOCBOOK_DOCS_ENABLED, test x$enable_docbook_docs = xyes)
 AC_MSG_RESULT(yes)
 
 dnl ---------------------------------------------------------------------------
+dnl - Compile time default choice of security framework
+dnl ---------------------------------------------------------------------------
+AC_ARG_WITH([security_framework],
+	    AS_HELP_STRING([--with-security-framework=<option>],
+			   [Default backend to use polkit,dummy (dummy)]))
+# try and guess this if nothing is listed
+if test x$with_security_framework = x; then
+	if test -f /usr/bin/polkit-list-actions ; then
+		with_security_framework=polkit
+	else
+		with_security_framework=dummy
+	fi
+fi
+
+AC_DEFINE(security_framework, "$with_security_framework", [default backend prefix])
+AC_SUBST(security_framework, "$with_security_framework")
+
+if test x$with_security_framework = xpolkit; then
+	PKG_CHECK_MODULES(POLKIT, \
+			  polkit-dbus >= $POLKIT_DBUS_REQUIRED \
+			  polkit-grant >= $POLKIT_GRANT_REQUIRED)
+	AC_SUBST(POLKIT_CFLAGS)
+	AC_SUBST(POLKIT_LIBS)
+	AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
+		      [polkit-policy-file-validate], [polkit-policy-file-validate])
+	if test -z "$POLKIT_POLICY_FILE_VALIDATE"; then
+	   AC_MSG_ERROR([polkit-policy-file-validate not found])
+	fi
+	AC_DEFINE(USE_SECURITY_POLKIT, "polkit", [if we should use PolicyKit])
+elif test x$with_security_framework = xdummy; then
+	AC_DEFINE(USE_SECURITY_DUMMY, "dummy", [if we should use a dummy auth backend])
+fi
+
+AM_CONDITIONAL(SECURITY_TYPE_DUMMY, [test x$with_security_framework = xdummy], [using dummy security framework])
+AM_CONDITIONAL(SECURITY_TYPE_POLKIT, [test x$with_security_framework = xpolkit], [using PolicyKit security framework])
+
+dnl ---------------------------------------------------------------------------
 dnl - Compile time default choice of backend
 dnl ---------------------------------------------------------------------------
 AC_ARG_WITH([default_backend],
@@ -204,20 +231,19 @@ AC_ARG_WITH([default_backend],
 			   [Default backend to use alpm,apt,box,conary,dummy,yum (dummy)]))
 # default to a sane option for the installed tool
 if test x$with_default_backend = x; then
-    if test -f /usr/bin/yum ; then
-        with_default_backend=yum
-    elif test -f /usr/lib/libalpm.so; then
-	with_default_backend=alpm
-    elif test -f /usr/bin/apt-get ; then
-        with_default_backend=apt
-    elif test -f /usr/bin/conary ; then
-        with_default_backend=conary
-    elif test -f /usr/bin/box-repos ; then
-        with_default_backend=box
-    else
-        with_default_backend=dummy
-        AC_DEFINE(IGNORE_POLKIT, "err...", [if we should disable polkit])
-    fi
+	if test -f /usr/bin/yum ; then
+		with_default_backend=yum
+	elif test -f /usr/lib/libalpm.so; then
+		with_default_backend=alpm
+	elif test -f /usr/bin/apt-get ; then
+		with_default_backend=apt
+	elif test -f /usr/bin/conary ; then
+		with_default_backend=conary
+	elif test -f /usr/bin/box-repos ; then
+		with_default_backend=box
+	else
+		with_default_backend=dummy
+	fi
 fi
 
 AC_DEFINE(DEFAULT_BACKEND, "$with_default_backend", [default backend prefix])
@@ -231,7 +257,7 @@ AC_DEFUN([APT_BACKEND],
 	   CPPFLAGS="$APT_CFLAGS $CPPFLAGS"
 	   _APT_save_libs=$LIBS
 	   LIBS="$APT_LIBS $LIBS"
-	   
+
 	   AC_MSG_CHECKING([for apt support for $1 packages])
 		AC_RUN_IFELSE(AC_LANG_PROGRAM([
 		#include <apt-pkg/configuration.h>
@@ -267,24 +293,24 @@ AC_DEFUN([APT_BACKEND],
 ])
 
 if test x$with_default_backend = xapt; then
-   
+
    AC_ARG_WITH(libapt-pkg-lib,
-     AC_HELP_STRING([--with-libapt-pkg-lib=DIR],[look for the libapt-pkg library in DIR]),
-     [_libaptpkg_with_lib=$withval],[_libaptpkg_with_lib=no])
+	 AC_HELP_STRING([--with-libapt-pkg-lib=DIR],[look for the libapt-pkg library in DIR]),
+	 [_libaptpkg_with_lib=$withval],[_libaptpkg_with_lib=no])
   	if test "$_libaptpkg_with_lib" == "no" ; then
 		APT_LIBS="-lapt-pkg"
-    else
-        APT_LIBS="-L$withval -lapt-pkg"
-	fi	
+	else
+		APT_LIBS="-L$withval -lapt-pkg"
+	fi
 
    AC_ARG_WITH(libapt-pkg-includes,
-     AC_HELP_STRING([--with-libapt-pkg-includes=DIR],[look for the libapt-pkg includes in DIR]),
-     [_libaptpkg_with_inc=$withval],[_libaptpkg_with_inc=no])
+	 AC_HELP_STRING([--with-libapt-pkg-includes=DIR],[look for the libapt-pkg includes in DIR]),
+	 [_libaptpkg_with_inc=$withval],[_libaptpkg_with_inc=no])
   	if test "$_libaptpkg_with_inc" == "no" ; then
 		APT_CFLAGS="-I/usr/include/apt-pkg"
-    else
+	else
 		APT_CFLAGS="-I$withval"
-	fi	
+	fi
 
 	AC_CACHE_CHECK([whether libapt-pkg is usable],
 	   [libaptpkg_usable],
@@ -319,17 +345,17 @@ if test x$with_default_backend = xapt; then
 	   unset _libaptpkg_save_cppflags
 	   unset _libaptpkg_save_libs
 	   ])
-    AC_LANG_POP(C++)
+	AC_LANG_POP(C++)
 
 	APT_BACKEND(deb,DEB)
 	APT_BACKEND(rpm,RPM)
   	if test "$APT_PKG_TYPE" == "" ; then
 		AC_MSG_ERROR([Couldn't find support for any type of packages that we know about for Apt!])
 	fi
-		
-    AC_SUBST(APT_CFLAGS)
-    AC_SUBST(APT_LIBS)
-    AC_SUBST(APT_PKG_TYPE)
+
+	AC_SUBST(APT_CFLAGS)
+	AC_SUBST(APT_LIBS)
+	AC_SUBST(APT_PKG_TYPE)
 fi
 
 if test x$with_default_backend = xbox; then
@@ -339,13 +365,12 @@ if test x$with_default_backend = xbox; then
 fi
 
 if test x$with_default_backend = xalpm; then
-    with_default_backend=dummy
-    AC_MSG_WARN([The alpm backend doesn't work at all!])
-    AC_CHECK_HEADER([alpm.h],
-		    [with_default_backend=alpm],
-		    [AC_MSG_WARN([No alpm headers found - falling back to dummy backend])])
+	with_default_backend=dummy
+	AC_MSG_WARN([The alpm backend doesn't work at all!])
+	AC_CHECK_HEADER([alpm.h],
+			[with_default_backend=alpm],
+			[AC_MSG_WARN([No alpm headers found - falling back to dummy backend])])
 fi
-    
 
 AC_SUBST(PK_CONF_DIR, "\$(sysconfdir)/PackageKit")
 AC_SUBST(PK_DB_DIR, "\$(localstatedir)/lib/PackageKit")
@@ -406,5 +431,11 @@ echo "
         compiler:                  ${CC}
         cflags:                    ${CFLAGS}
         Default backend:           ${with_default_backend}
+        Security Framework:        ${with_security_framework}
 "
 
+# warn that dummy is basically broken
+if test x$with_security_framework = xdummy; then
+	echo "YOU ARE NOT USING A SECURE DAEMON. ALL USERS CAN DO ANYTHING!"
+fi
+
diff --git a/src/Makefile.am b/src/Makefile.am
index 4f99bb7..6b17868 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,7 +46,6 @@ packagekitd_SOURCES =					\
 	pk-backend.c					\
 	pk-backend.h					\
 	pk-security.h					\
-	pk-security-polkit.c				\
 	pk-conf.c					\
 	pk-conf.h					\
 	pk-spawn.c					\
@@ -65,6 +64,14 @@ packagekitd_SOURCES =					\
 	pk-transaction-list.h				\
 	$(NULL)
 
+if SECURITY_TYPE_POLKIT
+packagekitd_SOURCES += pk-security-polkit.c
+endif
+
+if SECURITY_TYPE_DUMMY
+packagekitd_SOURCES += pk-security-dummy.c
+endif
+
 packagekitd_LDADD =					\
 	$(GLIB_LIBS)					\
 	$(GMODULE_LIBS)					\
@@ -147,6 +154,7 @@ pk_self_test_CPPFLAGS=	\
 
 EXTRA_DIST =						\
 	pk-marshal.list					\
+	pk-security-polkit.c				\
 	pk-security-dummy.c				\
 	pk-interface.xml				\
 	$(NULL)



More information about the PackageKit mailing list