Commit Graph

11773 Commits

Author SHA1 Message Date
Richard W.M. Jones
f065a05f75 tests/nbd: Remove bogus sleep
This is no longer needed since qemu-nbd now supports pidfiles

Fixes: commit 1eb055bd46
(cherry picked from commit a84ff62478)
2023-01-11 10:05:14 +00:00
Richard W.M. Jones
9ad2c361bb tests/nbd: Unlink pidfile before running qemu-nbd
It might be left over from a previous failed run.  Best to unlink the
old file before starting qemu-nbd, so there's no possibility of
getting confused later when we wait for the file to appear.

(cherry picked from commit dc9bdda084)
2023-01-11 10:05:10 +00:00
Richard W.M. Jones
01cbb1ca05 tests/nbd: Move temporary files into tests/nbd/ subdirectory
This test fails for reasons I have not fully understood yet.  However
one thing I noticed is that the Unix domain socket and PID file used
the tests are placed in the tests/ directory, not the tests/nbd/
subdirectory, so let's fix that:

Starting qemu-nbd fedora-nbd.img -t --pid-file /home/rjones/d/libguestfs-rhel-9.2/tests/nbd.pid --format raw -p 63668 ...
Starting qemu-nbd fedora-nbd.img -t --pid-file /home/rjones/d/libguestfs-rhel-9.2/tests/nbd.pid --format raw -p 60684 ...
Starting qemu-nbd fedora-nbd.img -t --pid-file /home/rjones/d/libguestfs-rhel-9.2/tests/nbd.pid --format raw -k /home/rjones/d/libguestfs-rhel-9.2/tests/unix.sock ...

Fixes: commit 6d32773e81
(cherry picked from commit 98ab261a05)
2023-01-11 10:05:05 +00:00
Richard W.M. Jones
464da7d651 Version 1.48.6. v1.48.6 2022-11-28 11:46:17 +00:00
Richard W.M. Jones
99505eb7b6 python: Fix code style ("missing whitespace after keyword")
(cherry picked from commit fa305b709a)
2022-11-28 10:54:26 +00:00
Richard W.M. Jones
c9bd9d9cb1 file: Use -S option with -z
The file(1) manual suggests using -S (disable seccomp) with -z since
the set of system calls provided by the seccomp policy does not allow
the subprocess to run.  This is obvious when you use file -z on a
compressed file on a Linux distro that enables file's seccomp policy
(Arch does this, Fedora does not):

  $ file -zbsL lib-i586.so.zst
  Bad system call

I also fixed some incorrect text in the manual.

Thanks: Toolybird for pointing to this fix
Reported-by: David Runge
Fixes: https://github.com/libguestfs/libguestfs/issues/100
(cherry picked from commit 23986d3c4f)
2022-11-28 10:54:20 +00:00
Richard W.M. Jones
3a20ae00dc tests: Increase size of disk in xfs_growfs_0 test
I cannot reproduce the originally reported error:

libguestfs: error: mkfs: xfs: /dev/VG/LV: Filesystem must be larger than 300MB.

Thanks: David Runge
Related: https://github.com/libguestfs/libguestfs/issues/100
(cherry picked from commit e657e45b43)
2022-11-28 10:54:06 +00:00
Richard W.M. Jones
094338cb8e gnulib/lib/c-ctype.h: Remove executable bit
$ ls -l `find -name c-ctype.h`
-rwxr-xr-x. 1 rjones rjones 9647 Dec  3  2021 ./gnulib/lib/c-ctype.h
$ chmod -x `find -name c-ctype.h`
$ ls -l `find -name c-ctype.h`
-rw-r--r--. 1 rjones rjones 9647 Dec  3  2021 ./gnulib/lib/c-ctype.h

RPM builds actually gave a warning about this which is how I noticed
the problem:

*** WARNING: ./usr/src/debug/guestfs-tools-1.48.2-2.fc36.x86_64/gnulib/lib/c-ctype.h is executable but has no shebang, removing executable bit

(cherry picked from
guestfs-tools commit 566267a3d447eb97b4a0637adbe3e45c09ba090f)

