Commit Graph

11802 Commits

Author SHA1 Message Date
Richard W.M. Jones
d6ba398825 appliance: Copy in /etc/crypto-policies/back-ends/ files
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.

Force a copy of the host files into the appliance.  This is not ideal
and is hopefully a temporary fix until Fedora's openssl is fixed.

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
2022-10-11 21:59:49 +01:00
Richard W.M. Jones
cf89757883 Version 1.49.5. v1.49.5 2022-10-11 14:54:08 +01:00
Richard W.M. Jones
c2dd84b263 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")
2022-09-27 15:53:48 +01:00
rwmjones
57d1812091 Merge pull request #97 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-09-06 13:00:53 +01:00
Weblate
b18a71ef1b Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-09-06 11:19:52 +02:00
Temuri Doghonadze
6501d78bd4 Translated using Weblate (Georgian)
Currently translated at 0.9% (9 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2022-09-06 11:19:51 +02:00
Richard W.M. Jones
5e1f158c40 gnulib: Fix replacement functions for pipe2/accept4
gnulib itself has a replacement for <unistd.h> which redefines pipe2
as rpl_pipe2 (etc), which is why the apparently recursive call in the
implementation of pipe2 isn't actually recursive.  Since I didn't copy
that file, none of that worked and instead on platforms which have
pipe2 it recursed.

Reported-by: Laszlo Ersek
Fixes: commit 908e41e556
2022-08-17 14:58:52 +01:00
Richard W.M. Jones
e13a77e865 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
2022-08-16 16:31:34 +01:00
Richard W.M. Jones
03fadae09e 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
2022-08-16 16:12:06 +01:00
Richard W.M. Jones
39d66abc04 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.
2022-08-16 16:00:09 +01:00
Richard W.M. Jones
8d50637741 gnulib: Copy in error(3) replacement from gnulib
This is available under a compatible license (LGPLv2+).
2022-08-16 16:00:09 +01:00
Richard W.M. Jones
347e875911 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]
                               ^
2022-08-16 15:42:30 +01:00
Richard W.M. Jones
5fe33b685a lib/readdir.c: Include <rpc/types.h> before <rpc/xdr.h>
On macOS, several pages of errors like:

In file included from readdir.c:26:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/rpc/xdr.h:126:3: error: type name requires a specifier or qualifier
                bool_t  (*x_getlong)(struct __rpc_xdr *, int *);
                ^
