[Pkg-libvirt-commits] [libguestfs] 68/165: daemon: add sysroot_realpath

Hilko Bengen bengen at moszumanska.debian.org
Sat Aug 30 08:24:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit d7aec9c0d31c14b97c0bb93595d492fdd3741143
Author: Pino Toscano <ptoscano at redhat.com>
Date:   Wed May 21 15:01:50 2014 +0200

    daemon: add sysroot_realpath
    
    Similar to sysroot_path, but first resolves (using realpath) the given
    path within sysroot.
---
 daemon/daemon.h   |  1 +
 daemon/guestfsd.c | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/daemon/daemon.h b/daemon/daemon.h
index 6535658..94537b7 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -51,6 +51,7 @@ extern const char *sysroot;
 extern size_t sysroot_len;
 
 extern char *sysroot_path (const char *path);
+extern char *sysroot_realpath (const char *path);
 
 extern int is_root_device (const char *device);
 
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 6519ea6..622bda1 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -455,6 +455,27 @@ sysroot_path (const char *path)
   return r;
 }
 
+/* Resolve path within sysroot, calling sysroot_path on the resolved path.
+ *
+ * Caller must check for NULL and call reply_with_perror ("malloc/realpath")
+ * if it is.  Caller must also free the string.
+ *
+ * See also the custom %R printf formatter which does shell quoting too.
+ */
+char *
+sysroot_realpath (const char *path)
+{
+  CLEANUP_FREE char *rp = NULL;
+
+  CHROOT_IN;
+  rp = realpath (path, NULL);
+  CHROOT_OUT;
+  if (rp == NULL)
+    return NULL;
+
+  return sysroot_path (rp);
+}
+
 int
 xwrite (int sock, const void *v_buf, size_t len)
 {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list