-- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Richard W.M. Jones wrote:
From 9beb53ca567147aa2cd03c8e68b11706bc284713 Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 14:37:43 +0100 Subject: [PATCH 1/7] do_equal does not need to explicitly check for NEED_ROOT/ABS_PATH.
--- daemon/cmp.c | 4 ---- 1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/daemon/cmp.c b/daemon/cmp.c index 56717c5..2b7e33b 100644 --- a/daemon/cmp.c +++ b/daemon/cmp.c @@ -34,10 +34,6 @@ do_equal (const char *file1, const char *file2) char *err; int r;
- NEED_ROOT (return -1); - ABS_PATH (file1, return -1); - ABS_PATH (file2, return -1);
Right. Now that each arg is of type "Pathname" in generator.ml, those tests are redundant. ACK
Richard W.M. Jones wrote:
From 80c479162db74c461d671128237975aecc982a5e Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 14:39:31 +0100 Subject: [PATCH 2/7] cp/cp-a/mv parameters marked as Pathname.
--- daemon/cpmv.c | 4 ---- src/generator.ml | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/daemon/cpmv.c b/daemon/cpmv.c index 1007203..47b8aa2 100644 --- a/daemon/cpmv.c +++ b/daemon/cpmv.c @@ -52,10 +52,6 @@ cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest) char *err; int r;
- NEED_ROOT (return -1); - ABS_PATH (src, return -1); - ABS_PATH (dest, return -1); - srcbuf = sysroot_path (src); if (srcbuf == NULL) { reply_with_perror ("malloc"); diff --git a/src/generator.ml b/src/generator.ml index b4dd4cd..1278afd 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -2170,7 +2170,7 @@ See also: C<guestfs_scrub_device>."); This command installs GRUB (the Grand Unified Bootloader) on C<device>, with the root directory being C<root>.");
- ("cp", (RErr, [String "src"; String "dest"]), 87, [], + ("cp", (RErr, [Pathname "src"; Pathname "dest"]), 87, [], [InitBasicFS, Always, TestOutput ( [["write_file"; "/old"; "file content"; "0"]; ["cp"; "/old"; "/new"]; @@ -2189,7 +2189,7 @@ C<device>, with the root directory being C<root>."); This copies a file from C<src> to C<dest> where C<dest> is either a destination filename or destination directory.");
- ("cp_a", (RErr, [String "src"; String "dest"]), 88, [], + ("cp_a", (RErr, [Pathname "src"; Pathname "dest"]), 88, [], [InitBasicFS, Always, TestOutput ( [["mkdir"; "/olddir"]; ["mkdir"; "/newdir"]; @@ -2201,7 +2201,7 @@ either a destination filename or destination directory."); This copies a file or directory from C<src> to C<dest> recursively using the C<cp -a> command.");
- ("mv", (RErr, [String "src"; String "dest"]), 89, [], + ("mv", (RErr, [Pathname "src"; Pathname "dest"]), 89, [], [InitBasicFS, Always, TestOutput ( [["write_file"; "/old"; "file content"; "0"]; ["mv"; "/old"; "/new"];
More of the same. Looks fine. ACK.
Richard W.M. Jones wrote:
From 0790c58e369d8fe77c8d1c6473dd757c63abebab Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 14:39:59 +0100 Subject: [PATCH 3/7] inotify-add-watch does not need to explicitly check for ABS_PATH.
--- daemon/inotify.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/daemon/inotify.c b/daemon/inotify.c index 7834dcb..3e314f0 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -129,7 +129,6 @@ do_inotify_add_watch (const char *path, int mask) char *buf;
NEED_INOTIFY (-1); - ABS_PATH (path, return -1);
buf = sysroot_path (path); if (!buf) {
Confirmed. That's redundant, given "Pathname" here: ("inotify_add_watch", (RInt64 "wd", [Pathname "path"; Int "mask"]), 180, [], ack
Richard W.M. Jones wrote:
From dcd67e2c4e81bb270ea7f5ed8b6675b114afca60 Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 14:41:05 +0100 Subject: [PATCH 4/7] In rmmountpoint, have to explicitly check for ABS_PATH (*not* NEED_ROOT).
--- daemon/mount.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemon/mount.c b/daemon/mount.c index 4f74c02..d1b26fa 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -373,6 +373,9 @@ do_rmmountpoint (const char *path) { int r;
+ /* NEED_ROOT (return -1); - we don't want this test for this call. */ + ABS_PATH (path, return -1); + CHROOT_IN; r = rmdir (path); CHROOT_OUT;
Why? I note that before my commit, 84fc760439e82e6b3616abd0d1f9bd7d7eb01ec0 it had both: - NEED_ROOT (return -1); - ABS_PATH (path, return -1); - When I switched back from Pathname to String, shouldn't I have restored both?
On Thu, Aug 13, 2009 at 04:59:57PM +0200, Jim Meyering wrote:
Richard W.M. Jones wrote:
From dcd67e2c4e81bb270ea7f5ed8b6675b114afca60 Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 14:41:05 +0100 Subject: [PATCH 4/7] In rmmountpoint, have to explicitly check for ABS_PATH (*not* NEED_ROOT).
--- daemon/mount.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/daemon/mount.c b/daemon/mount.c index 4f74c02..d1b26fa 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -373,6 +373,9 @@ do_rmmountpoint (const char *path) { int r;
+ /* NEED_ROOT (return -1); - we don't want this test for this call. */ + ABS_PATH (path, return -1); + CHROOT_IN; r = rmdir (path); CHROOT_OUT;
Why? I note that before my commit, 84fc760439e82e6b3616abd0d1f9bd7d7eb01ec0 it had both:
- NEED_ROOT (return -1); - ABS_PATH (path, return -1); -
When I switched back from Pathname to String, shouldn't I have restored both?
I don't know if what was there before was correct, but the semantics of rmmountpoint are: (1) You can remove a mountpoint when nothing is mounted (pretty important for removing the final mountpoint). (2) Mountpoints should be paths. And the proposed code does that correctly. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Richard W.M. Jones wrote:
From 77b9dc04cf336e751287837fa35390d875b22e4b Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 14:41:52 +0100 Subject: [PATCH 5/7] Misc parameters which are String but should be Pathname.
--- src/generator.ml | 18 +++++++++--------- 1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/generator.ml b/src/generator.ml index 1278afd..b8f9ace 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -856,7 +856,7 @@ Note that this function cannot correctly handle binary files as end of string). For those you need to use the C<guestfs_read_file> or C<guestfs_download> functions which have a more complex interface.");
- ("ll", (RString "listing", [String "directory"]), 5, [], + ("ll", (RString "listing", [Pathname "directory"]), 5, [], [], (* XXX Tricky to test because it depends on the exact format * of the 'ls -l' command, which changes between F10 and F11. *) @@ -868,7 +868,7 @@ there is no cwd) in the format of 'ls -la'. This command is mostly useful for interactive sessions. It is I<not> intended that you try to parse the output string.");
- ("ls", (RStringList "listing", [String "directory"]), 6, [], + ("ls", (RStringList "listing", [Pathname "directory"]), 6, [], [InitBasicFS, Always, TestOutputList ( [["touch"; "/new"]; ["touch"; "/newer"]; @@ -1910,7 +1910,7 @@ I<gzip compressed> tar file) into C<directory>.
To upload an uncompressed tarball, use C<guestfs_tar_in>.");
- ("tgz_out", (RErr, [String "directory"; FileOut "tarball"]), 72, [], + ("tgz_out", (RErr, [Pathname "directory"; FileOut "tarball"]), 72, [],
Looks fine. But why not do the same for tgz_in ? ACK
[], "pack directory into compressed tarball",
...
On Thu, Aug 13, 2009 at 05:07:36PM +0200, Jim Meyering wrote:
Looks fine. But why not do the same for tgz_in ?
tgz_in is a FileIn parameter, and those functions have to be handled quite differently. In particular you can't call reply_with{,p}error for those functions -- you have to cancel the receive first. This is not really documented anywhere ... http://libguestfs.org/guestfs.3.html#functions_that_have_filein_parameters The upshot is that any functions which have any FileIn parameter must not use Pathname/Device/Dev_or_path, but must do all the checking explicitly. Luckily there are only 3 or 4 such functions. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
Richard W.M. Jones wrote:
From 91c9e00ddc528318b485137b7749e0315c76bb49 Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@centos5x32.home.annexia.org> Date: Thu, 13 Aug 2009 14:43:57 +0100 Subject: [PATCH 6/7] selinux: Don't fail if libselinux is not found.
--- daemon/selinux.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/daemon/selinux.c b/daemon/selinux.c index ad5eaa1..575baf5 100644 --- a/daemon/selinux.c +++ b/daemon/selinux.c @@ -30,8 +30,6 @@ #include "daemon.h" #include "actions.h"
-#ifdef HAVE_LIBSELINUX - /* setcon is only valid under the following circumstances: * - single threaded * - enforcing=0 @@ -39,7 +37,7 @@ int do_setcon (const char *context) { -#ifdef HAVE_SETCON +#if defined(HAVE_LIBSELINUX) && defined(HAVE_SETCON)
Looks correct. [but there's a bug in the context below] FWIW (yes, this can be sensitive -- I'm not trying to push), I find this to be more readable, since there's far less syntax to endure: #if HAVE_LIBSELINUX && HAVE_SETCON
if (setcon ((char *) context) == -1) { reply_with_perror ("setcon"); return -1; @@ -55,7 +53,7 @@ do_setcon (const char *context) char * do_getcon (void) { -#ifdef HAVE_GETCON +#if defined(HAVE_LIBSELINUX) && defined(HAVE_GETCON) security_context_t context; char *r;
@@ -77,5 +75,3 @@ do_getcon (void) return -1;
That should be "return NULL", not return -1.
#endif } - -#endif /* HAVE_LIBSELINUX */
On Thu, Aug 13, 2009 at 05:13:54PM +0200, Jim Meyering wrote:
return -1;
That should be "return NULL", not return -1.
Yup, that's a bug. I'll fix it before pushing. Thanks, Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Richard W.M. Jones wrote:
From 715f3083ad7625bca182fd1d87e20f56c5b6752b Mon Sep 17 00:00:00 2001 From: Richard Jones <rjones@trick.home.annexia.org> Date: Thu, 13 Aug 2009 15:00:38 +0100 Subject: [PATCH 7/7] mount: Check mountpoints are absolute paths.
--- daemon/mount.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/daemon/mount.c b/daemon/mount.c index d1b26fa..f593812 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -48,6 +48,8 @@ do_mount_vfs (const char *options, const char *vfstype, char *mp; char *error;
+ ABS_PATH (mountpoint, return -1); + is_root = strcmp (mountpoint, "/") == 0;
if (!root_mounted && !is_root) {
Looks fine. ACK
participants (2)
-
Jim Meyering -
Richard W.M. Jones