- Timestamp:
- Jul 28, 2013, 7:37:35 PM (12 years ago)
- Location:
- branches/3.0/mondo
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/mondo/src/common/libmondo-devices.c
r3169 r3171 2820 2820 mr_asprintf(&g_getfacl,"getfacl"); 2821 2821 } 2822 log_it("Backup of extended attributes"); 2822 2823 } 2823 2824 // Interactive mode: -
branches/3.0/mondo/src/common/libmondo-filelist.c
r3141 r3171 470 470 } 471 471 log_msg(8, "Analyzing %s", file_to_analyze); 472 tmp = mr_stresc(file_to_analyze, " `$\\\"(){}[]'*?&|!#~", '\\');473 mr_asprintf(&s trtmp, syscall_sprintf, tmp);472 tmp = mr_stresc(file_to_analyze, "'", '\\', '\''); 473 mr_asprintf(&syscall, "%s '%s' 2>> /dev/null", syscall_sprintf, tmp); // " MONDO_LOGFILE); 474 474 paranoid_free(tmp); 475 mr_asprintf(&syscall, "%s 2>> /dev/null", strtmp); // " MONDO_LOGFILE);476 paranoid_free(strtmp);477 475 log_msg(20,"calling %s\n",syscall); 478 476 call_exe_and_pipe_output_to_fd(syscall, pout); … … 496 494 mr_free(command); 497 495 498 retval = 499 gen_aux_list(filelist, "getfacl --all-effective -P \"%s\"", 500 facl_fname); 496 retval = gen_aux_list(filelist, "getfacl --all-effective -P ", facl_fname); 501 497 } 502 498 return (retval); … … 513 509 run_program_and_log_output(command, 8); 514 510 mr_free(command); 515 retval = 516 gen_aux_list(filelist, "getfattr --en=hex -m - -h -d \"%s\"", 517 fattr_fname); 511 retval = gen_aux_list(filelist, "getfattr --en=hex -m - -h -d ", fattr_fname); 518 512 } 519 513 return (retval); … … 1350 1344 1351 1345 /* dir is needed when we pass it to the shell */ 1352 dir = mr_stresc(dir1, " `$\\\"(){}'[]&*?|!#~", '\\');1346 dir = mr_stresc(dir1, "'", '\\', '\''); 1353 1347 p = strrchr(dir1, '/'); 1354 1348 if (p) { -
branches/3.0/mondo/src/include/mr_str.h
r2208 r3171 16 16 17 17 extern char *mr_strtok(char *instr, const char *delims, int *lastpos); 18 extern char *mr_stresc(char *instr, char *toesc, const char escchr );18 extern char *mr_stresc(char *instr, char *toesc, const char escchr, const char specialchr); 19 19 extern inline char *mr_date(void); 20 20 extern void mr_strip_spaces(char *in_out); -
branches/3.0/mondo/src/lib/mr_str.c
r2972 r3171 12 12 13 13 #include "mr_mem.h" 14 15 // to get bool type 16 #define _MY_STUFF_H_ 17 #include "my-stuff.h" 14 18 15 19 /** … … 66 70 * @note this function allocates memory that needs to be freed by caller 67 71 **/ 68 char *mr_stresc(char *instr, char *toesc, const char escchr ) {72 char *mr_stresc(char *instr, char *toesc, const char escchr, const char specialchr) { 69 73 char *inptr = NULL; 70 74 char *retstr = NULL; … … 72 76 char *escptr = NULL; 73 77 int cnt = 0; 78 bool found = FALSE; 74 79 75 80 inptr = instr; 76 77 81 // Count how many characters need escaping. 78 82 while (*inptr != '\0') { … … 82 86 // Found it, skip the rest. 83 87 cnt++; 88 // if specialchar (' or ") then replace it with '\'' or "\"" so adds 2 chars 89 if (*inptr == specialchr) { 90 cnt += 2; 91 } 84 92 break; 85 93 } … … 88 96 inptr++; 89 97 } 98 90 99 inptr = instr; 91 92 100 retstr = (char *) mr_malloc(strlen(inptr) + cnt + 1); 93 101 retptr = retstr; … … 99 107 if (*inptr == *escptr) { 100 108 // Found it, skip the rest. 101 *retptr = escchr; 102 retptr++; 109 // if specialchar (' or ") then replace it with '\'' or "\"" so adds 2 chars 110 if (*inptr == specialchr) { 111 *retptr = specialchr; 112 retptr++; 113 *retptr = escchr; 114 retptr++; 115 found = TRUE; 116 } else { 117 *retptr = escchr; 118 retptr++; 119 } 103 120 break; 104 121 } … … 108 125 retptr++; 109 126 inptr++; 127 if (found) { 128 // finish to put the remaining specialchr 129 *retptr = specialchr; 130 retptr++; 131 found = FALSE; 132 } 110 133 } 111 134 *retptr = '\0'; -
branches/3.0/mondo/test/test-mr_stresc.c
r3170 r3171 8 8 #include <stdlib.h> 9 9 #include "mr_str.h" 10 #include "mr_mem.h" 10 11 #include "my-stuff.h" 11 12 … … 39 40 for (i = 1; strl[i] != NULL ; i++) { 40 41 printf("Test %2d Original chain is %s\n",i,strl[i]); 41 p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\'); 42 printf("Test %2d Transformed chain is %s\n",i,p); 42 p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\', '"'); 43 printf("Test %2d Transformed chain (with \") is %s\n",i,p); 44 mr_free(p); 45 p = mr_stresc(strl[i], "`$\\\"(){}'[]&*?|!#~", '\\', '\''); 46 printf("Test %2d Transformed chain (with ') is %s\n",i,p); 47 mr_free(p); 43 48 } 44 49 exit(0);
Note:
See TracChangeset
for help on using the changeset viewer.