diff options
author | Kalev Lember <klember@redhat.com> | 2018-11-24 15:54:53 +0100 |
---|---|---|
committer | Kalev Lember <klember@redhat.com> | 2018-11-25 13:59:33 +0100 |
commit | 08a1e481b2a550cc8245aa54e23f6803fbad6061 (patch) | |
tree | edf957cf07caa515efe9e29b40b6616973af8f95 /lib | |
parent | fc9e7daedf2503bb34d97782ebea6be8486f1968 (diff) |
common: Handle quoted strings in /etc/os-release
This should fix /var/cache/PackageKit/"8.0"/ on RHEL 8.0 to not have
quotes in it.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/packagekit-glib2/pk-common.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/packagekit-glib2/pk-common.c b/lib/packagekit-glib2/pk-common.c index 82e201fff..c0f56de77 100644 --- a/lib/packagekit-glib2/pk-common.c +++ b/lib/packagekit-glib2/pk-common.c @@ -265,17 +265,26 @@ pk_parse_os_release (gchar **id, gchar **name, gchar **version_id, GError **erro /* get keys */ if (id != NULL) { - *id = g_key_file_get_string (key_file, "os-release", "ID", error); + g_autofree gchar *tmp = g_key_file_get_string (key_file, "os-release", "ID", error); + if (tmp == NULL) + return FALSE; + *id = g_shell_unquote (tmp, error); if (*id == NULL) return FALSE; } if (name != NULL) { - *name = g_key_file_get_string (key_file, "os-release", "NAME", error); + g_autofree gchar *tmp = g_key_file_get_string (key_file, "os-release", "NAME", error); + if (tmp == NULL) + return FALSE; + *name = g_shell_unquote (tmp, error); if (*name == NULL) return FALSE; } if (version_id != NULL) { - *version_id = g_key_file_get_string (key_file, "os-release", "VERSION_ID", error); + g_autofree gchar *tmp = g_key_file_get_string (key_file, "os-release", "VERSION_ID", error); + if (tmp == NULL) + return FALSE; + *version_id = g_shell_unquote (tmp, error); if (*version_id == NULL) return FALSE; } |