New -osirrox option auto_chmod_on
This commit is contained in:
@ -2835,6 +2835,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->allow_graft_points= 0;
|
||||
m->allow_restore= 0;
|
||||
m->do_concat_split= 1;
|
||||
m->do_auto_chmod= 0;
|
||||
m->dialog= 0;
|
||||
m->search_mode= 0;
|
||||
m->structured_search= 1;
|
||||
@ -3942,11 +3943,14 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
}
|
||||
|
||||
is_default= (xorriso->allow_restore==0 && xorriso->do_concat_split==1);
|
||||
sprintf(line,"-osirrox %s:%s\n",
|
||||
is_default= (xorriso->allow_restore==0 && xorriso->do_concat_split==1 &&
|
||||
xorriso->do_auto_chmod==0);
|
||||
sprintf(line,"-osirrox %s:%s:%s\n",
|
||||
xorriso->allow_restore ? xorriso->allow_restore==2 ?
|
||||
"device_files" : "on" : "off",
|
||||
xorriso->do_concat_split ? "concat_split_on" : "concat_split_off");
|
||||
xorriso->do_concat_split ? "concat_split_on" : "concat_split_off",
|
||||
xorriso->do_auto_chmod ? "auto_chmod_on" : "auto_chmod_off"
|
||||
);
|
||||
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
@ -7897,6 +7901,54 @@ int Xorriso_make_tmp_path(struct XorrisO *xorriso, char *orig_path,
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_auto_chmod(struct XorrisO *xorriso, char *disk_path, int flag)
|
||||
{
|
||||
int ret, is_link= 0;
|
||||
char *path_pt, sfe[5*SfileadrL], link_target[SfileadrL];
|
||||
mode_t mode, desired= S_IRUSR | S_IWUSR | S_IXUSR;
|
||||
struct stat stbuf;
|
||||
|
||||
if(!xorriso->do_auto_chmod)
|
||||
return(0);
|
||||
|
||||
path_pt= disk_path;
|
||||
ret= lstat(path_pt, &stbuf);
|
||||
if(ret==-1)
|
||||
return(0);
|
||||
if(S_ISLNK(stbuf.st_mode)) {
|
||||
is_link= 1;
|
||||
ret= stat(path_pt, &stbuf);
|
||||
if(ret==-1)
|
||||
return(0);
|
||||
}
|
||||
if(!S_ISDIR(stbuf.st_mode))
|
||||
return(0);
|
||||
if(is_link) {
|
||||
ret= Xorriso_resolve_link(xorriso, path_pt, link_target, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
path_pt= link_target;
|
||||
}
|
||||
if(stbuf.st_uid!=geteuid())
|
||||
return(0);
|
||||
if((stbuf.st_mode & desired) == desired)
|
||||
return(0);
|
||||
|
||||
mode= (stbuf.st_mode | desired) & 07777;
|
||||
ret= chmod(path_pt, mode);
|
||||
if(ret==-1) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot change access permissions of disk directory: chmod %o %s",
|
||||
mode & 07777, Text_shellsafe(path_pt, sfe, 0));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0);
|
||||
}
|
||||
ret= Permstack_push(&(xorriso->perm_stack), path_pt, &stbuf, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/* ---------------------------- Options API ------------------------ */
|
||||
|
||||
@ -10884,6 +10936,10 @@ int Xorriso_option_osirrox(struct XorrisO *xorriso, char *mode, int flag)
|
||||
xorriso->do_concat_split= 1;
|
||||
else if(strncmp(cpt, "concat_split_off", l)==0)
|
||||
xorriso->do_concat_split= 0;
|
||||
else if(strncmp(cpt, "auto_chmod_on", l)==0)
|
||||
xorriso->do_auto_chmod= 1;
|
||||
else if(strncmp(cpt, "auto_chmod_off", l)==0)
|
||||
xorriso->do_auto_chmod= 0;
|
||||
else {
|
||||
unknown_mode:;
|
||||
sprintf(xorriso->info_text, "-osirrox: unknown mode '%s'", cpt);
|
||||
@ -10892,7 +10948,7 @@ unknown_mode:;
|
||||
}
|
||||
}
|
||||
sprintf(xorriso->info_text,
|
||||
"%s copying of file objects from ISO image to disk filesystem\n",
|
||||
"Copying of file objects from ISO image to disk filesystem is: %s\n",
|
||||
xorriso->allow_restore ? "Enabled" : "Disabled");
|
||||
Xorriso_info(xorriso, 0);
|
||||
return(1);
|
||||
|
Reference in New Issue
Block a user