Update libglnx, do some porting to new APIs
In particular I wanted to start using `GLNX_AUTO_PREFIX_ERROR`. Update submodule: libglnx Closes: #893 Approved by: jlebon
This commit is contained in:
parent
2082b3f8fb
commit
5763027b5f
2
libglnx
2
libglnx
@ -1 +1 @@
|
|||||||
Subproject commit 607f1775bb1c626cae1875a957a34802daebe81c
|
Subproject commit 7d6a31fb9316ec85d462c26b84fb8fe9ca04ef2b
|
@ -78,18 +78,13 @@ static gboolean
|
|||||||
start_daemon (GDBusConnection *connection,
|
start_daemon (GDBusConnection *connection,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
GLNX_AUTO_PREFIX_ERROR ("Couldn't start daemon", error);
|
||||||
rpm_ostree_daemon = g_initable_new (RPMOSTREED_TYPE_DAEMON,
|
rpm_ostree_daemon = g_initable_new (RPMOSTREED_TYPE_DAEMON,
|
||||||
NULL, error,
|
NULL, error,
|
||||||
"connection", connection,
|
"connection", connection,
|
||||||
"sysroot-path", opt_sysroot,
|
"sysroot-path", opt_sysroot,
|
||||||
NULL);
|
NULL);
|
||||||
if (!rpm_ostree_daemon)
|
return rpm_ostree_daemon != NULL;
|
||||||
{
|
|
||||||
g_prefix_error (error, "Couldn't start daemon: ");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -790,9 +790,9 @@ rpmostree_sort_pkgs_strv (const char *const* pkgs,
|
|||||||
g_ptr_array_add (repo_pkgs, g_strdup (*pkg));
|
g_ptr_array_add (repo_pkgs, g_strdup (*pkg));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glnx_fd_close int fd = open (*pkg, O_RDONLY | O_CLOEXEC);
|
glnx_fd_close int fd = -1;
|
||||||
if (fd < 0)
|
if (!glnx_openat_rdonly (AT_FDCWD, *pkg, TRUE, &fd, error))
|
||||||
return glnx_throw_errno_prefix (error, "can't open '%s'", *pkg);
|
return FALSE;
|
||||||
|
|
||||||
int idx = g_unix_fd_list_append (fd_list, fd, error);
|
int idx = g_unix_fd_list_append (fd_list, fd, error);
|
||||||
if (idx < 0)
|
if (idx < 0)
|
||||||
|
@ -326,19 +326,16 @@ rpmostree_bwrap_run (RpmOstreeBwrap *bwrap,
|
|||||||
/* Add the final NULL */
|
/* Add the final NULL */
|
||||||
g_ptr_array_add (bwrap->argv, NULL);
|
g_ptr_array_add (bwrap->argv, NULL);
|
||||||
|
|
||||||
|
const char *errmsg = glnx_strjoina ("Executing bwrap(", bwrap->child_argv0, ")");
|
||||||
|
GLNX_AUTO_PREFIX_ERROR (errmsg, error);
|
||||||
|
|
||||||
if (!g_spawn_sync (NULL, (char**)bwrap->argv->pdata, (char**) bwrap_env, G_SPAWN_SEARCH_PATH,
|
if (!g_spawn_sync (NULL, (char**)bwrap->argv->pdata, (char**) bwrap_env, G_SPAWN_SEARCH_PATH,
|
||||||
bwrap_child_setup, bwrap,
|
bwrap_child_setup, bwrap,
|
||||||
NULL, NULL, &estatus, error))
|
NULL, NULL, &estatus, error))
|
||||||
{
|
|
||||||
g_prefix_error (error, "Executing bwrap(%s): ", bwrap->child_argv0);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
if (!g_spawn_check_exit_status (estatus, error))
|
if (!g_spawn_check_exit_status (estatus, error))
|
||||||
{
|
|
||||||
g_prefix_error (error, "Executing bwrap(%s): ", bwrap->child_argv0);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1973,8 +1973,8 @@ break_single_hardlink_at (int dfd,
|
|||||||
{
|
{
|
||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
|
|
||||||
if (fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) != 0)
|
if (!glnx_fstatat (dfd, path, &stbuf, AT_SYMLINK_NOFOLLOW, error))
|
||||||
return glnx_throw_errno_prefix (error, "fstatat");
|
return FALSE;
|
||||||
|
|
||||||
if (!S_ISLNK (stbuf.st_mode) && !S_ISREG (stbuf.st_mode))
|
if (!S_ISLNK (stbuf.st_mode) && !S_ISREG (stbuf.st_mode))
|
||||||
return glnx_throw (error, "Unsupported type for entry '%s'", path);
|
return glnx_throw (error, "Unsupported type for entry '%s'", path);
|
||||||
@ -2011,8 +2011,8 @@ break_single_hardlink_at (int dfd,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (renameat (dfd, path_tmp, dfd, path) != 0)
|
if (!glnx_renameat (dfd, path_tmp, dfd, path, error))
|
||||||
return glnx_throw_errno_prefix (error, "rename(%s)", path);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -2394,8 +2394,8 @@ get_package_metainfo (RpmOstreeContext *self,
|
|||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
glnx_fd_close int metadata_fd = -1;
|
glnx_fd_close int metadata_fd = -1;
|
||||||
if ((metadata_fd = openat (self->tmpdir_fd, path, O_RDONLY | O_CLOEXEC)) < 0)
|
if (!glnx_openat_rdonly (self->tmpdir_fd, path, TRUE, &metadata_fd, error))
|
||||||
return glnx_throw_errno_prefix (error, "open(%s)", path);
|
return FALSE;
|
||||||
|
|
||||||
return rpmostree_unpacker_read_metainfo (metadata_fd, out_header, NULL,
|
return rpmostree_unpacker_read_metainfo (metadata_fd, out_header, NULL,
|
||||||
out_fi, error);
|
out_fi, error);
|
||||||
|
@ -1095,9 +1095,9 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
|
|||||||
const char *usrlibfiletmp = glnx_strjoina ("usr/lib/", file, ".tmp");
|
const char *usrlibfiletmp = glnx_strjoina ("usr/lib/", file, ".tmp");
|
||||||
|
|
||||||
/* Retain the current copies in /etc as backups */
|
/* Retain the current copies in /etc as backups */
|
||||||
if (renameat (rootfs_dfd, usretcfile, rootfs_dfd,
|
if (!glnx_renameat (rootfs_dfd, usretcfile, rootfs_dfd,
|
||||||
glnx_strjoina (usretcfile, ".rpmostreesave")) < 0)
|
glnx_strjoina (usretcfile, ".rpmostreesave"), error))
|
||||||
return glnx_throw_errno_prefix (error, "renameat");
|
return FALSE;
|
||||||
|
|
||||||
/* Copy /usr/lib/{passwd,group} -> /usr/etc (breaking hardlinks) */
|
/* Copy /usr/lib/{passwd,group} -> /usr/etc (breaking hardlinks) */
|
||||||
if (!glnx_file_copy_at (rootfs_dfd, usrlibfile, NULL,
|
if (!glnx_file_copy_at (rootfs_dfd, usrlibfile, NULL,
|
||||||
@ -1111,8 +1111,8 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
|
|||||||
GLNX_FILE_COPY_OVERWRITE, cancellable, error))
|
GLNX_FILE_COPY_OVERWRITE, cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (renameat (rootfs_dfd, usrlibfiletmp, rootfs_dfd, usrlibfile) < 0)
|
if (!glnx_renameat (rootfs_dfd, usrlibfiletmp, rootfs_dfd, usrlibfile, error))
|
||||||
return glnx_throw_errno_prefix (error, "renameat");
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* And break hardlinks for the shadow files, since we don't have
|
/* And break hardlinks for the shadow files, since we don't have
|
||||||
@ -1136,8 +1136,8 @@ rpmostree_passwd_prepare_rpm_layering (int rootfs_dfd,
|
|||||||
rootfs_dfd, tmp, GLNX_FILE_COPY_OVERWRITE,
|
rootfs_dfd, tmp, GLNX_FILE_COPY_OVERWRITE,
|
||||||
cancellable, error))
|
cancellable, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (renameat (rootfs_dfd, tmp, rootfs_dfd, src) < 0)
|
if (!glnx_renameat (rootfs_dfd, tmp, rootfs_dfd, src, error))
|
||||||
return glnx_throw_errno_prefix (error, "renameat");
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -681,11 +681,8 @@ hardlink_recurse (int src_dfd,
|
|||||||
if (!dent)
|
if (!dent)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW) < 0)
|
if (!glnx_fstatat (dfd_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, error))
|
||||||
{
|
|
||||||
glnx_set_error_from_errno (error);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
if (dent->d_type == DT_DIR)
|
if (dent->d_type == DT_DIR)
|
||||||
{
|
{
|
||||||
|
@ -336,9 +336,9 @@ rpmostree_unpacker_new_at (int dfd, const char *path,
|
|||||||
RpmOstreeUnpackerFlags flags,
|
RpmOstreeUnpackerFlags flags,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
glnx_fd_close int fd = openat (dfd, path, O_RDONLY | O_CLOEXEC | O_NOCTTY);
|
glnx_fd_close int fd = -1;
|
||||||
if (fd < 0)
|
if (!glnx_openat_rdonly (dfd, path, TRUE, &fd, error))
|
||||||
return glnx_null_throw_errno_prefix (error, "openat(%s)", path);
|
return FALSE;
|
||||||
|
|
||||||
RpmOstreeUnpacker *ret = rpmostree_unpacker_new_fd (fd, pkg, flags, error);
|
RpmOstreeUnpacker *ret = rpmostree_unpacker_new_fd (fd, pkg, flags, error);
|
||||||
if (ret == NULL)
|
if (ret == NULL)
|
||||||
|
@ -159,12 +159,8 @@ _rpmostree_util_update_checksum_from_file (GChecksum *checksum,
|
|||||||
glnx_fd_close int fd = -1;
|
glnx_fd_close int fd = -1;
|
||||||
g_autoptr(GMappedFile) mfile = NULL;
|
g_autoptr(GMappedFile) mfile = NULL;
|
||||||
|
|
||||||
fd = openat (dfd, path, O_RDONLY | O_CLOEXEC);
|
if (!glnx_openat_rdonly (dfd, path, TRUE, &fd, error))
|
||||||
if (fd < 0)
|
|
||||||
{
|
|
||||||
glnx_set_error_from_errno (error);
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
|
||||||
|
|
||||||
mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
|
mfile = g_mapped_file_new_from_fd (fd, FALSE, error);
|
||||||
if (!mfile)
|
if (!mfile)
|
||||||
|
Loading…
Reference in New Issue
Block a user