diff --git a/test/xorriso.c b/test/xorriso.c index 7b4559e9..acc22523 100644 --- a/test/xorriso.c +++ b/test/xorriso.c @@ -1306,6 +1306,8 @@ char *Text_shellsafe(char *in_text, char *out_text, int flag) out_text[w++]= '\''; for(i=0;i4*SfileadrL) + goto overflow; /* escape hard quote within the text */ out_text[w++]= '\''; out_text[w++]= '"'; @@ -1313,6 +1315,11 @@ char *Text_shellsafe(char *in_text, char *out_text, int flag) out_text[w++]= '"'; out_text[w++]= '\''; } else { + if(w+3>4*SfileadrL) { +overflow:; + strncpy(out_text, "'xorriso: TEXT MUCH TOO LONG ... ",33); + break; + } out_text[w++]= in_text[i]; } } @@ -3415,14 +3422,14 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag) /* Option -chgrp alias -chgrpi */ -int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, char *path, +int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, int argc, char **argv, int *idx, int flag) { int i, end_idx; end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); - fprintf(stderr, ">>> LIBISOFS : would perform -chgrpi %s %s ", gid, path); + fprintf(stderr, ">>> LIBISOFS : would perform -chgrpi %s ", gid); for(i= *idx; i>> LIBISOFS : would perform -chmodi %s %s ", mode, path); - for(i= *idx; iinfo_text, + "-chmodi: Unrecognizable or faulty permission mode %s\n", + Text_shellsafe(mode, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + } + + ret= 1; + for(i= *idx; i>> LIBISOFS : would perform -chowni %s %s ", uid, path); + fprintf(stderr, ">>> LIBISOFS : would perform -chowni %s", uid); for(i= *idx; iinfo_text, "Not found in ISO image: %s", + Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + return(1); +} + + /* @param flag bit0= recursion is active */ int Xorriso_add_tree(struct XorrisO *xorriso, struct iso_tree_node_dir *dir, char *img_dir_path, char *disk_dir_path, int flag) @@ -1740,6 +1767,40 @@ ex:; } +int Xorriso__mode_to_perms(mode_t st_mode, char perms[10], int flag) +{ + strcpy(perms,"---------"); + if(st_mode&S_IRUSR) perms[0]= 'r'; + if(st_mode&S_IWUSR) perms[1]= 'w'; + if(st_mode&S_IXUSR) perms[2]= 'x'; + if(st_mode&S_ISUID) { + if(st_mode&S_IXUSR) + perms[2]= 's'; + else + perms[2]= 'S'; + } + if(st_mode&S_IRGRP) perms[3]= 'r'; + if(st_mode&S_IWGRP) perms[4]= 'w'; + if(st_mode&S_IXGRP) perms[5]= 'x'; + if(st_mode&S_ISGID) { + if(st_mode&S_IXGRP) + perms[5]= 's'; + else + perms[5]= 'S'; + } + if(st_mode&S_IROTH) perms[6]= 'r'; + if(st_mode&S_IWOTH) perms[7]= 'w'; + if(st_mode&S_IXOTH) perms[8]= 'x'; + if(st_mode&S_ISVTX) { + if(st_mode&S_IXOTH) + perms[8]= 't'; + else + perms[8]= 'T'; + } + return(1); +} + + /* @param flag bit0= long format bit1= do not print count of nodes bit2= du format @@ -1824,16 +1885,7 @@ much_too_long:; strcat(rpt, "?"); st_mode= iso_tree_node_get_permissions(node); - strcpy(perms,"---------"); - if(st_mode&S_IRUSR) perms[0]= 'r'; - if(st_mode&S_IWUSR) perms[1]= 'w'; - if(st_mode&S_IXUSR) perms[2]= 'x'; - if(st_mode&S_IRGRP) perms[3]= 'r'; - if(st_mode&S_IWGRP) perms[4]= 'w'; - if(st_mode&S_IXGRP) perms[5]= 'x'; - if(st_mode&S_IROTH) perms[6]= 'r'; - if(st_mode&S_IWOTH) perms[7]= 'w'; - if(st_mode&S_IXOTH) perms[8]= 'x'; + Xorriso__mode_to_perms(st_mode, perms, 0); strcat(rpt, perms); /* >>> With directories this should be : number of subdirs + 2 */ @@ -1976,16 +2028,7 @@ wdi_is_not_a_dir:; strcat(rpt, "?"); st_mode= iso_tree_node_get_permissions(node); - strcpy(perms,"---------"); - if(st_mode&S_IRUSR) perms[0]= 'r'; - if(st_mode&S_IWUSR) perms[1]= 'w'; - if(st_mode&S_IXUSR) perms[2]= 'x'; - if(st_mode&S_IRGRP) perms[3]= 'r'; - if(st_mode&S_IWGRP) perms[4]= 'w'; - if(st_mode&S_IXGRP) perms[5]= 'x'; - if(st_mode&S_IROTH) perms[6]= 'r'; - if(st_mode&S_IWOTH) perms[7]= 'w'; - if(st_mode&S_IXOTH) perms[8]= 'x'; + Xorriso__mode_to_perms(st_mode, perms, 0); strcat(rpt, perms); /* >>> With directories this should be : number of subdirs + 2 */ @@ -2422,3 +2465,24 @@ ex:; } +int Xorriso_set_st_mode(struct XorrisO *xorriso, char *in_path, + mode_t mode_and, mode_t mode_or, int flag) +{ + mode_t mode= 0; + int ret; + struct iso_tree_node *node; + char sfe[4*SfileadrL], path[SfileadrL]; + + ret= Xorriso_get_node_by_path(xorriso, in_path, path, &node, 0); + if(ret<=0) + return(ret); + mode= iso_tree_node_get_permissions(node); + mode= (mode & mode_and) | mode_or; + iso_tree_node_set_permissions(node, mode); + sprintf(xorriso->info_text,"Permissions now: %-5.5o %s", + mode, Text_shellsafe(path, sfe, 0)); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0); + xorriso->volset_change_pending= 1; + return(1); +} + diff --git a/test/xorrisoburn.h b/test/xorrisoburn.h index 26b05f35..b7929215 100644 --- a/test/xorrisoburn.h +++ b/test/xorrisoburn.h @@ -95,5 +95,9 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso, int num_patterns, char **patterns, int *filec, char ***filev, off_t *mem, int flag); +int Xorriso_set_st_mode(struct XorrisO *xorriso, char *path, + mode_t mode_and, mode_t mode_or, int flag); + + #endif /* Xorrisoburn_includeD */