2022-08-16 15:40:23 +01:00
Richard W.M. Jones
e7f28159fb 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.
2022-08-16 15:38:51 +01:00
Richard W.M. Jones
ef947a9d3b gnulib: Use system getprogname on macOS 2022-08-16 15:37:52 +01:00
Richard W.M. Jones
908e41e556 gnulib: Copy in pipe2 and accept4 replacements from gnulib
These are shipped under a compatible license (LGPLv2+ or LGPLv3+).
2022-08-16 15:37:52 +01:00
Richard W.M. Jones
6be5430314 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*
2022-08-16 15:37:52 +01:00
Richard W.M. Jones
b018b35bd4 lib: Remove dtrace/systemtap probes
These were added in libguestfs 1.14, but never really used.  Only a
handful of probes were available.  When I was benchmarking libguestfs
in 2016 I didn't even use these probes because better/simpler
techniques were available.
2022-08-16 15:35:17 +01:00
Richard W.M. Jones
df5805df63 configure: Use AC_FUNC_STRERROR_R
Update common submodule to include modified strerror_r replacement
2022-08-16 14:15:11 +01:00
Richard W.M. Jones
6c0e5d7f8f protocol: Replace missing xdr_uint64_t on macOS
The macOS rpcgen actually generates calls to xdr_uint64_t but doesn't
define them.  Despite this we can just use xdr_int64_t instead since
it's just byte swapping.
2022-08-16 14:03:59 +01:00
Richard W.M. Jones
c51d1cfe9a m4: Check for GNU realpath program
It is a dependency of the ocaml-dep.sh script, required for all builds.
2022-08-16 13:45:14 +01:00
Richard W.M. Jones
be60075b16 m4: Don't check for DISTRO with --disable-appliance
It is only used when building the appliance and for nothing else.
2022-08-16 13:40:15 +01:00
Richard W.M. Jones
0b3c6cc0c0 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);
2022-08-16 10:39:01 +01:00
Richard W.M. Jones
ad8b1b09ee 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.
2022-08-16 10:21:33 +01:00
Richard W.M. Jones
0e784824e8 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.
2022-08-09 19:04:41 +01:00
Richard W.M. Jones
d8fce89eca Version 1.49.4. v1.49.4 2022-08-01 15:15:55 +01:00
rwmjones
6f8e014958 Merge pull request #93 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-08-01 13:49:31 +01:00
Yuri Chornoivan
7dbd49d1aa Translated using Weblate (Ukrainian)
Currently translated at 100.0% (965 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/uk/
2022-08-01 14:19:07 +02:00
Piotr Drąg
1fbdc4386a Translated using Weblate (Polish)
Currently translated at 53.8% (520 of 965 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/pl/
2022-08-01 14:19:06 +02:00
Weblate
0d4b8de8b1 Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-08-01 14:19:06 +02:00
Temuri Doghonadze
f968e9b955 Translated using Weblate (Georgian)
Currently translated at 0.8% (8 of 956 strings)

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/ka/
2022-08-01 14:19:05 +02:00
Richard W.M. Jones
4a517601c7 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>
2022-07-20 13:22:39 +01:00
Richard W.M. Jones
adfaf25a12 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
2022-07-20 10:11:09 +01:00
Richard W.M. Jones
7149312632 lib: Don't use -cpu max on RISC-V
qemu (7.0) does not support -cpu max for TCG.

Note this change is necessary but not sufficient for getting
libguestfs to run on RISC-V, because there is also currently no
working path to make -kernel work.
2022-07-15 17:10:56 +01:00
Richard W.M. Jones
d68d1b2780 Version 1.49.3. v1.49.3 2022-07-01 15:27:25 +01:00
Richard W.M. Jones
1342626b33 valgrind: Add new suppressions for OCaml 4.14 2022-07-01 15:22:46 +01:00
Richard W.M. Jones
f16fcdcfa2 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.
2022-07-01 15:12:23 +01:00
Laszlo Ersek
6a5b44f538 guestfish, guestmount: enable networking for "--key ID:clevis"
Call the C-language helper key_store_requires_network() in guestfish and
guestmount.

(Short log for the "common" submodule, commit range
35467027f657..af6cb55bc58a:

Laszlo Ersek (12):
      options: fix UUID comparison logic bug in get_keys()
      mltools/tools_utils: remove unused function "key_store_to_cli"
      mltools/tools_utils: allow multiple "--key" options for OCaml tools too
      options: replace NULL-termination with number-of-elements in get_keys()
      options: wrap each passphrase from get_keys() into a struct
      options: add back-end for LUKS decryption with Clevis+Tang
      options: introduce selector type "key_clevis"
      options: generalize "--key" selector parsing for C-language utilities
      mltools/tools_utils-c: handle internal type error with abort()
      mltools/tools_utils: generalize "--key" selector parsing for OCaml utils
      options, mltools/tools_utils: parse "--key ID:clevis" options
      options, mltools/tools_utils: add helper for network dependency
).

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20220630122048.19335-4-lersek@redhat.com>
2022-07-01 15:11:06 +02:00
Laszlo Ersek
9a3e9a6c03 introduce the "clevis_luks_unlock" API
Introduce a new guestfs API called "clevis_luks_unlock". At the libguestfs
level, it is quite simple; it wraps the "clevis luks unlock" guest command
(implemented by the "clevis-luks-unlock" executable, which is in fact a
shell script).

The complexity is instead in the network-based disk encryption
(Clevis/Tang) scheme. Useful documentation:

- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html-single/security_hardening/index#configuring-automated-unlocking-of-encrypted-volumes-using-policy-based-decryption_security-hardening
- https://github.com/latchset/clevis#clevis
- https://github.com/latchset/tang#tang

The package providing "clevis-luks-unlock" is usually called
"clevis-luks", occasionally "clevis". Some distros don't package clevis at
all. Add the new API under a new option group (which may not be available)
called "clevisluks".

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1809453
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20220630122048.19335-3-lersek@redhat.com>
Reviewed-by: Richard W.M. Jones <rjones@redhat.com>
2022-07-01 15:07:26 +02:00
Laszlo Ersek
99844660b4 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>
2022-06-29 15:29:37 +02:00
rwmjones
4159f72bb7 Merge pull request #91 from weblate/weblate-libguestfs-libguestfs-master
Translations update from Fedora Weblate
2022-06-21 10:43:15 +01:00
Weblate
661c4f0bfb Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: libguestfs/libguestfs-master
Translate-URL: https://translate.fedoraproject.org/projects/libguestfs/libguestfs-master/
2022-06-18 19:45:25 +02:00
Temuri Doghonadze
2fdf19e49f Added translation using Weblate (Georgian) 2022-06-18 19:45:24 +02:00
Richard W.M. Jones
60e8ea0312 lib/readdir.c: Include unistd.h for unlink(2)
On riscv64:

readdir.c: In function ‘guestfs_impl_readdir’:
readdir.c:127:3: error: implicit declaration of function ‘unlink’ [-Werror=implicit-function-declaration]
  127 |   unlink (tmpfn);
      |   ^~~~~~

I also changed the #include lines to make them look a bit more
like use in other files.
2022-06-17 13:25:48 +01:00
Richard W.M. Jones
1087d314cc 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.
2022-06-17 13:24:19 +01:00
Geoff Amey
ec27979398 php: add arginfo to php bindings
Starting with PHP8, arginfo is mandatory for PHP extensions. This patch
updates the generator for the PHP bindings to generate the arginfo
structures, using the Zend API macros. Only basic arginfo is added,
without full documentation of argument and return types, in order to
ensure compatibility with as many versions of PHP as possible.
2022-06-15 22:29:28 +01:00
Laszlo Ersek
8fc4d16715 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]
2022-05-31 08:47:58 +02:00
Richard W.M. Jones
7afbf5ee44 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
2022-05-26 14:11:01 +01:00
Richard W.M. Jones
4b1fd3f154 Version 1.49.2. v1.49.2 2022-05-26 11:17:09 +01:00
Richard W.M. Jones
a1b0c4162e build: Add .gitpublish to EXTRA_DIST
Found by: make dist && make maintainer-check-extra-dist

Fixes: commit 8487e906d4
2022-05-26 10:48:32 +01:00