Commit Graph

6263 Commits

Author SHA1 Message Date
Richard W.M. Jones
73cf29101f Update generated files. 2014-03-08 17:56:43 +00:00
Pino Toscano
1b5d4fb334 builder: install a $sysconfdir/virt-builder -> xdg-virt-builder symlink
This way "virt-builder" appears directly in the sysconfdir.

(cherry picked from commit 631c7d9241)
2014-03-08 17:34:10 +00:00
Pino Toscano
d4ddc6b9d5 builder: add libguestfs.gpg to EXTRA_DIST
It needs to be in EXTRA_DIST, otherwise it is not put in the dist.

(cherry picked from commit 962837650c)
2014-03-08 17:34:10 +00:00
Pino Toscano
eaba93cf38 builder: update documentation
Update the documentation according to the new .conf files structure, the
drop of VIRT_BUILDER_SOURCE and VIRT_BUILDER_FINGERPRINT, the drop of
hardcoded source and its key, etc.

(cherry picked from commit 963b0341e2)
2014-03-08 17:34:10 +00:00
Pino Toscano
28a9ed1d1f builder: remove the default fingerprint/pubkey
Sigchecker can still import keys from the user's keyring, so there is no
need to hardcode fingerprint and key of the index hosted on
libguestfs.org (which is now pointed to using a .conf file).

(cherry picked from commit 47538865f2)
2014-03-08 17:34:10 +00:00
Pino Toscano
2c5349eff4 builder: remove VIRT_BUILDER_SOURCE and VIRT_BUILDER_FINGERPRINT
Drop these two environment variables, and the implicit hardcoded source
hosted at libguestfs.org.
This means all the sources must be provided as .conf files, or at each
invocation with --source.

(cherry picked from commit 573cae45c3)
2014-03-08 17:34:10 +00:00
Pino Toscano
53596d0926 builder: switch sources to .conf files
Introduce and use simple .conf files to configure the sources of indexes
for virt-builder. The location of these files is in XDG_CONFIG_DIRS /
XDG_CONFIG_HOME, so it can be easily overridden.

There are three .conf(.in) files shipped with this commit:
- "test-index.conf.in" (in "test-config"), which points to the
  "test-index" index (used in tests only); the tests are adapted to
  point to the hierarchy containing this .conf
- "libguestfs.conf.in" (in "test-website"), which points to the local
  "index.asc" (i.e. the offline copy of the libguestfs.org index);
  run(.in) will point to the hierarchy providing this .conf
- "libguestfs.conf.in" (directly among the other sources), which points
  to the online "index.asc" and it is installed in sysconfdir, along
  with the key of this repository

The tests are adapted, other than to the different way to pick sources,
to the different output of --list, as "test-index" is not signed.

(cherry picked from commit f4990bef1c)
2014-03-08 17:34:10 +00:00
Pino Toscano
f1d2b2b600 builder: extract the default key to file
This is basically default_pubkey from sigchecker.ml, just extracted as
file. Not used right now, but will be in the future.

(cherry picked from commit a3f1ac9a2d)
2014-03-08 17:34:10 +00:00
Pino Toscano
145a3367cb builder: add functions to read XDG_CONFIG_DIRS and XDG_CONFIG_PATH
(cherry picked from commit a21da3c801)
2014-03-08 17:34:10 +00:00
Pino Toscano
32e1da26d4 builder: use Sigchecker.gpgkey_type for the fingerprint
Use Sigchecker.gpgkey_type instead of just string as type in the
sources list; adapt the listing code (and its expected output) to that.

No behaviour change which eases a bit the addition of new sources with
other key types.

(cherry picked from commit ad38e68c34)
2014-03-08 17:34:10 +00:00
Pino Toscano
07ee461bda builder: allow "no key" as key in Sigchecker
Additional way to distinguish no actual key available for signature
checking; make sure to not allow signing in such situation.

(cherry picked from commit c09f5bbc70)
2014-03-08 17:34:10 +00:00
Pino Toscano
623c362629 builder: split INI C <-> OCaml glue code in own module
Move in an own module the code which calls the C
virt_builder_parse_index and does the array -> list conversion of the
result. This way this code can be easily called also in places different
than Index_parser without the need to copy the types mapping, etc.

