Commit Graph

229 Commits

Author SHA1 Message Date
Margaret Lewicka
b969be72cd lib: Check if crypt() comes from a separate library
Mac OS X includes crypt() in libc.
2015-02-13 08:55:44 +00:00
Richard W.M. Jones
ab950f8290 mllib: Add a better List.assoc function.
You can specify what comparison function is used; and instead of
having it raise 'Not_found', it returns a ~default value.
2015-02-02 13:32:24 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
d3e93e1011 inspection: Recognise 'dnf' as the package manager in Fedora 22.
Also fix virt-sysprep and virt-customize so they can work with dnf.

I also sorted some of the lists alphabetically.
2014-12-15 14:41:29 +00:00
Richard W.M. Jones
f9e0aee149 sysprep: Use automake to build the library.
Normally this requires the program to have at least one C source file.
virt-sysprep doesn't have this, but it uses C sources from other
directories, and therefore we can make it work.
2014-12-13 18:10:58 +00:00
Pino Toscano
d4ffaad983 sysprep: user-account: mark "changed file" if users were removed
Removing an user causes /etc/passwd, /etc/shadow, and /etc/group to
change, so mark the side effects as such if any user has been removed.
2014-12-05 16:10:56 +01:00
Pino Toscano
acb6e8f344 sysprep: add a "changed file" side effect 2014-12-05 16:10:56 +01:00
Pino Toscano
1ea9b684b2 customize, sysprep: add a short SELinux note
Add a short paragraph about SELinux, mostly to point to the
documentation about it provided in the documentation of virt-builder.
2014-12-05 16:10:56 +01:00
Hu Tao
95644f33cd uuid: add support to change uuid of swap partition
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-11-28 14:19:27 +00:00
Pino Toscano
b00adf3b78 tools: implement --short-options
Just like --long-options, it makes it possible to know which short
options are supported by each tool; this can help improving the bash
completion, for example.
2014-11-27 16:26:13 +01:00
Pino Toscano
b2b65bcefb mllib: remove the TTY module
The only function provided is isatty_stdout, which is no more used now
in favour of Unix.isatty.
2014-11-25 15:40:49 +01:00
Richard W.M. Jones
f421c7cae8 ocaml: Remove *.annot files when doing 'make clean'.
Commit fd70cdc3c5 passes the -annot flag
to the compiler, generating *.annot files (containing type information
used by emacs and IDEs).  Remove these files when doing 'make clean'.
2014-11-15 17:39:01 +00:00
Richard W.M. Jones
34d6851574 Rename LIBNCURSES* to LIBTINFO*.
We actually depend on libtinfo or libtermcap, not curses, so
rename the variable.

This updates commit 96add4d5b3.
2014-11-13 13:22:21 +00:00
Mike Frysinger
96add4d5b3 use pkg-config to look up ncurses
Hardcoding -ltinfo breaks on distros that do not build the sep library
(which is the default ncurses behavior).  Use pkg-config to look up the
right libraries regardless of how the distro built things.
2014-11-13 13:19:55 +00:00
Richard W.M. Jones
ea04bcbc84 Use -ltinfo instead of -lncurses.
In tools except guestfish, we don't use ncurses, or even curses, just
2 termcap functions and a global variable.  These are provided by
libtinfo, so just link to that.

In guestfish we use readline which needs ncurses.  Leave that alone.
2014-11-05 21:34:58 +00:00
Pino Toscano
a5426cce5f build: check for libintl, and use it
Look for libint/gettext and link to it; this properly detects whether
libint is part of libc.
2014-11-05 13:45:17 +01:00
Pino Toscano
3d6c2af450 customize: Add --ssh-inject option for injecting SSH keys.
This adds a customize option:

  virt-customize --ssh-inject USER
  virt-customize --ssh-inject USER:string:KEY_STRING
  virt-customize --ssh-inject USER:file:FILENAME

(ditto for virt-builder and virt-sysprep)

In each case this injects into the guest user USER
a) the current (host) user's ssh pubkey
b) the key specified as KEY_STRING
c) the key in FILENAME
adding it to ~USER/.ssh/authorized_keys in the guest.

For example:

  virt-builder fedora-20 --ssh-inject root

will add the local user's ssh pubkey into the root account of the
newly created guest.  Or:

  virt-customize -a disk.img \
     --ssh-inject 'mary:string:ssh-rsa AAAA.... mary@localhost'

adds the given ssh pubkey to mary's account in the guest.

This doesn't set the SELinux labels correctly on newly created files
and directories, so you have to use --selinux-relabel (probably we
should fix this as part of the general effort to fix SELinux
relabelling).  However it should preserve the labels if the
~/.ssh/authorized_keys file already exists.

