[PATCH] sysprep: remove RH subscription manager log files
by Pino Toscano
Part of RHBZ#1063374.
---
sysprep/sysprep_operation_logfiles.ml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sysprep/sysprep_operation_logfiles.ml b/sysprep/sysprep_operation_logfiles.ml
index f154b4d..4c3eb8c 100644
--- a/sysprep/sysprep_operation_logfiles.ml
+++ b/sysprep/sysprep_operation_logfiles.ml
@@ -98,6 +98,9 @@ let globs = List.sort compare [
"/etc/Pegasus/*.csr";
"/etc/Pegasus/*.pem";
"/etc/Pegasus/*.srl";
+
+ (* Red Hat subscription manager log files *)
+ "/var/log/rhsm/*";
]
let globs_as_pod = String.concat "\n" (List.map ((^) " ") globs)
--
1.8.3.1
10 years, 10 months
[PATCH] sysprep: remove RH subscription manager files
by Pino Toscano
Add a new operation for it, which should do what
`subscription-manager clean` does.
Part of RHBZ#1063374.
---
po/POTFILES-ml | 1 +
sysprep/Makefile.am | 1 +
.../sysprep_operation_rh_subscription_manager.ml | 42 ++++++++++++++++++++++
3 files changed, 44 insertions(+)
create mode 100644 sysprep/sysprep_operation_rh_subscription_manager.ml
diff --git a/po/POTFILES-ml b/po/POTFILES-ml
index cd869fb..7937728 100644
--- a/po/POTFILES-ml
+++ b/po/POTFILES-ml
@@ -57,6 +57,7 @@ sysprep/sysprep_operation_pam_data.ml
sysprep/sysprep_operation_password.ml
sysprep/sysprep_operation_puppet_data_log.ml
sysprep/sysprep_operation_random_seed.ml
+sysprep/sysprep_operation_rh_subscription_manager.ml
sysprep/sysprep_operation_rhn_systemid.ml
sysprep/sysprep_operation_rpm_db.ml
sysprep/sysprep_operation_samba_db_log.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index 4c03c7f..2600477 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -60,6 +60,7 @@ operations = \
password \
puppet_data_log \
random_seed \
+ rh_subscription_manager \
rhn_systemid \
rpm_db \
samba_db_log \
diff --git a/sysprep/sysprep_operation_rh_subscription_manager.ml b/sysprep/sysprep_operation_rh_subscription_manager.ml
new file mode 100644
index 0000000..d6c38b2
--- /dev/null
+++ b/sysprep/sysprep_operation_rh_subscription_manager.ml
@@ -0,0 +1,42 @@
+(* virt-sysprep
+ * Copyright (C) 2014 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Sysprep_operation
+open Common_gettext.Gettext
+
+module G = Guestfs
+
+let rh_subscription_manager_perform g root side_effects =
+ let typ = g#inspect_get_type root in
+ let distro = g#inspect_get_distro root in
+
+ match typ, distro with
+ | "linux", "rhel" ->
+ Array.iter g#rm_rf (g#glob_expand "/etc/pki/consumer/*");
+ Array.iter g#rm_rf (g#glob_expand "/etc/pki/entitlement/*")
+ | _ -> ()
+
+let op = {
+ defaults with
+ name = "rh-subscription-manager";
+ enabled_by_default = true;
+ heading = s_"Remove the RH subscription manager files";
+ perform_on_filesystems = Some rh_subscription_manager_perform;
+}
+
+let () = register_operation op
--
1.8.3.1
10 years, 10 months
[PATCH 2/2] mllib: hostname: add a newline in /etc/hostname
by Pino Toscano
/etc/hostname usually has an ending newline, so add it when changing it.
---
mllib/hostname.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mllib/hostname.ml b/mllib/hostname.ml
index e1c5d4b..cffba6b 100644
--- a/mllib/hostname.ml
+++ b/mllib/hostname.ml
@@ -79,7 +79,7 @@ and replace_line_in_file g filename key value =
g#write filename content
and update_etc_hostname g hostname =
- g#write "/etc/hostname" hostname
+ g#write "/etc/hostname" (hostname ^ "\n")
and update_etc_machine_info g hostname =
replace_line_in_file g "/etc/machine-info" "PRETTY_HOSTNAME" hostname
--
1.8.3.1
10 years, 10 months
P2V: Headless support
by Maros Zatko
This introduces support to run P2V without X server. Runtime parameters
are specified via kernel command line making it hopefully suitable for
automated migration with a little help of PXE boot.
Patchset is not squashed and represents dev. history.
10 years, 10 months
[PATCH] list-filesystems: Do not segfault if guestfs_btrfs_subvolume_list returns an error (RHBZ#1064008).
by Richard W.M. Jones
If calling guestfs_list_filesystems with a disk image containing a
corrupt btrfs volume, the library would segfault. There was a missing
check for a NULL return from guestfs_btrfs_subvolume_list.
This adds a check, returning the real error up through the stack and
out of guestfs_list_filesystems.
This is potentially a denial of service if processing disk images from
untrusted sources, but is not exploitable.
Thanks: Jeff Bastian for reporting the bug.
---
src/listfs.c | 34 +++++++++++++++++++++++-----------
1 file changed, 23 insertions(+), 11 deletions(-)
diff --git a/src/listfs.c b/src/listfs.c
index 9102c55..bbdb0a2 100644
--- a/src/listfs.c
+++ b/src/listfs.c
@@ -39,7 +39,7 @@
*/
static void remove_from_list (char **list, const char *item);
-static void check_with_vfs_type (guestfs_h *g, const char *dev, struct stringsbuf *sb);
+static int check_with_vfs_type (guestfs_h *g, const char *dev, struct stringsbuf *sb);
static int is_mbr_partition_type_42 (guestfs_h *g, const char *partition);
char **
@@ -78,17 +78,21 @@ guestfs__list_filesystems (guestfs_h *g)
/* Use vfs-type to check for filesystems on devices. */
for (i = 0; devices[i] != NULL; ++i)
- check_with_vfs_type (g, devices[i], &ret);
+ if (check_with_vfs_type (g, devices[i], &ret) == -1)
+ goto error;
/* Use vfs-type to check for filesystems on partitions. */
for (i = 0; partitions[i] != NULL; ++i) {
- if (! is_mbr_partition_type_42 (g, partitions[i]))
- check_with_vfs_type (g, partitions[i], &ret);
+ if (! is_mbr_partition_type_42 (g, partitions[i])) {
+ if (check_with_vfs_type (g, partitions[i], &ret) == -1)
+ goto error;
+ }
}
/* Use vfs-type to check for filesystems on md devices. */
for (i = 0; mds[i] != NULL; ++i)
- check_with_vfs_type (g, mds[i], &ret);
+ if (check_with_vfs_type (g, mds[i], &ret) == -1)
+ goto error;
if (guestfs_feature_available (g, (char **) lvm2)) {
/* Use vfs-type to check for filesystems on LVs. */
@@ -96,7 +100,8 @@ guestfs__list_filesystems (guestfs_h *g)
if (lvs == NULL) goto error;
for (i = 0; lvs[i] != NULL; ++i)
- check_with_vfs_type (g, lvs[i], &ret);
+ if (check_with_vfs_type (g, lvs[i], &ret) == -1)
+ goto error;
}
if (guestfs_feature_available (g, (char **) ldm)) {
@@ -105,13 +110,15 @@ guestfs__list_filesystems (guestfs_h *g)
if (ldmvols == NULL) goto error;
for (i = 0; ldmvols[i] != NULL; ++i)
- check_with_vfs_type (g, ldmvols[i], &ret);
+ if (check_with_vfs_type (g, ldmvols[i], &ret) == -1)
+ goto error;
ldmparts = guestfs_list_ldm_partitions (g);
if (ldmparts == NULL) goto error;
for (i = 0; ldmparts[i] != NULL; ++i)
- check_with_vfs_type (g, ldmparts[i], &ret);
+ if (check_with_vfs_type (g, ldmparts[i], &ret) == -1)
+ goto error;
}
/* Finish off the list and return it. */
@@ -143,7 +150,7 @@ remove_from_list (char **list, const char *item)
* Apart from some types which we ignore, add the result to the
* 'ret' string list.
*/
-static void
+static int
check_with_vfs_type (guestfs_h *g, const char *device, struct stringsbuf *sb)
{
const char *v;
@@ -161,6 +168,9 @@ check_with_vfs_type (guestfs_h *g, const char *device, struct stringsbuf *sb)
CLEANUP_FREE_BTRFSSUBVOLUME_LIST struct guestfs_btrfssubvolume_list *vols =
guestfs_btrfs_subvolume_list (g, device);
+ if (vols == NULL)
+ return -1;
+
for (size_t i = 0; i < vols->len; i++) {
struct guestfs_btrfssubvolume *this = &vols->val[i];
guestfs___add_sprintf (g, sb,
@@ -178,17 +188,19 @@ check_with_vfs_type (guestfs_h *g, const char *device, struct stringsbuf *sb)
*/
size_t n = strlen (vfs_type);
if (n >= 7 && STREQ (&vfs_type[n-7], "_member"))
- return;
+ return 0;
/* Ignore LUKS-encrypted partitions. These are also containers. */
if (STREQ (vfs_type, "crypto_LUKS"))
- return;
+ return 0;
v = vfs_type;
}
guestfs___add_string (g, sb, device);
guestfs___add_string (g, sb, v);
+
+ return 0;
}
/* We should ignore partitions that have MBR type byte 0x42, because
--
1.8.4.2
10 years, 10 months
[PATCH 0/3] virt-builder: copy local files instead of using curl
by Pino Toscano
Hi,
this patch serie does a small optimisation in virt-builder, i.e. make
its internal Downloader just copy files when the source is a local URI,
instead of spawn curl in this case too.
Pino Toscano (3):
builder: isolate C libraries in an own OCAMLCLIBS
builder: prepare for different per-protocol download actions
builder: do a copy when downloading local files
builder/Makefile.am | 13 ++++++-
builder/downloader.ml | 95 +++++++++++++++++++++++++++++++--------------------
2 files changed, 70 insertions(+), 38 deletions(-)
--
1.8.3.1
10 years, 10 months
[PATCH 0/4] add GUID validation (RHBZ#1008417)
by Pino Toscano
Hi,
this patch serie adds a new GUID type in the generator, which would do
the same as String, but also validating (just in the C output) the
passed GUID string.
This allows to reject invalid GUIDs before passing them to low-level
tools.
Pino Toscano (4):
utils: add a function to validate a GUID string
generator: add a GUID parameter type
generator: generate code for parameter validation
actions/part_set_gpt_type: set type of "guid" parameter as "GUID"
(RHBZ#1008417).
generator/actions.ml | 11 +++++++++-
generator/bindtests.ml | 3 ++-
generator/c.ml | 54 ++++++++++++++++++++++++++++++++++++++++++++----
generator/csharp.ml | 6 ++++--
generator/daemon.ml | 4 ++--
generator/erlang.ml | 3 ++-
generator/fish.ml | 11 ++++++----
generator/gobject.ml | 8 ++++---
generator/golang.ml | 9 +++++---
generator/haskell.ml | 8 +++----
generator/java.ml | 15 +++++++++-----
generator/lua.ml | 6 +++---
generator/ocaml.ml | 9 +++++---
generator/perl.ml | 8 +++----
generator/php.ml | 12 ++++++-----
generator/python.ml | 12 +++++------
generator/ruby.ml | 4 ++--
generator/tests_c_api.ml | 6 ++++--
generator/types.ml | 6 ++++++
generator/utils.ml | 3 ++-
generator/xdr.ml | 2 +-
src/guestfs-internal.h | 3 +++
src/test-utils.c | 14 +++++++++++++
src/utils.c | 44 +++++++++++++++++++++++++++++++++++++++
24 files changed, 204 insertions(+), 57 deletions(-)
--
1.8.3.1
10 years, 10 months
[PATCH 1/2] hivex: Use correct constant in diagnostic error message
by Hilko Bengen
---
lib/value.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/value.c b/lib/value.c
index c4e21ec..f222b41 100644
--- a/lib/value.c
+++ b/lib/value.c
@@ -334,7 +334,7 @@ hivex_value_value (hive_h *h, hive_value_h value,
/* Arbitrarily limit the length that we will read. */
if (len > HIVEX_MAX_VALUE_LEN) {
SET_ERRNO (ERANGE, "data length > HIVEX_MAX_VALUE_LEN (%zu > %d)",
- len, HIVEX_MAX_SUBKEYS);
+ len, HIVEX_MAX_VALUE_LEN);
return NULL;
}
--
1.9.rc1
10 years, 10 months
Possible to speed up guestmount?
by Patrick Schleizer
Hi,
Apparently,
guestmount -o allow_other -a "/path/to/raw_file" -m /dev/sda1
"/path/to/mountfolder"
is much slower than
kpartx -av "/path/to/raw_file"
mount /dev/mapper/loop0p1 /path/to/mountfolder
(Doing lots of read/write inside the image.)
I thought guestmount "only" scripts the above. Seems I was wrong on that.
I am currently using libguestfs 1.18.1-1 (because it comes with Debian
wheezy/stable) and read the FAQ [1] [2], but still have questions.
Seems my version is higher than 1.13.16, so far so good. I am using
guestmount inside a virtual machine (to prevent damaging my hosts due to
own stuff).
It's a sparse raw image (because the tool I am using to create them
(grml-debootstrap [3]) can only create raw images).
With guestmount,
time sudo chroot /path/to/mountfolder sudo -u user echo test
takes ~1 second. In comparison, doing the same using kpartx/mount only
takes ~0.01 seconds.
Converting the image to a metadata preallocated qcow2 image didn't help
either.
Is there anything I can do to speed up guestmount?
Cheers,
Patrick
[1] http://libguestfs.org/guestfs-faq.1.html#upload-or-write-seem-very-slow
[2] http://libguestfs.org/guestfs-performance.1.html
[3] http://grml.org/grml-debootstrap/
10 years, 10 months
libguestfs and zfs-fuse
by Andre Goree
I'm wondering whether or not anyone has tried to use guestmount on an
image with a ZFS partition (MBR partition table). I can't seem to find
much on the internet regarding it, but I do see hints that may lead me
to a solution. I'm under the impression that libguestfs can use what
ever is available to the kernel on the host -- in my case I have zfs-use
installed and running. I can't seem to mount the image, however.
It's the exact same problem stated in this link[1], however I'm not able
to discern what exactly is needed to have guestmount be aware that the
volume is a zfs partition. In my trace, I see the following (larger
selection here[2]):
libguestfs: recv_from_daemon: received GUESTFS_LAUNCH_FLAG
libguestfs: [03558ms] appliance is up
libguestfs: trace: launch = 0
libguestfs: trace: mount_options "" "/dev/sda1" "/"
libguestfs: send_to_daemon: 72 bytes: 00 00 00 44 | 20 00 f5 f5 | 00 00
00 04 | 00 00 00 4a | 00 00 00 00 | ...
guestfsd: main_loop: new request, len 0x44
/dev/sda1: No such file or directory
mount -o /dev/vda1 /sysroot/
mount: unknown filesystem type 'zfs_member'
guestfsd: error: /dev/vda1 on /: mount: unknown filesystem type
'zfs_member'
From the aforementioned link, I should use zpool import -d $(dir) -R
(mountpoint) to mount ZFS filesystems, however I'm not sure how to
reconcile that with the 'guestmount' command or whether or not it's a
possibility. Since zfs-fuse is a dependency of libguestfs itself,
though, I'm hoping someone has made the attempt other than myself and
can provide a bit of insight, thanks in advance!
[1]https://bbs.archlinux.org/viewtopic.php?pid=1279000
[2]http://pastebin.com/dw0vyWB1
--
Andre Goree
-=-=-=-=-=-
Email - andre at drenet.net
Website - http://www.drenet.net
PGP key - http://www.drenet.net/pubkey.txt
-=-=-=-=-=-
10 years, 10 months