Just code motion, no actual behaviour changes.

(cherry picked from commit 8ed905c7e6)
2014-03-08 17:34:10 +00:00
Pino Toscano
05a998cb54 builder: add a mandatory 'arch' key in index files
Introduce a mandatory arch= key in all the entries of index files, to
identify which architecture is each. Adapt the long and JSON list
outputs to print also this new field.

This introduces an incompatibility with index files created with
virt-builder < 1.26, as they will be rejected until entries will have
the arch= key added (which is ignored by older virt-builder, so adding
it will not create backward-compatibility issues).

(cherry picked from commit 61323fabaf)
2014-03-08 17:34:10 +00:00
Pino Toscano
5ef5783517 builder: allow Sigchecker to import keys from file
Extend Sigchecker so it allows both fingerprints (to be imported from
user's keyring, as before) and keys stored in files. To simplify this
process (and have the fingerprint always around), the key is imported
on Sigchecker.create time, instead of lazily at the first verification.

(cherry picked from commit 35e53c0381)
2014-03-08 17:34:10 +00:00
Pino Toscano
fa17328234 builder: use a disposable GPG keyring for every Sigchecker
Create a temporary directory and tell gpg to use it as homedir, so
imported keys do not get into the user's keyring. This also avoid
importing the default key  when a different one is needed to check the
signature.

The only exception is when a non-default fingerprint is used: in this
case, that key is read from the user's keyring, since it is where it is.

(cherry picked from commit dd03d38be3)
2014-03-08 17:34:10 +00:00
Pino Toscano
da72572e99 mllib: add an hook to cleanup directories on exit
Much similar to unlink_on_exit, but recursively cleaning directories.

(cherry picked from commit 7f77f4fb28)
2014-03-08 17:34:10 +00:00
Pino Toscano
87dcb7e7d4 builder: accept also '_' in group names
(cherry picked from commit 4c5a6afc84)
2014-03-08 17:34:10 +00:00
Pino Toscano
b3190becb6 builder: move the XDG path handling in an own file
Just code motion and renaming, no actual behaviour changes.

(cherry picked from commit bb35e72503)
2014-03-08 17:34:10 +00:00
Pino Toscano
b18d073221 fish: use XDG paths for the config file
Read the configuration file from XDG paths for both global and
user-local locations, keeping the old paths as fallback.

(cherry picked from commit 8b1f1c15f5)
2014-03-08 17:34:10 +00:00
Richard W.M. Jones
1b1430bcb7 builder: Fix dependencies which are not generated correctly by automake.
See the error messages here:
https://www.redhat.com/archives/libguestfs/2014-February/msg00148.html

This fixes commit e2cc8b6465.

(cherry picked from commit 360abeebda)
2014-03-08 17:34:10 +00:00
Richard W.M. Jones
e48c2b8f3f Use bindtextdomain in some programs where it was missing.
Found by make syntax-check.

(cherry picked from commit 9018356a67)
2014-03-08 17:34:10 +00:00
Richard W.M. Jones
6592e59f30 builder: Suppress warning about unused yyunput.
CC       virt_index_validate-index-validate.o
index-scan.c:1270:17: warning: 'yyunput' defined but not used [-Wunused-function]
     static void yyunput (int c, register char * yy_bp )
                 ^
  CCLD     virt-index-validate

By using %option nounput we can prevent this from being generated in
the first place.

(cherry picked from commit e3d23cccf4)
2014-03-08 17:34:10 +00:00
Richard W.M. Jones
d1f9407a92 builder: pxzcat: Fix char * signedness warning.
(cherry picked from commit e4fe09c5ae)
2014-03-08 17:34:10 +00:00
Pino Toscano
a38e43d316 mllib: hostname: on Debian replace it also in /etc/hosts (RHBZ#953907).
In Debian/Ubuntu systems, read the previous hostname from /etc/hostname
before replacing it, and replace it in /etc/hosts with the new hostname.

(cherry picked from commit ab2df2e659)
2014-03-08 17:34:10 +00:00
Pino Toscano
b9f40ee0a0 builder: do a copy when downloading local files
Instead of spawning curl even to "download" file:// URIs, just copy
them.

(cherry picked from commit 76e3e15d03)
2014-03-08 17:34:10 +00:00
Pino Toscano
bdf45e434f builder: prepare for different per-protocol download actions
Small refactor of Downloader.download_to to allow different download
actions depending on the protocol of the URI (which is now parsed).

No actual behaviour changes, just mostly code motion.

(cherry picked from commit ba3569704c)
2014-03-08 17:34:10 +00:00
Pino Toscano
e8cddd39da builder: isolate C libraries in an own OCAMLCLIBS
Just moving stuff within Makefile.am, no functional changes.

(cherry picked from commit c66cec6ffa)
2014-03-08 17:34:10 +00:00
Pino Toscano
31bfed9c75 builder: remove unused variables
Leftovers of the list_entries_short+list_entries_long split done in
commit 91aae893c7.

(cherry picked from commit bed8a168c0)
2014-03-08 17:34:09 +00:00
Pino Toscano
16e4cb121e builder: output translated notes
Output all the translations available for the notes in the "verbose"
output and the JSON output, while trying to match the system langauge in
the "show notes" output.

The JSON output is slightly changed to handle translations, with the
"untranslated" notes being matched as "C". The version is not bumped
though, since there have been no stable releases with the former output
yet.

(cherry picked from commit 07ef60c63f)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
e0d039574b daemon: Add a note about how 'mount --rbind' doesn't work.
(cherry picked from commit d9cd2dc9b0)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
cc3baf20c7 daemon: If /selinux exists in the guest, bind-mount /sys/fs/selinux to there.
Commit 72afcf450a was partially
incorrect.  If the guest userspace is expecting /selinux to exist,
then we should bind-mount /sys/fs/selinux from the appliance kernel
there.

(cherry picked from commit 9df50877f8)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
215bb1426c daemon: Bind-mount /sys/fs/selinux into sysroot when running commands.
Even though we are already bind-mounting /sys, it is necessary to also
bind-mount /sys/fs/selinux in order for SELinux commands (in
particular, 'load_policy') to work.

This fixes/reverts commit 7367729ec7.

(cherry picked from commit ab33653ef3)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
942656546c builder: Add documentation for enabling Puppet (agent) in a guest.
(cherry picked from commit 080300dfec)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
48f09e1bbd builder: Add --selinux-relabel option to perform SELinux relabelling.
This adds the --selinux-relabel option which enables selinux in the
appliance and runs:

  if load_policy && fixfiles restore; then
    rm -f /.autorelabel
  else
    touch /.autorelabel
  fi

at the end of installation.

When possible this fixes SELinux labels in the guest and makes the
autorelabel step unnecessary.

Notes:

 - The previous commit is required so that load_policy works.

 - During the build, SELinux is enabled but no policy is loaded.  This
   works because SELinux is in permissive mode.

 - This flag does not work if the appliance kernel and the guest have
   greatly differing versions, eg. a RHEL 6 guest with a Fedora 20
   appliance.  This is because SELinux changes the policy format and
   breaks backwards compatibility.  You would see errors like this:

   libsepol.policydb_write: policy version 15 cannot support MLS
   libsepol.policydb_to_image: could not compute policy length
   libsepol.policydb_to_image: could not create policy image
   SELinux:  Could not downgrade policy file /etc/selinux/targeted/policy/policy.24, searching for an older version.
   SELinux:  Could not open policy file <= /etc/selinux/targeted/policy/policy.24:  No such file or directory

   These errors are ignored (they go to the log file) and relabelling
   is done at boot instead.

 - It's not clear if loading guest policy is safe.  You should trust
   the virt-builder templates and to use libguestfs confinement for
   additional protection.

(cherry picked from commit 90e23b4e56)
2014-03-08 17:34:09 +00:00
Pino Toscano
0766c47cfd builder: read all the available notes from the index
Switch the internal storage for the notes of each entry to a sorted list
with all the subkeys available (which should represent the translations
to various languages).
The current outputs are the same (i.e. still the untranslated notes), so
this is just internal refactoring/preparation.

(cherry picked from commit b7cd63fc1d)
2014-03-08 17:34:09 +00:00
Pino Toscano
30e387cfed builder: small code simplification
No actual behaviour changes, just remove extra match statements.

(cherry picked from commit 958e84d699)
2014-03-08 17:34:09 +00:00
Pino Toscano
a299cf6d21 builder: fix small regression in subkey parsing
Introduced in 5cbdf35d65, it caused the
first character of the value to be skipped if the key has a subkey.

(cherry picked from commit 9e4357ca54)
2014-03-08 17:34:09 +00:00
Pino Toscano
765382e254 builder: proper consider subkeys in index files
The index files already allowed the 'key[subkey]=...' syntax for keys,
but considering such string as whole key. Proper split the parsing and
the handling of the subkeys, so they can be searched a bit easier.

This causes no actual behaviour changes, it is just internal
micro-refactoring. (Thanks Rich for the hints, too.)

(cherry picked from commit 5cbdf35d65)
2014-03-08 17:34:09 +00:00
Pino Toscano
5327e6988d builder: allow more empty lines in index files
Improve the index grammar to allow more than one empty line between
sections, and to allow any number of empty lines at the end of the file
(after the last section).

(cherry picked from commit 4505f61979)
2014-03-08 17:34:09 +00:00
Pino Toscano
ee214e1f75 builder: add index-struct.h as dependency for index-parser-c.c
Just like with index-parse.h, also index-struct.h is a dependency of
index-parser-c.c which automake cannot generate correctly.
Thus, add it manually.

(cherry picked from commit e2cc8b6465)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
6b6ce89d05 builder: Fix unterminated I<...> in man page.
Thanks: Lukas Zapletal.
(cherry picked from commit b3cf877e58)
2014-03-08 17:34:09 +00:00
Pino Toscano
1d0c6895d9 builder: add a JSON output for --list
Simple JSON output for sources and templates, to be able to query them
with no need to parse unstructured outputs like the "--list-format long"
one.

(cherry picked from commit 5b42351294)
2014-03-08 17:34:09 +00:00
Pino Toscano
9a636393a6 builder: add --list-format
Add a --list-format which allows to choose which in format should be the
output of --list.

(cherry picked from commit e45bfe0d36)
2014-03-08 17:34:09 +00:00
Pino Toscano
f92e6e3087 builder: small refactor of the list output
Switch from a boolean for the short/long list output to labels for the
actual format. Also, split the output of each list format to an own
function for easier maintaineance.

(cherry picked from commit 91aae893c7)
2014-03-08 17:34:09 +00:00
Pino Toscano
a859445b88 builder: test-virt-builder: check some results
Check at least some basic modifications in the image created with
virt-builder.

(cherry picked from commit 775c6daf22)
2014-03-08 17:34:09 +00:00
Pino Toscano
a8dc88c71d builder, edit, fish: use copy-attributes
Make use of the new copy-attributes command to properly copy all file
attributes from a file to the new version of it.

(cherry picked from commit b7bb1f6cee)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
ea14ff02b0 fish: Add test-file-attrs.sh to EXTRA_DIST.
This fixes commit efb5f18415.

(cherry picked from commit aba64a0327)
2014-03-08 17:34:09 +00:00
Pino Toscano
018ddf7206 New API: copy-attributes.
This allows one to copy attributes (like permissions, xattrs,
ownership) from a file to another.

(cherry picked from commit efb5f18415)
2014-03-08 17:34:09 +00:00
Richard W.M. Jones
0cd83538f5 daemon: xattr: Remove unused variable.
Revealed by using ./configure --enable-gcc-warnings.

(cherry picked from commit cea270de3b)
2014-03-08 17:34:09 +00:00
Pino Toscano
44cd429c03 daemon: xattr: move the listxattrs code in an own function
Move in an own function the code that does the (l)listxattrs allocating
the buffer of the right legth, as it will be useful later.

No functional changes, just code motion.

(cherry picked from commit 59d8cf62cb)
2014-03-08 17:34:09 +00:00