diff --git a/libisoburn/trunk/test/xorriso.c b/libisoburn/trunk/test/xorriso.c index acc22523..fb0d1bb4 100644 --- a/libisoburn/trunk/test/xorriso.c +++ b/libisoburn/trunk/test/xorriso.c @@ -3132,6 +3132,54 @@ int Xorriso_eval_problem_status(struct XorrisO *xorriso, int ret, int flag) } +int Xorriso_convert_uidstring(struct XorrisO *xorriso, char *uid_string, + uid_t *uid, int flag) +{ + double num; + char text[80]; + struct passwd *pwd; + + sscanf(uid_string, "%lf", &num); + sprintf(text,"%.f",num); + if(strcmp(text,uid_string)==0) { + *uid= num; + return(1); + } + pwd= getpwnam(uid_string); + if(pwd==NULL) { + sprintf(xorriso->info_text, "-uid: Not a known user: '%s'", uid_string); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *uid= pwd->pw_uid; + return(1); +} + + +int Xorriso_convert_gidstring(struct XorrisO *xorriso, char *gid_string, + gid_t *gid, int flag) +{ + double num; + char text[80]; + struct group *grp; + + sscanf(gid_string, "%lf", &num); + sprintf(text,"%.f",num); + if(strcmp(text,gid_string)==0) { + *gid= num; + return(1); + } + grp= getgrnam(gid_string); + if(grp==NULL) { + sprintf(xorriso->info_text, "-gid: Not a known group: '%s'", gid_string); + Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); + return(0); + } + *gid= grp->gr_gid; + return(1); +} + + /* ---------------------------- Options API ------------------------ */ @@ -3425,17 +3473,28 @@ int Xorriso_option_cdx(struct XorrisO *xorriso, char *disk_path, int flag) int Xorriso_option_chgrpi(struct XorrisO *xorriso, char *gid, int argc, char **argv, int *idx, int flag) { - int i, end_idx; + int i, end_idx, ret, was_failure= 0; + gid_t gid_number; end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); - fprintf(stderr, ">>> LIBISOFS : would perform -chgrpi %s ", gid); - for(i= *idx; iinfo_text, 0, "SORRY", 0); + ret= 0; goto ex; } ret= 1; @@ -3532,6 +3592,7 @@ unrecognizable:; if(ret<=0) break; } +ex:; (*idx)= end_idx; return(ret); } @@ -3541,17 +3602,28 @@ unrecognizable:; int Xorriso_option_chowni(struct XorrisO *xorriso, char *uid, int argc, char **argv, int *idx, int flag) { - int i, end_idx; + int i, end_idx, ret, was_failure= 0; + uid_t uid_number; end_idx= Xorriso_end_idx(xorriso, argc, argv, *idx, 0); - fprintf(stderr, ">>> LIBISOFS : would perform -chowni %s", uid); - for(i= *idx; ido_global_gid= 0; if(gid[0]==0 || strcmp(gid,"-")==0) - xorriso->do_global_gid= 0; - - sscanf(gid, "%lf", &num); - sprintf(text,"%.f",num); - if(strcmp(text,gid)==0) { - xorriso->global_gid= num; - xorriso->do_global_gid= 1; return(1); - } - grp= getgrnam(gid); - if(grp==NULL) { - sprintf(xorriso->info_text, "-gid: Not a known group: '%s'", gid); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - xorriso->global_gid= grp->gr_gid; - xorriso->do_global_gid= 1; - return(1); + ret= Xorriso_convert_gidstring(xorriso, gid, &(xorriso->global_gid), 0); + if(ret>0) + xorriso->do_global_gid= 1; + return(ret); } @@ -4902,30 +4960,15 @@ int Xorriso_option_toc(struct XorrisO *xorriso, int flag) /* Option -uid */ int Xorriso_option_uid(struct XorrisO *xorriso, char *uid, int flag) { - double num; - char text[80]; - struct passwd *pwd; + int ret; + xorriso->do_global_uid= 0; if(uid[0]==0 || strcmp(uid,"-")==0) - xorriso->do_global_uid= 0; - - sscanf(uid, "%lf", &num); - sprintf(text,"%.f",num); - if(strcmp(text,uid)==0) { - xorriso->global_uid= num; - xorriso->do_global_uid= 1; return(1); - } - - pwd= getpwnam(uid); - if(pwd==NULL) { - sprintf(xorriso->info_text, "-gid: Not a known user: '%s'", uid); - Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); - return(0); - } - xorriso->global_uid= pwd->pw_uid; - xorriso->do_global_uid= 1; - return(1); + ret= Xorriso_convert_uidstring(xorriso, uid, &(xorriso->global_uid), 0); + if(ret>0) + xorriso->do_global_uid= 1; + return(ret); } diff --git a/libisoburn/trunk/test/xorriso_timestamp.h b/libisoburn/trunk/test/xorriso_timestamp.h index ae1ef80a..a236ba0f 100644 --- a/libisoburn/trunk/test/xorriso_timestamp.h +++ b/libisoburn/trunk/test/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2007.11.07.191915" +#define Xorriso_timestamP "2007.11.07.225624" diff --git a/libisoburn/trunk/test/xorrisoburn.c b/libisoburn/trunk/test/xorrisoburn.c index 60facc48..1e1419c1 100644 --- a/libisoburn/trunk/test/xorrisoburn.c +++ b/libisoburn/trunk/test/xorrisoburn.c @@ -2486,3 +2486,34 @@ int Xorriso_set_st_mode(struct XorrisO *xorriso, char *in_path, return(1); } + +int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, + int flag) +{ + int ret; + struct iso_tree_node *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + iso_tree_node_set_uid(node, uid); + xorriso->volset_change_pending= 1; + return(1); +} + + +int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, + int flag) +{ + int ret; + struct iso_tree_node *node; + + ret= Xorriso_get_node_by_path(xorriso, in_path, NULL, &node, 0); + if(ret<=0) + return(ret); + iso_tree_node_set_gid(node, gid); + xorriso->volset_change_pending= 1; + return(1); +} + + diff --git a/libisoburn/trunk/test/xorrisoburn.h b/libisoburn/trunk/test/xorrisoburn.h index b7929215..530098a3 100644 --- a/libisoburn/trunk/test/xorrisoburn.h +++ b/libisoburn/trunk/test/xorrisoburn.h @@ -98,6 +98,12 @@ int Xorriso_expand_pattern(struct XorrisO *xorriso, int Xorriso_set_st_mode(struct XorrisO *xorriso, char *path, mode_t mode_and, mode_t mode_or, int flag); +int Xorriso_set_uid(struct XorrisO *xorriso, char *in_path, uid_t uid, + int flag); + +int Xorriso_set_gid(struct XorrisO *xorriso, char *in_path, gid_t gid, + int flag); + #endif /* Xorrisoburn_includeD */