Made -outdev stdio:/dev/fd/1 safe for single session runs
This commit is contained in:
@ -2871,6 +2871,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->volset_change_pending= 0;
|
||||
m->outdev[0]= 0;
|
||||
m->out_drive_handle= NULL;
|
||||
m->dev_fd_1= -1;
|
||||
m->ban_stdio_write= 0;
|
||||
m->do_dummy= 0;
|
||||
m->do_close= 0;
|
||||
@ -2999,7 +3000,7 @@ int Xorriso_dialog_input(struct XorrisO *xorriso, char line[], int linesize,
|
||||
|
||||
#ifdef Xorriso_with_readlinE
|
||||
|
||||
if(xorriso->use_stdin) {
|
||||
if(xorriso->use_stdin || xorriso->dev_fd_1>=0) {
|
||||
if(flag&2)
|
||||
{ret= 1; goto ex;}
|
||||
if(Sfile_fgets(line,linesize-1,stdin)==NULL) {
|
||||
@ -6559,11 +6560,14 @@ int Xorriso_option_cut_out(struct XorrisO *xorriso, char *disk_path,
|
||||
|
||||
/* Options -dev , -indev, -outdev */
|
||||
/** @param flag bit0=use as indev , bit1= use as outdev */
|
||||
int Xorriso_option_dev(struct XorrisO *xorriso, char *adr, int flag)
|
||||
int Xorriso_option_dev(struct XorrisO *xorriso, char *in_adr, int flag)
|
||||
{
|
||||
int ret;
|
||||
char sfe[5*SfileadrL];
|
||||
char sfe[5*SfileadrL], *adr;
|
||||
|
||||
adr= in_adr;
|
||||
if(strcmp(in_adr, "-")==0)
|
||||
adr= "stdio:/dev/fd/1";
|
||||
if(xorriso->ban_stdio_write && strncmp(adr, "stdio:", 6)==0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Drive address banned by -ban_stdio_write : '%s'",
|
||||
@ -8773,6 +8777,17 @@ ex:;
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_protect_stdout(struct XorrisO *xorriso, int flag)
|
||||
{
|
||||
if(xorriso->dev_fd_1>=0)
|
||||
return(2);
|
||||
xorriso->dev_fd_1= dup(1);
|
||||
close(1);
|
||||
dup2(2,1);
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int flag)
|
||||
/*
|
||||
@ -8815,10 +8830,28 @@ int Xorriso_prescan_args(struct XorrisO *xorriso, int argc, char **argv,
|
||||
xorriso->did_something_useful= 1;
|
||||
return(0);
|
||||
}
|
||||
} else if(strcmp(cmd,"no_rc")==0) {
|
||||
} else if(i==1 && strcmp(cmd,"no_rc")==0) {
|
||||
ret= Xorriso_option_no_rc(xorriso, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
|
||||
} else if((strcmp(cmd,"dev")==0 || strcmp(cmd,"outdev")==0 ||
|
||||
strcmp(cmd,"indev")==0) &&
|
||||
(strcmp(arg1,"stdio:/dev/fd/1")==0 || strcmp(arg1,"-")==0) &&
|
||||
xorriso->dev_fd_1<0) {
|
||||
/* Detach fd 1 from externally perceived stdout and attach it to stderr.
|
||||
Keep dev_fd_1 connected to external stdout. dev_fd_1 is to be used when
|
||||
"stdio:/dev/fd/1" is interpreted as drive address.
|
||||
*/
|
||||
Xorriso_protect_stdout(xorriso, 0);
|
||||
sprintf(xorriso->info_text,
|
||||
"Encountered - or stdio:/dev/fd/1 as possible write target.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
sprintf(xorriso->info_text,
|
||||
"Redirecting any text message output to stderr.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
sprintf(xorriso->info_text, "Disabling use of libreadline.");
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
|
||||
}
|
||||
}
|
||||
return(1);
|
||||
|
Reference in New Issue
Block a user