[PATCH] Add a test for an executable stack in libguestfs.so
by Matthew Booth
I've updated the patch. It's now in regressions, and checks both libguestfs.so
and the guest daemon. It occurs to me that it's the daemon that's would get an
executable stack from the specific patch I posted the other day. However, would
this actually matter specifically for the daemon?
15 years, 1 month
[PATCH] build: generate some just-removed files in po/
by Jim Meyering
My change that removed most of po/*
should have included this patch to generate two required files.
Without this change, "make -C po" fails like this:
make: Entering directory `/o/libguestfs/po'
make: *** No rule to make target `/config.status', needed by `Makefile'. Stop.
...
Once you've pulled this change, you will need to
run ./bootstrap manually to make it take effect.
>From 6d9d5a54f871c229a5d8b65edd5ddf25850ce713 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 5 Aug 2009 08:01:38 -0400
Subject: [PATCH] build: generate some just-removed files in po/
* bootstrap: Generate po/Makevars and po/LINGUAS.
---
bootstrap | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/bootstrap b/bootstrap
index e4ddf85..d46b3be 100755
--- a/bootstrap
+++ b/bootstrap
@@ -60,6 +60,21 @@ case ${GNULIB_SRCDIR--} in
;;
esac
+ls po/*.po 2>/dev/null | sed 's|.*/||; s|\.po$||' > po/LINGUAS
+
+# Create gettext configuration.
+echo "$0: Creating po/Makevars from po/Makevars.template ..."
+rm -f po/Makevars
+sed '
+ /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
+ /^MSGID_BUGS_ADDRESS *=/s/=.*/= '"$MSGID_BUGS_ADDRESS"'/
+ /^XGETTEXT_OPTIONS *=/{
+ s/$/ \\/
+ a\
+ '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
+ }
+' po/Makevars.template >po/Makevars
+
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit
--
1.6.4.226.g08063
15 years, 1 month
syntax-check changes
by Jim Meyering
With this, "make syntax-check" runs a few more tests, all passing.
>From febff9d2a35c4f40abbaf8943146476bdeac671e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 13:49:19 +0200
Subject: [PATCH 1/8] build: remove more files added by ./autogen.sh
* po/LINGUAS: Remove file.
* po/Makefile.in.in: Likewise.
* po/Makevars: Likewise.
* po/Rules-quot: Likewise.
* po/boldquot.sed: Likewise.
* po/en(a)boldquot.header: Likewise.
* po/en(a)quot.header: Likewise.
* po/insert-header.sin: Likewise.
* po/quot.sed: Likewise.
* po/remove-potcdate.sin: Likewise.
---
po/LINGUAS | 1 -
po/Makefile.in.in | 366 ------------------------------------------------
po/Makevars | 42 ------
po/Rules-quot | 47 ------
po/boldquot.sed | 10 --
po/en(a)boldquot.header | 25 ----
po/en(a)quot.header | 22 ---
po/insert-header.sin | 23 ---
po/quot.sed | 6 -
po/remove-potcdate.sin | 19 ---
10 files changed, 0 insertions(+), 561 deletions(-)
delete mode 100644 po/LINGUAS
delete mode 100644 po/Makefile.in.in
delete mode 100644 po/Makevars
delete mode 100644 po/Rules-quot
delete mode 100644 po/boldquot.sed
delete mode 100644 po/en(a)boldquot.header
delete mode 100644 po/en(a)quot.header
delete mode 100644 po/insert-header.sin
delete mode 100644 po/quot.sed
delete mode 100644 po/remove-potcdate.sin
...
>From dc3d0e3b8ed8e77b1314f09d116ed97f6a440914 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 13:55:51 +0200
Subject: [PATCH 2/8] build: don't emit trailing blanks, remove generated file
* ocaml/Makefile.am (.depend): Don't redirect directly to $@.
Filter out trailing blanks.
* ocaml/.depend: Regenerate.
---
ocaml/.depend | 10 +++++-----
ocaml/Makefile.am | 5 +++--
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/ocaml/.depend b/ocaml/.depend
index 5074667..2a582db 100644
--- a/ocaml/.depend
+++ b/ocaml/.depend
@@ -1,5 +1,5 @@
-guestfs.cmi:
-bindtests.cmo: guestfs.cmi
-bindtests.cmx: guestfs.cmx
-guestfs.cmo: guestfs.cmi
-guestfs.cmx: guestfs.cmi
+guestfs.cmi:
+bindtests.cmo: guestfs.cmi
+bindtests.cmx: guestfs.cmx
+guestfs.cmo: guestfs.cmi
+guestfs.cmx: guestfs.cmi
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 1aa0cb6..d65ebaa 100644
--- a/ocaml/Makefile.am
+++ b/ocaml/Makefile.am
@@ -94,8 +94,9 @@ t/%.cmx: t/%.ml mlguestfs.cmxa
depend: .depend
.depend: $(wildcard *.mli) $(wildcard *.ml)
- rm -f .depend
- $(OCAMLFIND) ocamldep $^ > $@
+ rm -f $@ $@-t
+ $(OCAMLFIND) ocamldep $^ | sed 's/ *$$//' > $@-t
+ mv $@-t $@
include .depend
--
1.6.4.70.g9c084
>From e15ff2113f5b2a7e0aa138c47c14e93268d25aed Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 14:46:38 +0200
Subject: [PATCH 3/8] maint: use COPYING.LIB version 2.1
* COPYING.LIB: Update to 2.1.
* .x-sc_TAB_in_indentation: Also exempt COPYING.LIB.
---
.x-sc_TAB_in_indentation | 2 +-
COPYING.LIB | 281 ++++++++++++++++++++--------------------------
2 files changed, 125 insertions(+), 158 deletions(-)
diff --git a/.x-sc_TAB_in_indentation b/.x-sc_TAB_in_indentation
index c73edf2..ef5b1b6 100644
--- a/.x-sc_TAB_in_indentation
+++ b/.x-sc_TAB_in_indentation
@@ -1,6 +1,6 @@
^appliance/debian/modules/
^images/
-^COPYING$
+^COPYING(.LIB)?$
^\.gitmodules$
(^|\/)ChangeLog[^/]*$
(^|\/)(?:GNU)?[Mm]akefile[^/]*$
diff --git a/COPYING.LIB b/COPYING.LIB
index ba2be48..ef3b17b 100644
--- a/COPYING.LIB
+++ b/COPYING.LIB
@@ -1,128 +1,112 @@
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
- GNU LESSER GENERAL PUBLIC LICENSE
- Version 2.1, February 1999
...
>From 8ae7e1057f43e9b79260cdf191f39d657fdf0293 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 14:00:11 +0200
Subject: [PATCH 4/8] build: remove trailing blanks, enable syntax-check
* regressions/test-cancellation-download-librarycancels.sh:
* src/generator.ml:
* cfg.mk (disable_temporarily): Remove sc_trailing_blank.
* .x-sc_trailing_blank: New file.
---
.x-sc_trailing_blank | 1 +
cfg.mk | 3 +--
.../test-cancellation-download-librarycancels.sh | 2 +-
src/generator.ml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
create mode 100644 .x-sc_trailing_blank
diff --git a/.x-sc_trailing_blank b/.x-sc_trailing_blank
new file mode 100644
index 0000000..d4a4f31
--- /dev/null
+++ b/.x-sc_trailing_blank
@@ -0,0 +1 @@
+images/bin-win64.exe
diff --git a/cfg.mk b/cfg.mk
index 7130cea..c672e4d 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -70,8 +70,7 @@ disable_temporarily = \
sc_m4_quote_check \
sc_prohibit_trailing_blank_lines \
sc_avoid_ctype_macros \
- sc_avoid_write \
- sc_trailing_blank
+ sc_avoid_write
# Avoid uses of write(2). Either switch to streams (fwrite), or use
# the safewrite wrapper.
diff --git a/regressions/test-cancellation-download-librarycancels.sh b/regressions/test-cancellation-download-librarycancels.sh
index 9db1248..b0d78c9 100755
--- a/regressions/test-cancellation-download-librarycancels.sh
+++ b/regressions/test-cancellation-download-librarycancels.sh
@@ -18,7 +18,7 @@
# Test download where the library cancels.
#
-#
+#
set -e
diff --git a/src/generator.ml b/src/generator.ml
index 9ef99bd..c9b3315 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -90,7 +90,7 @@ and ret =
(* "RStruct" is a function which returns a single named structure
* or an error indication (in C, a struct, and in other languages
* with varying representations, but usually very efficient). See
- * after the function list below for the structures.
+ * after the function list below for the structures.
*)
| RStruct of string * string (* name of retval, name of struct *)
--
1.6.4.70.g9c084
>From 1fc38df2dfe7e991e27d4c2fdd50fbd41ee9cf70 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 14:01:38 +0200
Subject: [PATCH 5/8] build: tweak HACKING so we pass "make syntax-check"
* HACKING: Convert leading TABs.
---
HACKING | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/HACKING b/HACKING
index 815ee16..cb339bd 100644
--- a/HACKING
+++ b/HACKING
@@ -44,8 +44,8 @@ If you use Emacs, add the following to one of one of your start-up files
(setq c-indent-level 2)
(setq c-basic-offset 2))
(add-hook 'c-mode-hook
- '(lambda () (if (string-match "/libguestfs" (buffer-file-name))
- (libguestfs-c-mode))))
+ '(lambda () (if (string-match "/libguestfs" (buffer-file-name))
+ (libguestfs-c-mode))))
Directories
----------------------------------------------------------------------
--
1.6.4.70.g9c084
>From a4c544ef1282b2ac73ce43885bd7a9691958958e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 14:03:17 +0200
Subject: [PATCH 6/8] build: enable syntax-check: TAB-only indentation in Makefiles
* cfg.mk (disable_temporarily): Remove sc_makefile_TAB_only_indentation.
---
cfg.mk | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index c672e4d..c43185c 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -63,7 +63,6 @@ local-checks-to-skip = \
sc_useless_cpp_parens
disable_temporarily = \
- sc_makefile_TAB_only_indentation \
sc_unmarked_diagnostics \
sc_prohibit_ctype_h \
sc_prohibit_asprintf \
--
1.6.4.70.g9c084
>From 3625b0198c74f2e01eb76b99dadba3a80f97a880 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 14:19:29 +0200
Subject: [PATCH 7/8] build: exempt symlinks from trailing-blank-line prohibition
* cfg.mk (sc_prohibit_trailing_blank_lines): Exempt symlinks.
---
cfg.mk | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index c43185c..2b37450 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -134,8 +134,9 @@ sc_prohibit_gethostby:
# Disallow trailing blank lines.
sc_prohibit_trailing_blank_lines:
- @$(VC_LIST_EXCEPT) | xargs perl -ln -0777 -e \
- '/\n\n+$$/ and print $$ARGV' > $@-t
+ @$(VC_LIST_EXCEPT) \
+ | xargs perl -ln -0777 -e \
+ '-f $$ARGV or next; /\n\n+$$/ and print $$ARGV' > $@-t
@found=0; test -s $@-t && { found=1; cat $@-t 1>&2; \
echo '$(ME): found trailing blank line(s)' 1>&2; }; \
rm -f $@-t; \
--
1.6.4.70.g9c084
>From 0c463dd0aa962c405b1be32c925acf9891c96bfc Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Tue, 4 Aug 2009 14:21:32 +0200
Subject: [PATCH 8/8] build: remove trailing blank lines; enable the syntax-check rule
* cfg.mk (disable_temporarily): Remove sc_prohibit_trailing_blank_lines.
* appliance/Makefile.am: Remove trailing blank line(s).
* appliance/debian/modules/y0_install-guestfsd: Likewise.
* appliance/make.sh.in: Likewise.
* appliance/packagelist.in: Likewise.
* appliance/update.sh.in: Likewise.
* haskell/run-bindtests: Likewise.
* ocaml/run-bindtests: Likewise.
* python/run-python-tests: Likewise.
* recipes/squashfs.example: Likewise.
* ruby/run-ruby-tests: Likewise.
---
appliance/Makefile.am | 1 -
appliance/debian/modules/y0_install-guestfsd | 1 -
appliance/make.sh.in | 1 -
appliance/packagelist.in | 1 -
appliance/update.sh.in | 1 -
cfg.mk | 1 -
haskell/run-bindtests | 1 -
ocaml/run-bindtests | 1 -
python/run-python-tests | 1 -
recipes/squashfs.example | 1 -
ruby/run-ruby-tests | 1 -
11 files changed, 0 insertions(+), 11 deletions(-)
diff --git a/appliance/Makefile.am b/appliance/Makefile.am
index 8391b8b..d1338bf 100644
--- a/appliance/Makefile.am
+++ b/appliance/Makefile.am
@@ -146,4 +146,3 @@ CLEANFILES = $(APPLIANCE_FILES) packagelist kmod.whitelist supermin.incfiles
clean-local:
rm -rf $(top_builddir)/initramfs
-
diff --git a/appliance/debian/modules/y0_install-guestfsd b/appliance/debian/modules/y0_install-guestfsd
index 17bbbdc..c95e4f0 100755
--- a/appliance/debian/modules/y0_install-guestfsd
+++ b/appliance/debian/modules/y0_install-guestfsd
@@ -30,4 +30,3 @@ rm -rf "$DEBIRF_ROOT"/usr/share/man/
echo $PWD
install -o root -g root -m 0755 ../daemon/guestfsd "$DEBIRF_ROOT"/sbin/guestfsd
install -o root -g root -m 0755 init "$DEBIRF_ROOT"/sbin/init
-
diff --git a/appliance/make.sh.in b/appliance/make.sh.in
index a132ed8..d76c961 100755
--- a/appliance/make.sh.in
+++ b/appliance/make.sh.in
@@ -145,4 +145,3 @@ elif [ "@DIST@" = "DEBIAN" ]; then
mkdir -p @top_builddir@/initramfs
touch @top_builddir(a)/initramfs/fakeroot.log
fi
-
diff --git a/appliance/packagelist.in b/appliance/packagelist.in
index 9dbef11..be45fc4 100644
--- a/appliance/packagelist.in
+++ b/appliance/packagelist.in
@@ -39,4 +39,3 @@ ntfs-3g
procps
strace
zerofree
-
diff --git a/appliance/update.sh.in b/appliance/update.sh.in
index cdc441b..0222a75 100755
--- a/appliance/update.sh.in
+++ b/appliance/update.sh.in
@@ -46,4 +46,3 @@ elif [ "@DIST@" = "DEBIAN" ]; then
ln -sf debian/debirf-libguestfs_@REPO(a)*.cgz $output
ln -sf debian/vmlinuz-* $vmlinuz
fi
-
diff --git a/cfg.mk b/cfg.mk
index 2b37450..1d02b24 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -67,7 +67,6 @@ disable_temporarily = \
sc_prohibit_ctype_h \
sc_prohibit_asprintf \
sc_m4_quote_check \
- sc_prohibit_trailing_blank_lines \
sc_avoid_ctype_macros \
sc_avoid_write
diff --git a/haskell/run-bindtests b/haskell/run-bindtests
index ce01af9..f9ea434 100755
--- a/haskell/run-bindtests
+++ b/haskell/run-bindtests
@@ -20,4 +20,3 @@ set -e
./Bindtests > bindtests.tmp
diff -u ../bindtests bindtests.tmp
-
diff --git a/ocaml/run-bindtests b/ocaml/run-bindtests
index a9162c9..5200fec 100755
--- a/ocaml/run-bindtests
+++ b/ocaml/run-bindtests
@@ -20,4 +20,3 @@ set -e
./bindtests > bindtests.tmp
diff -u ../bindtests bindtests.tmp
-
diff --git a/python/run-python-tests b/python/run-python-tests
index 90e38b3..487f8ab 100755
--- a/python/run-python-tests
+++ b/python/run-python-tests
@@ -21,4 +21,3 @@ set -e
for f in t/*.py; do
python $f
done
-
diff --git a/recipes/squashfs.example b/recipes/squashfs.example
index f10d195..af40dd5 100644
--- a/recipes/squashfs.example
+++ b/recipes/squashfs.example
@@ -34,4 +34,3 @@ drwxr-xr-x 18 root root 0 May 29 08:44 ..
-rw-r--r-- 1 root root 2938 Apr 10 12:15 PAM.8.gz
-rw-r--r-- 1 root root 736 Feb 24 20:25 PolicyKit.8.gz
lrwxrwxrwx 1 root root 15 May 14 06:41 accept.8.gz -> cupsaccept.8.gz
-
diff --git a/ruby/run-ruby-tests b/ruby/run-ruby-tests
index b371bfb..6bf898b 100755
--- a/ruby/run-ruby-tests
+++ b/ruby/run-ruby-tests
@@ -19,4 +19,3 @@
set -e
rake test "$@"
-
--
1.6.4.70.g9c084
15 years, 1 month
[PATCH] Add a test for an executable stack in libguestfs.so
by Matthew Booth
---
capitests/Makefile.am | 4 ++-
capitests/check-noexec-stack.pl | 58 +++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletions(-)
create mode 100755 capitests/check-noexec-stack.pl
diff --git a/capitests/Makefile.am b/capitests/Makefile.am
index 71928ec..08466ac 100644
--- a/capitests/Makefile.am
+++ b/capitests/Makefile.am
@@ -22,13 +22,15 @@ EXTRA_DIST = \
# in the generator.
check_PROGRAMS = tests test-command
+check_SCRIPTS = check-noexec-stack.pl
tests_SOURCES = tests.c
tests_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src -Wall
tests_LDADD = $(top_builddir)/src/libguestfs.la
-TESTS = tests
+TESTS = check-noexec-stack.pl tests
TESTS_ENVIRONMENT = \
+ NOEXEC_CHECK=$(top_builddir)/src/.libs/libguestfs.so \
SKIP_TEST_COMMAND=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
SKIP_TEST_COMMAND_LINES=$(shell ldd test-command | grep -sq 'not a dynamic executable' || echo 1) \
SKIP_TEST_ZEROFREE=$(shell test -x ../initramfs/usr/sbin/zerofree || echo 1) \
diff --git a/capitests/check-noexec-stack.pl b/capitests/check-noexec-stack.pl
new file mode 100755
index 0000000..7654c78
--- /dev/null
+++ b/capitests/check-noexec-stack.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $file = $ENV{NOEXEC_CHECK};
+die("NOEXEC_CHECK not set") unless(defined($file));
+
+my $output;
+open($output, '-|', "readelf -l $file") or die("Unable to execute readelf");
+
+my $offset;
+my $line = 1;
+
+# Find the offset of the Flags field
+while(<$output>) {
+ next unless(/^\s*Type\b/);
+
+ my @lines;
+ push(@lines, $_);
+
+ # Look for a Flg field on this line (32 bit)
+ $offset = index($_, 'Flg ');
+
+ if(-1 == $offset) {
+ # 64 bit is split over 2 lines. Look for a Flags field on the next line
+ $_ = <$output>;
+ $offset = index($_, 'Flags ');
+ $line = 2;
+ push(@lines, $_);
+ }
+
+ die("Unrecognised header: ".join("\n", @lines)) if(-1 == $offset);
+ last;
+}
+
+# Find the GNU_STACK entry
+while(<$output>) {
+ next unless(/^\s*GNU_STACK\b/);
+
+ # Skip over input lines according to the header
+ for(my $i = 1; $i < $line; $i++) {
+ $_ = <$output>;
+ }
+
+ my $flags = substr($_, $offset, 3);
+
+ $flags =~ /^[ R][ W]([ E])$/ or die("Unrecognised flags: $flags");
+
+ if('E' eq $1) {
+ print "***** $ARGV[0] has an executable stack *****\n";
+ exit(1);
+ }
+
+ exit(0);
+}
+
+die("Didn't find GNU_STACK entry");
--
1.6.2.5
15 years, 1 month
[PATCH] Fix swapon_label test
by Matthew Booth
The swapon label test has a side-effect, in that it creates a new partition.
This causes the later failure of the list_partitions test.
This change causes the swapon_label test to scrub /dev/sdb after the test, and
then re-read the partition table.
---
src/generator.ml | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/src/generator.ml b/src/generator.ml
index 9ef99bd..fe538a6 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -3254,7 +3254,9 @@ This command disables the libguestfs appliance swap on file.");
[["sfdiskM"; "/dev/sdb"; ","];
["mkswap_L"; "swapit"; "/dev/sdb1"];
["swapon_label"; "swapit"];
- ["swapoff_label"; "swapit"]])],
+ ["swapoff_label"; "swapit"];
+ ["scrub_device"; "/dev/sdb"];
+ ["blockdev_rereadpt"; "/dev/sdb"]])],
"enable swap on labelled swap partition",
"\
This command enables swap to a labelled swap partition.
--
1.6.2.5
15 years, 1 month
Re: [Libguestfs] How to get information about the guest filesystems by libguestfs
by Charles Duffy
I looked into it -- what exists in newer versions (via "guestfish -i") isn't
really built-in as such, but rather calls virt-inspector. There is no C
implementation presently, and you would need to rewrite the (fairly complex)
Perl code in C to get that functionality independent of it.
That's certainly a feasible thing to do -- but why is it so important to you
that everything be pure C?
15 years, 1 month