(cherry picked from commit 6bfb73cdb0)
2022-11-28 10:54:01 +00:00
Richard W.M. Jones
fd6940218a Version 1.48.5. v1.48.5 2022-11-21 18:40:03 +00:00
Richard W.M. Jones
b22a98d6ec appliance: Add back libldm (ldmtool) and libxml2 to package list
Commit 133a491677 ("Use guestfsd binary to auto-generate library
dependencies for appliance", October 2020) removed explicit
dependencies for various system packages that the daemon links
directly to, ie. all of these libraries:

$ objdump -p daemon/guestfsd | grep NEEDED | sort
  NEEDED               libacl.so.1
  NEEDED               libaugeas.so.0
  NEEDED               libcap.so.2
  NEEDED               libc.so.6
  NEEDED               libgcc_s.so.1
  NEEDED               libhivex.so.0
  NEEDED               libjansson.so.4
  NEEDED               libm.so.6
  NEEDED               libpcre2-8.so.0
  NEEDED               librpm.so.9
  NEEDED               libselinux.so.1
  NEEDED               libsystemd.so.0
  NEEDED               libtirpc.so.3
(plus libyara which I don't have installed.)

This avoids having to update these dependencies if they change, eg.
when we switched from PCRE to PCRE2 we did not need to update this
file.

However the same commit also incorrectly removed two apparent library
packages (libldm, libxml2) which the daemon does not link to, but
which we'd like to pull in because of tools they provide, in
particular ldmtool.

Re-add those two explicit dependencies.

Fixes: commit 133a491677
(cherry picked from commit d5472a2219)
2022-11-21 18:20:19 +00:00
Richard W.M. Jones
16195a5a19 build: Replace Python distutils by sysconfig
This module has been deprecated in Python >= 3.10
(https://peps.python.org/pep-0632/).  Replace distutils.sysconfig with
sysconfig which is not quite a drop-in replacement.

This fix is incomplete as we still reference distutils in
python/setup.py.in.  However that is only used for PIP-style
distributions (make -C python sdist) which we don't really use or
recommend.

Thanks: Miro Hrončok
See-also: https://peps.python.org/pep-0632/
See-also: https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/N6ITYHLRWIDNYNXGPYG2ZHF3ZLQWZN7L/
(cherry picked from commit 26940f64a7)
2022-11-21 18:20:13 +00:00
Richard W.M. Jones
b4b00402bd gobject: Remove bogus NULL test for UUIDs
Many warnings such as:

src/session.c: In function 'guestfs_session_internal_test_rstruct':
src/session.c:14755:7: warning: the comparison will always evaluate as 'true' for the address of 'pv_uuid' will never be NULL [-Waddress]
14755 |   if (ret->pv_uuid) memcpy (s->pv_uuid, ret->pv_uuid, sizeof (s->pv_uuid));
      |       ^~~
In file included from src/session.c:40:
../include/guestfs.h:551:8: note: 'pv_uuid' declared here
  551 |   char pv_uuid[32]; /* this is NOT nul-terminated, be careful when printing */
      |        ^~~~~~~

(cherry picked from commit 5c63ec2a53)
2022-11-21 18:20:08 +00:00
Richard W.M. Jones
7b406c272d gobject: Use G_ADD_PRIVATE
Deprecation warnings include:

src/optargs-xfs_growfs.c: In function 'guestfs_xfs_growfs_init':
src/optargs-xfs_growfs.c:311:13: warning: Deprecated pre-processor symbol: replace with "G_ADD_PRIVATE"
  311 |   o->priv = GUESTFS_XFS_GROWFS_GET_PRIVATE (o);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is based on the same change made here:

https://github.com/nzjrs/osm-gps-map/pull/78/files
(cherry picked from commit 19c40e6717)
2022-11-21 18:20:03 +00:00
Richard W.M. Jones
e3f3aeae0b appliance: Remove LD_PRELOAD=libSegFault.so
This feature was removed in glibc 2.35:
https://savannah.gnu.org/forum/forum.php?forum_id=10111

(cherry picked from commit 001683e885)
2022-11-21 18:19:58 +00:00
Richard W.M. Jones
840c98cd24 Update common submodule
utils: Fix rogue include of nbdkit-plugin.h

(cherry picked from commit 3f5bdce111)
2022-11-21 18:19:54 +00:00
Richard W.M. Jones
d14acc97be lib: Avoid calling setenv between fork and exec
setenv can call malloc and is not safe to call here.  Glibc is usually
tolerant of this and we haven't had problems before, but if you use
GLIBC_TUNABLES glibc.malloc.check=1 (or any alternate malloc / libc
which serializes) then you would see hangs if starting multiple
libguestfs handles from different threads at the same time.

This commit also updates the common submodule to pick up:

  commit 3c64bcdeaf684f05f46f3928b55aadafdfe72720
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Fri Oct 14 11:07:21 2022 +0100

    utils: Add function for copying the environment and adding new entries

    libguestfs is currently calling setenv at an unsafe location between
    fork and exec.  To fix this we need a way to copy and modify the
    environment before fork and then we can pass the modified environ to
    execve-like functions.  nbdkit already does the same so use that code.

    This function is copied and adapted from here under a compatible license:
    https://gitlab.com/nbdkit/nbdkit/-/blob/master/common/utils/environ.c

Thanks: Siddhesh Poyarekar
(cherry picked from commit e1c9bbb3d1)
2022-11-21 18:19:27 +00:00
Richard W.M. Jones
0d47870a2b appliance: Create symlink /etc/crypto-policies/back-ends/opensslcnf.config
Downstream patched openssl in Fedora 37+ broke unless
/etc/crypto-policies/back-ends/opensslcnf.conf is present.  Files in
this directory are generated by %post rules that use scripting
languages so cannot easily be created by supermin.

Add a symlink to the DEFAULT policy file if the configuration file
doesn't exist.

A symptom of this problem is the error:

  Requested hash sha256 is not supported.
  Failed to set pbkdf parameters.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2133884
Updates: commit d6ba398825
(cherry picked from commit 4004e8eb36)
2022-11-21 18:18:10 +00:00
Richard W.M. Jones
35327035d8 daemon: Make vg_scan and lvm_scan no-ops if no LVM feature
If the LVM ("lvm2") feature is not available, these calls would fail.
Really they ought to be part of the "lvm2" optgroup which would cause
the generator to call reply_with_unavailable_feature and generate the
correct ENOTSUP error.  When vgscan was originally added in 2010 it
was not added to the optgroup, and when lvm_scan was later added in
2018 and deprecating vgscan, the same mistake was copied.

Before this commit they will try to run the lvm pvscan command which
will fail returning some other error (instead of ENOTSUP).

Fix this by turning the calls into no-ops if the LVM feature is not
available, since scanning for LVM objects when there is no LVM can be
safely turned into a no-op.

See also
https://listman.redhat.com/archives/libguestfs/2022-September/thread.html#29908

Also this updates the common module to pick up a related fix:

  commit 4b4a5b84647b1496d034bcdff910930ca5f5c486
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Fri Sep 23 15:18:43 2022 +0100

    options: Don't attempt to scan LVs if "lvm2" feature is not available

Reported-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Fixes: 55dfcb2211 ("New API: lvm_scan, deprecate vgscan")
Fixes: 9752039e52 ("New API: vgscan")
(cherry picked from commit c2dd84b263)
2022-11-21 18:17:47 +00:00
Richard W.M. Jones
b3e547b914 common: Update common submodule
commit 9d40590852e0755d4719adf97122758fa98e90f9
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 16:19:29 2022 +0100

    options/decrypt.c: Ignore #pragma GCC with clang

(cherry picked from commit e13a77e865)
2022-11-21 18:17:34 +00:00
Richard W.M. Jones
c3d91df504 common: Update common submodule
commit fd4062248271c1e026e3349fdcd4f9fc99e8f0c7
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 16:10:39 2022 +0100

    options/decrypt.c: Ignore probably bogus GCC -Werror=stringop-overflow

  commit 9d66f02807c7abdfbceba162a94c38cf474cf48b
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 15:56:46 2022 +0100

    windows/windows.c: Remove ignore -Wanalyzer-null-argument

  commit 0e4fdabcb6be5fc61dfc7b45cc5cb6db3d341494
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 15:46:22 2022 +0100

    mlpcre/pcre-c.c: Remove unused variable

(cherry picked from commit 03fadae09e)
2022-11-21 18:17:28 +00:00
Richard W.M. Jones
16eafe418d fish/tilde.c: Remove ignore -Wanalyzer-null-argument
Added in 2021 as a workaround for GCC 11 and since fixed upstream.

On macOS (clang):

tilde.c:43:32: error: unknown warning group '-Wanalyzer-null-argument', ignored [-Werror,-Wunknown-warning-option]
                               ^
tilde.c:86:32: error: unknown warning group '-Wanalyzer-null-argument', ignored [-Werror,-Wunknown-warning-option]
                               ^
2 errors generated.

(cherry picked from commit 39d66abc04)
2022-11-21 18:17:19 +00:00
Richard W.M. Jones
c0b866948b lib: Remove -Wanalyzer-file-leak ignores
These were added for GCC 11.  The problem has been fixed in GCC 12.
On macOS (clang) these produced errors like this:

tsk.c:75:32: error: unknown warning group '-Wanalyzer-file-leak', ignored [-Werror,-Wunknown-warning-option]
                               ^

(cherry picked from commit 347e875911)
2022-11-21 18:17:10 +00:00
Richard W.M. Jones
4c14f91cb3 lib/launch.c: Include <signal.h> for sigemptyset, etc
launch.c:191:3: error: implicit declaration of function 'sigemptyset' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sigemptyset (&sigset);
  ^
launch.c:192:3: error: implicit declaration of function 'sigaddset' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sigaddset (&sigset, SIGTERM);
  ^
launch.c:193:3: error: implicit declaration of function 'sigprocmask' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  sigprocmask (SIG_UNBLOCK, &sigset, NULL);
  ^
3 errors generated.

(cherry picked from commit e7f28159fb)
2022-11-21 18:16:43 +00:00
Richard W.M. Jones
e39b5a8845 common: Update common submodule
commit 1bf092f3c22e93c152de9dea3f5c13df23dc571c
  Author: Richard W.M. Jones <rjones@redhat.com>
  Date:   Tue Aug 16 15:08:40 2022 +0100

    utils: Include <stdio.h> for FILE*

(cherry picked from commit 6be5430314)
2022-11-21 18:15:53 +00:00
Richard W.M. Jones
5c622a72f5 configure: Use AC_FUNC_STRERROR_R
Update common submodule to include modified strerror_r replacement

(cherry picked from commit df5805df63)
2022-11-21 18:13:43 +00:00
Richard W.M. Jones
ab9ed404e0 m4: Check for GNU realpath program
It is a dependency of the ocaml-dep.sh script, required for all builds.

(cherry picked from commit c51d1cfe9a)
2022-11-21 18:11:07 +00:00
Richard W.M. Jones
d93175358a m4: Don't check for DISTRO with --disable-appliance
It is only used when building the appliance and for nothing else.

(cherry picked from commit be60075b16)
2022-11-21 18:11:02 +00:00
Richard W.M. Jones
8bf4455936 daemon: Remove remaining uses of custom printf %Q and %R
We have traditionally used custom printf formatters %Q and %R, where
%Q replaces the argument with a shell-quoted string, and %R replaces
the argument with a sysroot-prefixed shell-quoted string.  They are
actually pretty useful, but unfortunately only supported by glibc.

We only used them in about a dozen places in the daemon (much code
having been replaced by OCaml which does not need them).

In every remaining case we were constructing a command using code like
this:

  asprintf_nowarn (&cmd,
         "cd %Q && find -print0 | %s -0 -o -H %s --quiet", ...);

We can replace this with:

  char *cmd;
  size_t cmd_size;
  fp = open_memstream (&cmd, &cmd_size);
  fprintf (fp, "cd ");
  shell_quote (dir, fp);
  fprintf (fp, " && find -print0 | %s -0 -o -H %s --quiet", ...);
  fclose (fp);

(cherry picked from commit 0b3c6cc0c0)
2022-11-21 18:10:55 +00:00
Richard W.M. Jones
4b83ed8a2d daemon: grub: Remove incorrect use of printf specifier %R
This code is attempting to construct a grub-install command like:

  grub-install --root-directory=/sysroot/boot /dev/sda

In fact it was adding quoting to the --root-directory parameter where
it was not needed (because our "command" function uses exec).

Remove use of %R here (to avoid the extra quoting) and just use the
sysroot prefix directly.

(cherry picked from commit ad8b1b09ee)
2022-11-21 18:10:42 +00:00
Richard W.M. Jones
7716af56b9 daemon: Add zstd support to guestfs_file_architecture
This is required so we can determine the file architecture of
zstd-compressed Linux kernel modules as used by OpenSUSE and maybe
other distros in future.

Note that zstd becomes a required package, but it is widely available
in current Linux distros.

The package names come from https://pkgs.org/download/zstd and my own
research.

(cherry picked from commit 0e784824e8)
2022-11-21 18:10:32 +00:00
Richard W.M. Jones
55370c688c daemon: Parse /etc/hostname files containing comments
Thanks: Dawid Zamirski
Link: https://www.freedesktop.org/software/systemd/man/hostname.html
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 4a517601c7)
2022-11-21 18:10:19 +00:00
Richard W.M. Jones
f162e47ecf m4: Fix ./configure --disable-ocaml
OCaml is required to compile libguestfs, however we should still be
able to disable the OCaml bindings.  This didn't work because using
--disable-ocaml caused various configure tests to be skipped which are
required to compile the daemon.  In particular the check for
caml_alloc_initialized_string, resulting in this error:

pcre-c.c:47:1: error: static declaration of ‘caml_alloc_initialized_string’ follows non-static declaration
 caml_alloc_initialized_string (mlsize_t len, const char *p)
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also OCaml gettext is not required by libguestfs.  There are no *.ml
files used by libguestfs which require translation.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2108425
Fixes: https://bugs.gentoo.org/820053
Fixes: commit 733d2182b6
(cherry picked from commit adfaf25a12)
2022-07-20 10:53:08 +01:00
Richard W.M. Jones
9345eab656 Version 1.48.4. v1.48.4 2022-07-06 16:29:28 +01:00
Richard W.M. Jones
dbdd015699 valgrind: Add new suppressions for OCaml 4.14
(cherry picked from commit 1342626b33)
2022-07-06 13:32:48 +01:00
Richard W.M. Jones
5cc914bccc fuse/test-fuse.c: Partially disable test because of caching
Previously we noted in a comment that stat("hello.txt") is cached (and
not called again), so the test of the link count failed.  Something
has changed, possibly in the kernel, but it results in even more
aggressive caching so that an earlier, similar test also fails in the
same way.  I checked by enabling debugging that the stat call doesn't
result in guestfs_lstatns being called, and the old value for the
statbuf was being returned.

(cherry picked from commit f16fcdcfa2)
2022-07-06 13:32:44 +01:00
Laszlo Ersek
99c4157556 docs/guestfs-security: document CVE-2022-2211
Short log for the common submodule, commit range
f8de5508fe75..35467027f657:

Laszlo Ersek (2):
      mlcustomize: factor out pkg install/update/uninstall from guestfs-tools
      options: fix buffer overflow in get_keys() [CVE-2022-2211]

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100862
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220628115418.5376-2-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>

Cherry picked from commit 99844660b4.
RWMJ: For the cherry pick, I updated the common submodule to
the latest master commit (201632e4a7).
2022-07-06 13:31:46 +01:00
Richard W.M. Jones
b0b85b862a daemon: Remove workaround for -Wanalyzer-mismatching-deallocation
On older GCC:

debug.c:116:32: error: unknown option after ‘#pragma GCC diagnostic’ kind [-Werror=pragmas]
  116 | #pragma GCC diagnostic ignored "-Wanalyzer-mismatching-deallocation"
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[3]: *** [Makefile:2039: guestfsd-debug.o] Error 1

The upstream bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99193)
has now been fixed so the workaround is not necessary with the latest
GCC, so just delete the workaround.

(cherry picked from commit 1087d314cc)
2022-07-06 13:30:13 +01:00
Laszlo Ersek
2d52b4ad3b appliance, daemon: disable lvm2 devicesfile
In guestfs-tools commit 4fe8a03cd2d3 ('sysprep: remove lvm2's default
"system.devices" file', 2022-04-11), we disabled the use of LVM2's new
"devicesfile" feature, which could interfere with the cloning of virtual
machines.

We suspected in

  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c6

that the same lvm2 feature could affect the libguestfs appliance itself,
but decided in

  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c8
  https://bugzilla.redhat.com/show_bug.cgi?id=2072493#c10

that this would not be the case, because "appliance/init" already
constructed a pristine LVM_SYSTEM_DIR.

Unfortunately, that's not enough: due to the "use_devicesfile=1" default
(on RHEL9 anyway), some "lvm" invocation, possibly inside the
lvm-set-filter API, *creates* "$LVM_SYSTEM_DIR/devices/system.devices".
And then we get (minimally) warnings such as

> Please remove the lvm.conf global_filter, it is ignored with the devices
> file.
> Please remove the lvm.conf filter, it is ignored with the devices file.

when using the lvm-set-filter API.

Explicitly disable the "devices file" in "appliance/init", and also
whenever we rewrite "lvm.conf" -- that is, in set_filter()
[daemon/lvm-filter.c]. In the former, check for the feature by locating
the devicesfile-related utilities "lvmdevices" and "vgimportdevices". In
the C code, invoke the utilities with the "--help" option instead. (In
"appliance/init",  I thought it was best not to call any lvm2 utilities
even with "--help", with our lvm2.conf still under construction there.) If
either utility is available, set "use_devicesfile = 0".

Cc: David Teigland <teigland@redhat.com>
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1965941
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220530141027.16167-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
[lersek@redhat.com: style fix: break "devicesfile_feature" in the function
 definition to a new line]
(cherry picked from commit 8fc4d16715)
2022-07-06 13:30:02 +01:00
Richard W.M. Jones
9318f39bd7 build: Pick first field in ID_LIKE
CentOS Stream has:

ID_LIKE="rhel fedora"

which confused the existing script.  If there are multiple "likes"
arbitrarily pick the first one in the list.

Fixes: commit 63b722b6c0
(cherry picked from commit 7afbf5ee44)
2022-05-26 14:56:51 +01:00
Richard W.M. Jones
75720c2dbe Version 1.48.3. v1.48.3 2022-05-26 11:54:19 +01:00
Richard W.M. Jones
df61a359ff build: Add .gitpublish to EXTRA_DIST
Found by: make dist && make maintainer-check-extra-dist

Fixes: commit 8487e906d4
(cherry picked from commit a1b0c4162e)
2022-05-26 11:20:45 +01:00
Richard W.M. Jones
4f02eb61c9 daemon: rpm: Check return values from librpm calls
We previously didn't bother to check the return values from any librpm
calls.  In some cases where possibly the RPM database is faulty, this
caused us to return a zero-length list of installed applications (but
no error indication).

One way to reproduce this is given below.  Note this reproducer will
only work when run on a RHEL 8 host (or more specifically, with
rpm <= 4.16):

$ virt-builder fedora-28
$ guestfish -a fedora-28.img -i rm /var/lib/rpm/Packages
$ guestfish --ro -a fedora-28.img -i inspect-list-applications /dev/sda4 -vx
...
chroot: /sysroot: running 'librpm'
error: cannot open Packages index using db5 - Read-only file system (30)
error: cannot open Packages database in
error: cannot open Packages index using db5 - Read-only file system (30)
error: cannot open Packages database in
librpm returned 0 installed packages
...

With this commit we get an error instead:

...
chroot: /sysroot: running 'librpm'
error: cannot open Packages index using db5 - Read-only file system (30)
error: cannot open Packages database in
ocaml_exn: 'internal_list_rpm_applications' raised 'Failure' exception
guestfsd: error: rpmtsInitIterator
guestfsd: => internal_list_rpm_applications (0x1fe) took 0.01 secs
libguestfs: trace: internal_list_rpm_applications = NULL (error)
libguestfs: error: internal_list_rpm_applications: rpmtsInitIterator
libguestfs: trace: inspect_list_applications2 = NULL (error)
libguestfs: trace: inspect_list_applications = NULL (error)
...

Not in this case, but in some cases of corrupt RPM databases it is
possible to recover them by running "rpmdb --rebuilddb" as a guest
command (ie. with guestfs_sh).

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2089623#c12
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2089623
Fixes: commit c9ee831aff
Reported-by: Xiaodai Wang
Reported-by: Ming Xie
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 488245ed6c)
2022-05-26 11:20:42 +01:00
Richard W.M. Jones
86cbff0a4b build: When parsing distro from /etc/os-release, try $ID_LIKE first
The current code for working out the distro uses the ID entry from
/etc/os-release, and then we map those strings into a smaller set of
values (basically, what package manager to use).  However it was
suggested that we should try ID_LIKE first so that distros which act
like other distros would work.  On an Arch Linux 32 system:

ID=arch32
ID_LIKE=arch

See-also: https://github.com/libguestfs/libguestfs/issues/81
Thanks: S D Rausty
(cherry picked from commit 63b722b6c0)
2022-05-26 11:20:29 +01:00
Richard W.M. Jones
0135f33c27 appliance: Error out if QUERY_FILES_CMD cannot be set
Instead of continuing on regardless and failing with a weird error
later, error out early if we don't know about the distro and so cannot
set QUERY_FILES_CMD.  This avoids situations like
https://github.com/libguestfs/libguestfs/issues/81

(cherry picked from commit 4418e6345a)
2022-05-26 11:20:23 +01:00
Richard W.M. Jones
383298a8bf appliance: Print guestfsd.deps after generation
Sometimes generating this file fails.  To help with debugging these
situatons, print the guestfsd.deps file after it has been generated.

(cherry picked from commit bf5fcdbc9b)
2022-05-26 11:20:19 +01:00
Laszlo Ersek
fd64ddfee0 guestfs.pod: document encrypted RBD disk limitation
Under "REMOTE STORAGE", the "NETWORK BLOCK DEVICE" section already
documents some limitations. Turns out we need to describe a quirky
exception for accessing encrypted RBD disks, too.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2033247
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220518083014.9890-1-lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit 544bb0ff50)
2022-05-26 11:20:13 +01:00
Richard W.M. Jones
215157f42b website: Fix typo in previous commit
Fixes: commit 53d6c000b4
(cherry picked from commit feaec2497f)
2022-05-26 11:20:06 +01:00
Richard W.M. Jones
a8df4f159e website: List only the 1.48 stable branch on the website
(cherry picked from commit 53d6c000b4)
2022-05-26 11:20:03 +01:00
Kashyap Chamarthy
f604d43935 git: Add 'git-publish' config file
The `git-publish`[1] tool is a wrapper around `git-format-patch` and
`git-send-email`.  It's a handy tool that automates some of the tedious
aspects of manual patch submission:

  - Submitting a patch to the list (with a small config in place) is as
    simple as `git publish`

  - On next revisions, it automatically increments version numbers

  - It auto-copies the list of To: and Cc: from your previous iteration

  - It lets you preview/edit emails before submission

  - You can also use standard `git-format-patch` and `git-send-email`
    options with `git publish`

  - You can send pull requests with `git publish --pull-request`

  - It also provides custom hooks ... and more[2]

[1] https://github.com/stefanha/git-publish
[2] https://github.com/stefanha/git-publish/blob/master/git-publish.pod

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
(cherry picked from commit 8487e906d4)
2022-05-26 11:19:57 +01:00
Kashyap Chamarthy
b95c7f60c7 website: Update 'git clone' protocol
GitHub dropped[1] support for git: protocol, so cloing with "git://"
will fail.  Use "https://" instead.

[1] https://github.blog/2021-09-01-improving-git-protocol-security-github/

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
(cherry picked from commit 16cf069b61)
2022-05-26 11:19:52 +01:00