Most of this work is based on a patch sent to the mailing list by
Richard W.M. Jones <rjones@redhat.com>:
https://www.redhat.com/archives/libguestfs/2014-November/msg00000.html
2014-11-03 20:47:38 +01:00
Hu Tao
d0eba7f260 sysprep: remove /var/spool/mail/username
remove /var/spool/mail/username if --enable user-account.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
2014-10-28 11:21:33 +00:00
Richard W.M. Jones
6049fbdddb sysprep: Use common error/warning/info functions. 2014-10-25 15:13:27 +01:00
Richard W.M. Jones
f7664b7f76 customize: Add Customize_utils module and use common error/warning/info functions.
Add a Customize_utils module.  This contains common error/warning/info
functions, and also quote = Filename.quote.

Examine every existing call to printf/eprintf and change where
necessary so that:

 - error is used instead of eprintf + exit 1

 - warning no longer needs ~prog argument (it is added by Utils module)

 - any verbose output should go to stdout, not stderr

 - info is used to print general informational messages

Also, don't pass ~prog parameter around.  Instead we just get it from
the executable name.
2014-10-25 15:00:21 +01:00
Richard W.M. Jones
90dc8942bf ocaml: Factor out flags into configure script.
No change, just refactoring.
2014-10-23 15:41:49 +01:00
Pino Toscano
56cfb8a926 sysprep: remove more logs
- remove firewalld, grubby, and proftpd logs
- extend the cups log removal also to its timestamped rotated logs
- remove also the libvirt/libxl logs
2014-10-03 14:24:48 +02:00
Richard W.M. Jones
9018a23828 mllib: Coloured messages, errors, warnings.
Uses ANSI terminal codes to colour the output.
2014-10-02 15:31:49 +01:00
Pino Toscano
d39744a030 sysprep: add no-op --no-selinux-relabel (RHBZ#1148072)
Add a no-op --no-selinux-relabel option, to be compatible with
virt-sysprep < 1.26.
2014-10-01 10:12:38 +02:00
Richard W.M. Jones
e85a976c5a tests: Don't use relative paths to binaries in tests.
All tests run under the ./run binary.  For a long time the ./run
binary has set the $PATH environment variable to contain all of the
directories with binaries in them.

Therefore there is no reason to use ../fish/guestfish instead of just
plain guestfish (and the same applies to other built binaries).
2014-09-17 17:31:50 +01:00
Richard W.M. Jones
4178bdc9b4 sysprep: Clarify the documentation for 'flag-reconfiguration'.
It was quite obscure what this actually did.  Make it clear
in the documentation.
2014-09-17 11:52:34 +01:00
Richard W.M. Jones
f722571c73 sysprep: Clarify when --mount-options is used and what it does (RHBZ#1142186). 2014-09-16 16:46:34 +01:00
Hilko Bengen
7039d0e7f6 Generate *.cmx targets only if a native OCaml compiler exists 2014-09-14 21:21:25 +02:00
Richard W.M. Jones
a18c2aca14 Revert "Use ocamldep -all option."
This reverts commit a3881445ef.

See discussion on the mailing list:

https://www.redhat.com/archives/libguestfs/2014-September/msg00069.html
2014-09-14 18:46:49 +01:00
Richard W.M. Jones
b7bdb63d89 tools: Check for dangling --format parameters (RHBZ#1140894).
In most C tools, virt-sysprep and virt-customize, you have to put the
--format parameter before the corresponding -a parameter.  ie.  The
following is correct:

  guestfish --format qcow2 -a disk1 -a disk2

But the following is incorrect.  The --format parameter is dangling
and prior to this commit would have been silently ignored:

  guestfish -a disk1 -a disk2 --format qcow2

After this change, dangling --format parameters now lead to an error:

  guestfish: --format parameter must appear before -a parameter

In virt-customize, also check that --attach-format parameter appears
before --attach parameter.

Thanks: Lingfei Kong
2014-09-13 10:49:58 +01:00
Richard W.M. Jones
764cbd5f69 sysprep: Use 'error' function consistently throughout the program. 2014-09-12 22:29:49 +01:00
Richard W.M. Jones
f1390d3d7a sysprep: Ensure error handler surrounds all the code so we catch and print all errors. 2014-09-12 22:20:17 +01:00
Richard W.M. Jones
3729bc1fe1 sysprep: Check --{keep,remove}-user-accounts parameters are not used when operation is disabled (RHBZ#1141157).
You will see an error like this:

$ virt-sysprep --remove-user-accounts foo,bar -a /dev/null
virt-sysprep: error: user-accounts: --remove-user-accounts parameter was
used, but the "user-account" operation is not enabled
2014-09-12 16:41:24 +01:00
Richard W.M. Jones
5066fde8f2 sysprep: Add an optional method for checking if unused arguments were passed to disabled operations. 2014-09-12 16:41:24 +01:00
Richard W.M. Jones
0513a91d2e sysprep: Replace --user-accounts option with --{remove,keep}-user-accounts.
The --user-accounts option, with its double-negative '-' prefix on
user names, is confusing.  Replace it with '--remove-user-accounts'
and '--keep-user-accounts' options.

This updates commit 128d474095.
2014-09-12 16:41:24 +01:00
Richard W.M. Jones
102e9a8c05 sysprep: Don't use --option=arg in documentation.
Fedora patches OCaml's Arg module to support --option=arg.  Since this
won't work on other distros or upstream OCaml, don't include such
examples in the documentation.
2014-09-09 23:27:51 +01:00
Pino Toscano
e89ab6dde4 tests: sysprep: slightly improve output
Add minor spacing changes, and report the image being sysprep'ed, so it
is easier to spot which image caused some warning message.
2014-09-09 15:10:33 +02:00
Pino Toscano
a0cf4b3407 sysprep: remove comment and notes about /etc/shadow lens
We are either using the upstream lens, or our copy of it, to handle
/etc/shadow, so now removing entries from it works.
2014-09-05 15:57:56 +02:00
Richard W.M. Jones
bb362f6878 OCaml virt-* tools: Handle pretty printing of exceptions through a common library function. 2014-09-03 12:37:39 +01:00
Pino Toscano
e52742e6d3 sysprep: user-account: remove the correct home
Query using augeas for the home directory of an user, instead of
hardcoding /home/<username>.
2014-09-03 11:13:54 +02:00
Pino Toscano
128d474095 sysprep: user-account: select which users to remove or keep
Enhance the user-account sysprep operation, so it is possible to select
which user accounts should be removed only (instead of all), or which to
eventually keep.
2014-09-02 16:35:43 +02:00
Richard W.M. Jones
a3881445ef Use ocamldep -all option.
In v2v, 'stringMap.ml' has no corresponding *.mli file.  ocamldep does
not generate a *.cmi dependency for such modules, and this can result
in parallel builds failing rarely because:

 (1) stringMap.ml is built (which has the side-effect of generating
     stringMap.cmi)

 (2) at the same time, types.mli is compiled.  types.mli depends on
     stringMap.cmi, but it is half way through being created by (1).

There is no dependency to serialize (1) and (2).

The resulting error is:

  File "types.mli", line 1:
  Error: Corrupted compiled interface
  stringMap.cmi

Using 'ocamldep -all' generates extra deps for the *.cmi files, and
otherwise appears to be safe, so use it.

There are currently a few upstream OCaml bugs with dependencies and
parallel builds:

http://caml.inria.fr/mantis/view.php?id=3190
http://caml.inria.fr/mantis/view.php?id=4991
http://caml.inria.fr/mantis/view.php?id=5000

It's not clear which of these apply here.
2014-09-01 22:24:14 +01:00
Pino Toscano
c6b7e6cdda customize: use the common perl file editing code
Wrap edit_file_perl to OCaml, and use it instead of the OCaml version
of it.
2014-08-29 11:30:17 +02:00
Richard W.M. Jones
f4698575cc customize: Add the ability to use --firstboot for Windows guests.
This allows you to add potentially multiple --firstboot
scripts to a Windows guest.
2014-07-23 17:02:49 +01:00
Richard W.M. Jones
fe9d3f7a90 ocaml: Ignore Warning 3: deprecated feature: String.* functions.
In OCaml 4.02, the 'string' type can be made immutable.  All String.*
functions that are concerned with creating or mutating strings now
give a warning like this:

  Warning 3: deprecated feature: String.unsafe_set

Disable this warning since we don't want to turn on immutable strings
yet.
2014-07-15 17:51:52 +01:00
Richard W.M. Jones
9d8ede1ae4 sysprep: Standard exception handling, taken from virt-builder & virt-v2v. 2014-07-15 17:38:32 +01:00
Richard W.M. Jones
f955fec760 docs: Remove useless "SHELL QUOTING" section from manual pages. 2014-07-15 17:38:31 +01:00
Pino Toscano
71ac957d4a Use Mkdtemp.temp_dir instead of Mkdtemp.mkdtemp 2014-07-07 19:33:44 +02:00
Richard W.M. Jones
b6b9b90dd7 Use -v and -x flags consistently across OCaml virt-* tools.
virt-customize:
virt-sparsify:
virt-sysprep:
virt-v2v:
  - These tools consistently used -v to mean verbose/debugging
    and -x to mean enable libguestfs tracing.

virt-builder:
virt-resize:
  - These two tools did not recognize -x at all, and used -v
    to enable libguestfs tracing and general debugging.
  - This commit changes these two tools to consume -v/-x
    consistently with the other tools.

Unfortunately this has a cascade of effects through the code.
2014-06-24 16:54:32 +01:00
Richard W.M. Jones
6f73266363 mllib: Add a common 'warning' utility function.
This commit changes many places in OCaml utilities that print
warnings to use the warning function instead.
2014-06-23 21:58:10 +01:00