|
|
55e633 |
From dec0fe1bef1424edc80902234d9730f66a586a07 Mon Sep 17 00:00:00 2001
|
|
|
55e633 |
From: Richard Hughes <richard@hughsie.com>
|
|
|
55e633 |
Date: Tue, 28 Jul 2015 16:49:10 +0100
|
|
|
55e633 |
Subject: [PATCH] yum: Record the UID of the session user in the yumdb
|
|
|
55e633 |
|
|
|
55e633 |
---
|
|
|
55e633 |
backends/yum/yumBackend.py | 9 +++++++++
|
|
|
55e633 |
lib/python/packagekit/backend.py | 7 +++++++
|
|
|
55e633 |
src/pk-backend-spawn.c | 6 ++++++
|
|
|
55e633 |
3 files changed, 22 insertions(+)
|
|
|
55e633 |
|
|
|
55e633 |
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
|
|
|
55e633 |
index 030f965..f097034 100755
|
|
|
55e633 |
--- a/backends/yum/yumBackend.py
|
|
|
55e633 |
+++ b/backends/yum/yumBackend.py
|
|
|
55e633 |
@@ -2299,6 +2299,12 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
|
|
|
55e633 |
self.percentage(100)
|
|
|
55e633 |
return
|
|
|
55e633 |
|
|
|
55e633 |
+ # this is set to the calling using to avoid reading /proc/self/loginuid
|
|
|
55e633 |
+ # and always returning '0' for the pacakgekitd user.
|
|
|
55e633 |
+ #
|
|
|
55e633 |
+ # Yes, it's global. No, I don't think that's a wise design choice.
|
|
|
55e633 |
+ _cached_getloginuid = self.uid
|
|
|
55e633 |
+
|
|
|
55e633 |
try:
|
|
|
55e633 |
rpmDisplay = PackageKitCallback(self)
|
|
|
55e633 |
callback = ProcessTransPackageKitCallback(self)
|
|
|
55e633 |
@@ -2339,6 +2345,9 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
|
|
|
55e633 |
except Exception, e:
|
|
|
55e633 |
raise PkError(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc()))
|
|
|
55e633 |
|
|
|
55e633 |
+ # do a mostly pointless verification just to write the yumdb entries
|
|
|
55e633 |
+ self.yumbase.verifyTransaction()
|
|
|
55e633 |
+
|
|
|
55e633 |
def remove_packages(self, transaction_flags, package_ids, allowdep, autoremove):
|
|
|
55e633 |
'''
|
|
|
55e633 |
Implement the remove functionality
|
|
|
55e633 |
diff --git a/lib/python/packagekit/backend.py b/lib/python/packagekit/backend.py
|
|
|
55e633 |
index 7df664e..4b9eedc 100644
|
|
|
55e633 |
--- a/lib/python/packagekit/backend.py
|
|
|
55e633 |
+++ b/lib/python/packagekit/backend.py
|
|
|
55e633 |
@@ -62,6 +62,7 @@ class PackageKitBaseBackend:
|
|
|
55e633 |
self._locked = False
|
|
|
55e633 |
self.lang = "C"
|
|
|
55e633 |
self.has_network = False
|
|
|
55e633 |
+ self.uid = 0
|
|
|
55e633 |
self.background = False
|
|
|
55e633 |
self.interactive = False
|
|
|
55e633 |
self.cache_age = 0
|
|
|
55e633 |
@@ -80,6 +81,12 @@ class PackageKitBaseBackend:
|
|
|
55e633 |
except KeyError as e:
|
|
|
55e633 |
print("Error: No NETWORK envp")
|
|
|
55e633 |
|
|
|
55e633 |
+ # try to get UID of running user
|
|
|
55e633 |
+ try:
|
|
|
55e633 |
+ self.uid = int(os.environ['UID'])
|
|
|
55e633 |
+ except KeyError as e:
|
|
|
55e633 |
+ print("Error: No UID envp")
|
|
|
55e633 |
+
|
|
|
55e633 |
# try to get BACKGROUND state
|
|
|
55e633 |
try:
|
|
|
55e633 |
if os.environ['BACKGROUND'] == 'TRUE':
|
|
|
55e633 |
diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
|
|
|
55e633 |
index 9d52957..3b1a571 100644
|
|
|
55e633 |
--- a/src/pk-backend-spawn.c
|
|
|
55e633 |
+++ b/src/pk-backend-spawn.c
|
|
|
55e633 |
@@ -782,6 +782,12 @@ pk_backend_spawn_get_envp (PkBackendSpawn *backend_spawn)
|
|
|
55e633 |
ret = pk_backend_job_get_interactive (priv->job);
|
|
|
55e633 |
g_hash_table_replace (env_table, g_strdup ("INTERACTIVE"), g_strdup (ret ? "TRUE" : "FALSE"));
|
|
|
55e633 |
|
|
|
55e633 |
+ /* UID */
|
|
|
55e633 |
+ ret = pk_backend_job_get_interactive (priv->job);
|
|
|
55e633 |
+ g_hash_table_replace (env_table,
|
|
|
55e633 |
+ g_strdup ("UID"),
|
|
|
55e633 |
+ g_strdup_printf ("%u", pk_backend_job_get_uid (priv->job)));
|
|
|
55e633 |
+
|
|
|
55e633 |
/* CACHE_AGE */
|
|
|
55e633 |
cache_age = pk_backend_job_get_cache_age (priv->job);
|
|
|
55e633 |
if (cache_age == G_MAXUINT) {
|
|
|
55e633 |
--
|
|
|
55e633 |
2.4.3
|
|
|
55e633 |
|
|
|
55e633 |
commit 3afec0a55d362ee692da0731d8205cd7372efe36
|
|
|
55e633 |
Author: Richard Hughes <richard@hughsie.com>
|
|
|
55e633 |
Date: Tue Jul 28 16:48:43 2015 +0100
|
|
|
55e633 |
|
|
|
55e633 |
hif: Record the UID of the session user in the yumdb
|
|
|
55e633 |
|
|
|
55e633 |
diff --git a/backends/hif/pk-backend-hif.c b/backends/hif/pk-backend-hif.c
|
|
|
55e633 |
index 7fcfdff..506f6b3 100644
|
|
|
55e633 |
--- a/backends/hif/pk-backend-hif.c
|
|
|
55e633 |
+++ b/backends/hif/pk-backend-hif.c
|
|
|
55e633 |
@@ -404,6 +404,8 @@ pk_backend_start_job (PkBackend *backend, PkBackendJob *job)
|
|
|
55e633 |
job_data->transaction = hif_transaction_new (priv->context);
|
|
|
55e633 |
hif_transaction_set_sources (job_data->transaction,
|
|
|
55e633 |
hif_context_get_sources (priv->context));
|
|
|
55e633 |
+ hif_transaction_set_uid (job_data->transaction,
|
|
|
55e633 |
+ pk_backend_job_get_uid (job));
|
|
|
55e633 |
|
|
|
55e633 |
#ifdef PK_BUILD_LOCAL
|
|
|
55e633 |
/* we don't want to enable this for normal runtime */
|
|
|
55e633 |
commit c5c0db1bb5577244a7644eb513751be333705996
|
|
|
55e633 |
Author: Richard Hughes <richard@hughsie.com>
|
|
|
55e633 |
Date: Tue Jul 28 15:00:31 2015 +0100
|
|
|
55e633 |
|
|
|
55e633 |
yum: Remove the obsolete service pack support
|
|
|
55e633 |
|
|
|
55e633 |
diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py
|
|
|
55e633 |
index 5e0c978..030f965 100755
|
|
|
55e633 |
--- a/backends/yum/yumBackend.py
|
|
|
55e633 |
+++ b/backends/yum/yumBackend.py
|
|
|
55e633 |
@@ -2008,80 +2008,14 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage):
|
|
|
55e633 |
|
|
|
55e633 |
# process these first
|
|
|
55e633 |
tempdir = tempfile.mkdtemp()
|
|
|
55e633 |
- inst_packs = []
|
|
|
55e633 |
|
|
|
55e633 |
for inst_file in inst_files:
|
|
|
55e633 |
if inst_file.endswith('.rpm'):
|
|
|
55e633 |
continue
|
|
|
55e633 |
- elif inst_file.endswith('.servicepack'):
|
|
|
55e633 |
- inst_packs.append(inst_file)
|
|
|
55e633 |
else:
|
|
|
55e633 |
self.error(ERROR_INVALID_PACKAGE_FILE, 'Only rpm files and packs are supported', exit=False)
|
|
|
55e633 |
return
|
|
|
55e633 |
|
|
|
55e633 |
- # decompress and add the contents of any .servicepack files
|
|
|
55e633 |
- for inst_pack in inst_packs:
|
|
|
55e633 |
- inst_files.remove(inst_pack)
|
|
|
55e633 |
- pack = tarfile.TarFile(name = inst_pack, mode = "r")
|
|
|
55e633 |
- members = pack.getnames()
|
|
|
55e633 |
- for mem in members:
|
|
|
55e633 |
- pack.extract(mem, path = tempdir)
|
|
|
55e633 |
- files = os.listdir(tempdir)
|
|
|
55e633 |
-
|
|
|
55e633 |
- # find the metadata file
|
|
|
55e633 |
- packtype = 'unknown'
|
|
|
55e633 |
- for fn in files:
|
|
|
55e633 |
- if fn == "metadata.conf":
|
|
|
55e633 |
- config = ConfigParser.ConfigParser()
|
|
|
55e633 |
- config.read(os.path.join(tempdir, fn))
|
|
|
55e633 |
- if config.has_option('PackageKit Service Pack', 'type'):
|
|
|
55e633 |
- packtype = config.get('PackageKit Service Pack', 'type')
|
|
|
55e633 |
- break
|
|
|
55e633 |
-
|
|
|
55e633 |
- # we only support update and install
|
|
|
55e633 |
- if packtype != 'install' and packtype != 'update':
|
|
|
55e633 |
- self.error(ERROR_INVALID_PACKAGE_FILE, 'no support for type %s' % packtype, exit=False)
|
|
|
55e633 |
- return
|
|
|
55e633 |
-
|
|
|
55e633 |
- # add the file if it's an install, or update if installed
|
|
|
55e633 |
- for fn in files:
|
|
|
55e633 |
- if fn.endswith('.rpm'):
|
|
|
55e633 |
- inst_file = os.path.join(tempdir, fn)
|
|
|
55e633 |
- try:
|
|
|
55e633 |
- # read the file
|
|
|
55e633 |
- pkg = YumLocalPackage(ts=self.yumbase.rpmdb.readOnlyTS(), filename=inst_file)
|
|
|
55e633 |
- pkgs_local = self.yumbase.rpmdb.searchNevra(name=pkg.name)
|
|
|
55e633 |
- except yum.Errors.MiscError:
|
|
|
55e633 |
- self.error(ERROR_INVALID_PACKAGE_FILE, "%s does not appear to be a valid package." % inst_file)
|
|
|
55e633 |
- except yum.Errors.YumBaseError, e:
|
|
|
55e633 |
- self.error(ERROR_INVALID_PACKAGE_FILE, 'Package could not be decompressed')
|
|
|
55e633 |
- except exceptions.IOError, e:
|
|
|
55e633 |
- self.error(ERROR_NO_SPACE_ON_DEVICE, "Disk error: %s" % _to_unicode(e))
|
|
|
55e633 |
- except:
|
|
|
55e633 |
- self.error(ERROR_UNKNOWN, "Failed to open local file -- please report")
|
|
|
55e633 |
- else:
|
|
|
55e633 |
- # trying to install package that already exists
|
|
|
55e633 |
- if len(pkgs_local) == 1 and pkgs_local[0].EVR == pkg.EVR:
|
|
|
55e633 |
- self.message('PACKAGE_ALREADY_INSTALLED', '%s is already installed and the latest version' % pkg.name)
|
|
|
55e633 |
-
|
|
|
55e633 |
- # trying to install package older than already exists
|
|
|
55e633 |
- elif len(pkgs_local) == 1 and pkgs_local[0].EVR > pkg.EVR:
|
|
|
55e633 |
- self.message('PACKAGE_ALREADY_INSTALLED', 'a newer version of %s is already installed' % pkg.name)
|
|
|
55e633 |
-
|
|
|
55e633 |
- # only update if installed
|
|
|
55e633 |
- elif packtype == 'update':
|
|
|
55e633 |
- if len(pkgs_local) > 0:
|
|
|
55e633 |
- inst_files.append(inst_file)
|
|
|
55e633 |
-
|
|
|
55e633 |
- # only install if we passed the checks above
|
|
|
55e633 |
- elif packtype == 'install':
|
|
|
55e633 |
- inst_files.append(inst_file)
|
|
|
55e633 |
-
|
|
|
55e633 |
- if len(inst_files) == 0:
|
|
|
55e633 |
- # More than one pkg to be installed, all of them already installed
|
|
|
55e633 |
- self.error(ERROR_ALL_PACKAGES_ALREADY_INSTALLED,
|
|
|
55e633 |
- 'All of the specified packages have already been installed')
|
|
|
55e633 |
-
|
|
|
55e633 |
self._set_only_trusted(TRANSACTION_FLAG_ONLY_TRUSTED in transaction_flags or TRANSACTION_FLAG_SIMULATE in transaction_flags)
|
|
|
55e633 |
|
|
|
55e633 |
# self.yumbase.installLocal fails for unsigned packages when self.yumbase.conf.gpgcheck = 1
|