[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCHx7] Misc patches



-- 
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
>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);
-
   file1buf = sysroot_path (file1);
   if (file1buf == NULL) {
     reply_with_perror ("malloc");
-- 
1.6.2.5

>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"];
-- 
1.6.2.5

>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) {
-- 
1.6.2.5

>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;
-- 
1.6.2.5

>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, [],
    [],
    "pack directory into compressed tarball",
    "\
@@ -2595,7 +2595,7 @@ more difficult.
 It is an interface to the L<scrub(1)> program.  See that
 manual page for more details.");
 
-  ("scrub_file", (RErr, [String "file"]), 115, [],
+  ("scrub_file", (RErr, [Pathname "file"]), 115, [],
    [InitBasicFS, Always, TestRun (
       [["write_file"; "/file"; "content"; "0"];
        ["scrub_file"; "/file"]])],
@@ -2609,7 +2609,7 @@ The file is I<removed> after scrubbing.
 It is an interface to the L<scrub(1)> program.  See that
 manual page for more details.");
 
-  ("scrub_freespace", (RErr, [String "dir"]), 116, [],
+  ("scrub_freespace", (RErr, [Pathname "dir"]), 116, [],
    [], (* XXX needs testing *)
    "scrub (securely wipe) free space",
    "\
@@ -2776,7 +2776,7 @@ Old Linux kernels (2.4 and earlier) used a compressed ext2
 filesystem as initrd.  We I<only> support the newer initramfs
 format (compressed cpio files).");
 
-  ("mount_loop", (RErr, [String "file"; String "mountpoint"]), 129, [],
+  ("mount_loop", (RErr, [Pathname "file"; Pathname "mountpoint"]), 129, [],
    [],
    "mount a file using the loop device",
    "\
@@ -2882,7 +2882,7 @@ See also L<umask(2)>, C<guestfs_mknod>, C<guestfs_mkdir>.
 
 This call returns the previous umask.");
 
-  ("readdir", (RStructList ("entries", "dirent"), [String "dir"]), 138, [],
+  ("readdir", (RStructList ("entries", "dirent"), [Pathname "dir"]), 138, [],
    [],
    "read directories entries",
    "\
@@ -3278,7 +3278,7 @@ This command disables the libguestfs appliance swap
 device or partition named C<device>.
 See C<guestfs_swapon_device>.");
 
-  ("swapon_file", (RErr, [String "file"]), 172, [],
+  ("swapon_file", (RErr, [Pathname "file"]), 172, [],
    [InitBasicFS, Always, TestRun (
       [["fallocate"; "/swap"; "8388608"];
        ["mkswap_file"; "/swap"];
@@ -3289,7 +3289,7 @@ See C<guestfs_swapon_device>.");
 This command enables swap to a file.
 See C<guestfs_swapon_device> for other notes.");
 
-  ("swapoff_file", (RErr, [String "file"]), 173, [],
+  ("swapoff_file", (RErr, [Pathname "file"]), 173, [],
    [], (* XXX tested by swapon_file *)
    "disable swap on file",
    "\
-- 
1.6.2.5

>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)
   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;
 #endif
 }
-
-#endif /* HAVE_LIBSELINUX */
-- 
1.6.2.5

>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) {
-- 
1.6.2.5


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]