New option -drive_class for safety management of pseudo-drive access
This commit is contained in:
@ -526,7 +526,7 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
enum burn_disc_status state;
|
||||
IsoImage *volset = NULL;
|
||||
struct isoburn_read_opts *ropts= NULL;
|
||||
char adr_data[SfileadrL], *libburn_adr, *boot_fate, *sev;
|
||||
char libburn_adr[SfileadrL], *boot_fate, *sev;
|
||||
|
||||
static int no_rr_or_joliet= 0;
|
||||
|
||||
@ -540,16 +540,17 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag)
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
|
||||
libburn_adr= adr;
|
||||
if(strcmp(adr,"stdio:/dev/fd/1")==0) {
|
||||
ret= Xorriso_auto_driveadr(xorriso, adr, libburn_adr, 0);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
if(strcmp(libburn_adr,"stdio:/dev/fd/1")==0) {
|
||||
if(xorriso->dev_fd_1<0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-*dev \"stdio:/dev/fd/1\" was not a start argument. Cannot use it now.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
{ret= 0; goto ex;}
|
||||
} else {
|
||||
sprintf(adr_data, "stdio:/dev/fd/%d", xorriso->dev_fd_1);
|
||||
libburn_adr= adr_data;
|
||||
sprintf(libburn_adr, "stdio:/dev/fd/%d", xorriso->dev_fd_1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8624,3 +8625,99 @@ ex:;
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result,
|
||||
int flag)
|
||||
{
|
||||
int ret, is_known_mmc= 0;
|
||||
char *path_pt, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL];
|
||||
char *abs_pt, abs_adr[SfileadrL];
|
||||
|
||||
path_pt= adr;
|
||||
if(strncmp(adr, "stdio:", 6) == 0)
|
||||
path_pt= adr + 6;
|
||||
else if(strncmp(adr, "mmc:", 4) == 0)
|
||||
path_pt= adr + 4;
|
||||
|
||||
|
||||
/* <<< replace by Xorriso_normalize_img_path() ? */;
|
||||
|
||||
if(path_pt[0] != '/') {
|
||||
abs_pt= getcwd(abs_adr, SfileadrL - 1);
|
||||
if(abs_pt == NULL) {
|
||||
Xorriso_msgs_submit(xorriso, 0,
|
||||
"Relative drive path given. Cannot determine working directory.",
|
||||
errno, "FAILURE", 0);
|
||||
return(-1);
|
||||
}
|
||||
ret= Sfile_add_to_path(abs_adr, path_pt, 0);
|
||||
if(ret <= 0)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_whitelist, path_pt, 0);
|
||||
if(ret > 0)
|
||||
goto ok;
|
||||
ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_blacklist, path_pt, 0);
|
||||
if(ret < 0)
|
||||
return(ret);
|
||||
if(ret) {
|
||||
strcpy(xorriso->info_text, "Drive address ");
|
||||
Text_shellsafe(adr, xorriso->info_text, 1);
|
||||
strcat(xorriso->info_text,
|
||||
" rejected because: -drive_class 'banned' ");
|
||||
Text_shellsafe(Xorriso_get_pattern(xorriso, xorriso->drive_blacklist,
|
||||
ret - 1, 0),
|
||||
xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
/* if in greylist and not MMC and not stdio prefix: reject */
|
||||
is_known_mmc= burn_drive_convert_fs_adr(path_pt, libburn_adr);
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
if(is_known_mmc < 0)
|
||||
return(ret);
|
||||
if(adr == path_pt && !is_known_mmc) { /* no prefix, no MMC */
|
||||
ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_greylist, path_pt,0);
|
||||
if(ret < 0)
|
||||
return(ret);
|
||||
if(ret) {
|
||||
strcpy(xorriso->info_text, "Drive address ");
|
||||
Text_shellsafe(adr, xorriso->info_text, 1);
|
||||
strcat(xorriso->info_text,
|
||||
" rejected because: not MMC and -drive_class 'risky' ");
|
||||
Text_shellsafe(Xorriso_get_pattern(xorriso,xorriso->drive_greylist,
|
||||
ret - 1, 0),
|
||||
xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
Xorriso_msgs_submit(xorriso, 0,
|
||||
"If the address is a legitimate target, prepend \"stdio:\"",
|
||||
0, "HINT", 0);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
ok:;
|
||||
if(strncmp(adr, "mmc:", 4) == 0) {
|
||||
if(Sfile_str(result, path_pt, 0) <= 0)
|
||||
return(0);
|
||||
} else if(adr == path_pt && !is_known_mmc) {
|
||||
Sfile_str(result, "stdio:", 0);
|
||||
if(Sfile_str(result, adr, 1) <= 0)
|
||||
return(0);
|
||||
} else {
|
||||
if(Sfile_str(result, adr, 0) <= 0)
|
||||
return(0);
|
||||
}
|
||||
if(strncmp(result, "stdio:", 6)==0) {
|
||||
if(xorriso->ban_stdio_write) {
|
||||
strcpy(xorriso->info_text, "Drive address banned by -ban_stdio_write : ");
|
||||
Text_shellsafe(result, xorriso->info_text, 1);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user