Made -getfacl file name escaping more similar to shell command behavior

This commit is contained in:
2009-01-28 19:01:47 +00:00
parent 0e70724dc2
commit 78a3402bf3
4 changed files with 71 additions and 18 deletions

View File

@ -8815,9 +8815,9 @@ ok:;
int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
char **acl_text, int flag)
{
int ret, d_ret, path_offset= 0, result_len= 0, pass;
int ret, d_ret, path_offset= 0, result_len= 0, pass, bsl_mem;
IsoNode *node;
char *text= NULL, *d_text= NULL, *cpt, *npt;
char *text= NULL, *d_text= NULL, *cpt, *npt, *bsl_path= NULL;
uid_t uid;
gid_t gid;
struct passwd *pwd;
@ -8875,10 +8875,19 @@ int Xorriso_getfacl(struct XorrisO *xorriso, void *in_node, char *path,
if(!(flag & 1)) {
if(path[0] == '/' && !(flag & 2))
path_offset= 1;
strcpy(xorriso->result_line, "# file: ");
Text_shellsafe(path + path_offset, xorriso->result_line, 1);
strcat(xorriso->result_line, "\n");
/* backslash escaped path rather than shellsafe path */
ret= Sfile_bsl_encoder(&bsl_path, path + path_offset, 8);
if(ret <= 0)
{ret= -1; goto ex;}
sprintf(xorriso->result_line, "# file: %s\n", bsl_path);
free(bsl_path);
bsl_path= NULL;
/* temporarily disable -backslash_codes with result output */
bsl_mem= xorriso->bsl_interpretation;
xorriso->bsl_interpretation= 0;
Xorriso_result(xorriso, 0);
xorriso->bsl_interpretation= bsl_mem;
uid= iso_node_get_uid(node);
pwd= getpwuid(uid);
@ -8949,6 +8958,8 @@ ex:;
free(d_text);
if(text != NULL)
free(text);
if(bsl_path != NULL)
free(bsl_path);
return(ret);
}