From: Matthew Daley <mattjd@gmail.com>
To: xen-devel@lists.xen.org
Cc: Matthew Daley <mattjd@gmail.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 1/2] xenstore: don't die on access-denied child nodes in 'xenstore ls'
Date: Sat, 6 Jul 2013 13:50:41 +1200 [thread overview]
Message-ID: <1373075442-3756-1-git-send-email-mattjd@gmail.com> (raw)
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
next reply other threads:[~2013-07-06 1:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-06 1:50 Matthew Daley [this message]
2013-07-06 1:50 ` [PATCH 2/2] xenstore: don't leak permissions info in 'xenstore ls -p' Matthew Daley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1373075442-3756-1-git-send-email-mattjd@gmail.com \
--to=mattjd@gmail.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).