xenstore: don't die on access-denied child nodes in 'xenstore ls'
PATCH 1/2 xenstore: don't die on access-denied child nodes in 'xenstore ls'
Signed-off-by Matthew Daley <[email protected]>
--- tools/xenstore/xenstore_client.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
tools/xenstore/xenstore_client.c +11 -4
@@ -134,8 +134,13 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_permsunsigned 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_permsputchar ('\n' ); +free (val); +do_ls (h, newpath, cur_depth+1 , show_perms); }free (e);
Signature · 1 line
1.7.10.4
PATCH 2/2 xenstore: don't leak permissions info in 'xenstore ls -p'
Signed-off-by Matthew Daley <[email protected]>
--- tools/xenstore/xenstore_client.c | 1 + 1 file changed, 1 insertion(+)
tools/xenstore/xenstore_client.c +1 -0
@@ -214,6 +214,7 @@ static void do_ls(struct xs_handle *h, char *path, int cur_depth, int show_permsfputs (buf, stdout); }putchar (')' ); +free (perms); } }
Signature · 1 line
1.7.10.4