mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-09 07:59:19 +00:00
offline update: Use glib api for for reading symlinks
readlink() man page says that applications must not rely on it returning null-terminated links. This commit switches it to use g_file_read_link() instead that has much nicer API and shields us from readlink() oddities.
This commit is contained in:
parent
9d76a877db
commit
1f819d7adc
@ -686,22 +686,21 @@ fu_util_offline_update_reboot (void)
|
|||||||
static gboolean
|
static gboolean
|
||||||
fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
|
fu_util_install_prepared (FuUtilPrivate *priv, gchar **values, GError **error)
|
||||||
{
|
{
|
||||||
gchar buf[1024];
|
|
||||||
gint vercmp;
|
gint vercmp;
|
||||||
gssize len;
|
|
||||||
guint cnt = 0;
|
guint cnt = 0;
|
||||||
guint i;
|
guint i;
|
||||||
const gchar *tmp;
|
const gchar *tmp;
|
||||||
|
g_autofree gchar *link = NULL;
|
||||||
g_autoptr(GPtrArray) devices = NULL;
|
g_autoptr(GPtrArray) devices = NULL;
|
||||||
g_autoptr(FuPending) pending = NULL;
|
g_autoptr(FuPending) pending = NULL;
|
||||||
|
|
||||||
/* verify this is pointing to our cache */
|
/* verify this is pointing to our cache */
|
||||||
len = readlink (FU_OFFLINE_TRIGGER_FILENAME, buf, sizeof(buf) - 1);
|
link = g_file_read_link (FU_OFFLINE_TRIGGER_FILENAME, NULL);
|
||||||
if (len == -1) {
|
if (link == NULL) {
|
||||||
g_debug ("No %s, exiting", FU_OFFLINE_TRIGGER_FILENAME);
|
g_debug ("No %s, exiting", FU_OFFLINE_TRIGGER_FILENAME);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
if (g_strcmp0 (buf, "/var/lib/fwupd") != 0) {
|
if (g_strcmp0 (link, "/var/lib/fwupd") != 0) {
|
||||||
g_debug ("Another framework set up the trigger, exiting");
|
g_debug ("Another framework set up the trigger, exiting");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user