xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] xenstore: don't die on access-denied child nodes in 'xenstore ls'
@ 2013-07-06  1:50 Matthew Daley
  2013-07-06  1:50 ` [PATCH 2/2] xenstore: don't leak permissions info in 'xenstore ls -p' Matthew Daley
  0 siblings, 1 reply; 2+ messages in thread
From: Matthew Daley @ 2013-07-06  1:50 UTC (permalink / raw)
  To: xen-devel; +Cc: Matthew Daley, Ian Jackson, Ian Campbell, Stefano Stabellini


Signed-off-by: Matthew Daley <mattjd@gmail.com>
---
 tools/xenstore/xenstore_client.c |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c
index 3ac214b..996ee64 100644
--- a/tools/xenstore/xenstore_client.c
+++ b/tools/xenstore/xenstore_client.c
@@ -134,8 +134,13 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms
     unsigned int num, len;
 
     e = xs_directory(h, XBT_NULL, path, &num);
-    if (e == NULL)
+    if (e == NULL) {
+        if(errno == EACCES && cur_depth)
+            /* Don't stop listing just because access was denied to a descendant */
+            return;
+
         err(1, "xs_directory (%s)", path);
+    }
 
     for (i = 0; i<num; i++) {
         char buf[MAX_STRLEN(unsigned int)+1];
@@ -172,7 +177,7 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms
 
         /* Print value */
         if (val == NULL) {
-            printf(":\n");
+            putchar(':');
         }
         else {
             if (max_width < (linewid + len + TAG_LEN)) {
@@ -192,12 +197,12 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms
                 }
             }
         }
-        free(val);
 
         if (show_perms) {
             perms = xs_get_permissions(h, XBT_NULL, newpath, &nperms);
             if (perms == NULL) {
-                warn("\ncould not access permissions for %s", e[i]);
+                if (val != NULL)
+                    warn("\ncould not access permissions for %s", e[i]);
             }
             else {
                 int i;
@@ -214,6 +219,8 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms
 
         putchar('\n');
             
+        free(val);
+
         do_ls(h, newpath, cur_depth+1, show_perms); 
     }
     free(e);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] xenstore: don't leak permissions info in 'xenstore ls -p'
  2013-07-06  1:50 [PATCH 1/2] xenstore: don't die on access-denied child nodes in 'xenstore ls' Matthew Daley
@ 2013-07-06  1:50 ` Matthew Daley
  0 siblings, 0 replies; 2+ messages in thread
From: Matthew Daley @ 2013-07-06  1:50 UTC (permalink / raw)
  To: xen-devel; +Cc: Matthew Daley, Ian Jackson, Ian Campbell, Stefano Stabellini


Signed-off-by: Matthew Daley <mattjd@gmail.com>
---
 tools/xenstore/xenstore_client.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c
index 996ee64..f42d06d 100644
--- a/tools/xenstore/xenstore_client.c
+++ b/tools/xenstore/xenstore_client.c
@@ -214,6 +214,7 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_perms
                     fputs(buf, stdout);
                 }
                 putchar(')');
+                free(perms);
             }
         }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-07-06  1:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-06  1:50 [PATCH 1/2] xenstore: don't die on access-denied child nodes in 'xenstore ls' Matthew Daley
2013-07-06  1:50 ` [PATCH 2/2] xenstore: don't leak permissions info in 'xenstore ls -p' Matthew Daley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).