Commit f5b81c7b authored by Thomas Schmitt's avatar Thomas Schmitt

Got rid of call system() in Xorriso_mount(), new option -session_string

parent ab691084
......@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH XORRISO 1 "Dec 05, 2008"
.TH XORRISO 1 "Dec 07, 2008"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
......@@ -59,6 +59,8 @@ Can perform multi-session tasks as emulation of mkisofs and cdrecord.
.br
Can restore files from ISO image to disk filesystem (see osirrox).
.br
Can issue commands to mount older sessions on Linux or FreeBSD.
.br
Can check media for damages and copy readable blocks to disk.
.br
Scans for optical drives, blanks re-useable optical media.
......@@ -1792,25 +1794,32 @@ to be the most recent real session then.
Some read-only drives and media show no usable session history at all.
Eventually option -rom_toc_scan might help.
.TP
\fB\-mount_cmd\fR drive entity id command_form
\fB\-mount_cmd\fR drive entity id path
Print to the result channel an appropriate command line for mounting the
ISO session which is depicted by drive, entity and id. The id can be a block
address with entity "sbsector", a track number with "track", a session number
with "session", a volume id search pattern with "volid", or any text with
"auto". See also option -load.
ISO session which is depicted by drive, entity and id. See option -mount
for direct execution of this command.
.br
drive can be "indev", "outdev" or the address of a not yet aquired drive.
Prefix "stdio:" for non MMC drives is not mandatory.
Prefix "stdio:" for non-MMC drives is not mandatory.
.br
The id can be a block address with entity "sbsector", a track number with
"track", a session number with "session", a volume id search pattern with
"volid", or a dummy text with "auto". See also option -load.
.br
path will be used as mount point and has already to exist as directory.
.br
command_form is either "linux:"path , or "freebsd:"path, or "shell:"command,
or a path.
The path will be used as moint point and has already to exist as directory.
A command line with suitable options is then generated.
If no recognizable prefix is given then xorriso guesses on which kind of
system it runs and uses the whole command_form as path.
xorriso determines on which kind of system it runs. Supported are Linux and
FreeBSD.
.TP
\fB\-session_string\fR drive entity id format
Print to the result channel a text which gets composed according to
format and the parameters of the addressed session.
.br
Formats "linux:"path or "freebsd:"path produce the output of -mount_cmd
for the given operating systems.
.br
If shell:command is given, then xorriso will substitute in the command text
the following parameter names:
In other texts xorriso will substitute the following parameter names.
An optional prefix "string:" will be removed.
.br
"%device%" will be substituted by the mountable device path of the drive
address.
......@@ -2197,13 +2206,12 @@ Read the content of a ISO data file and write it into a data file on disk
beginning at the byte_offset. Write at most byte_count bytes.
This is the inverse of option -cut_out.
.TP
\fB\-mount\fR drive entity id command_form
Produce the same line as -mount_cmd and then execute it as shell command
\fB\-mount\fR drive entity id path
Produce the same line as -mount_cmd and then execute it as external program run
after giving up the depicted drive.
This demands -osirrox to be enabled and normally will succeed only for the
superuser. For safety reasons it will refuse to execute the command line
if it stems from command_form shell:command or if setuid or setgid are in
effect. In these cases -mount will default to -mount_cmd and a SORRY event.
superuser. For safety reasons the mount program is only executed if it is
reachable as /bin/mount or /sbin/mount.
.TP
.B Command compatibility emulations:
.PP
......@@ -2853,7 +2861,9 @@ the newly written session (here for mount point /mnt):
-mount_cmd "indev" "auto" "auto" /mnt
.br
Options -mount_cmd and -mount are also able to produce the mount commands for
older sessions in the table-of-content.
older sessions in the table-of-content. E.g. as superuser:
.br
\fB$\fR osirrox -mount /dev/sr0 "volid" '*2008_12_05*' /mnt
.br
Sessions on multi-session media are separated by several MB of unused blocks.
So with small sessions the payload capacity can become substantially lower
......
This diff is collapsed.
......@@ -598,6 +598,12 @@ int Xorriso_make_mount_cmd(struct XorrisO *xorriso, char *cmd,
char *devadr, char result[SfileadrL], int flag);
/* @param flag bit0= use env_path to find the desired program
*/
int Xorriso_execv(struct XorrisO *xorriso, char *cmd, char *env_path,
int *status, int flag);
int Sfile_str(char target[SfileadrL], char *source, int flag);
double Sfile_microtime(int flag);
......
#define Xorriso_timestamP "2008.12.06.140828"
#define Xorriso_timestamP "2008.12.07.122439"
......@@ -8416,12 +8416,14 @@ int Xorriso_get_relax_text(struct XorrisO *xorriso, char mode[1024],
/**
@param flag bit0= print mount command to result channel rather than
performing it
bit1= do not allow prefixes with cmd
bit2= interpret unprefixed cmd as shell:
*/
int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
char *adr_value, char *cmd, int flag)
{
int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0;
int give_up= 0, mount_chardev= 0;
int give_up= 0, mount_chardev= 0, status;
char volid[33], *devadr, mount_command[SfileadrL], adr_data[163], *adr_pt;
char *dev_path, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL];
char sfe[5 * SfileadrL], *dpt, *sysname= "";
......@@ -8436,7 +8438,9 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
"on attempt to perform -mount \"indev\"", 0);
if(ret<=0)
goto ex;
devadr= xorriso->indev;
dev_path= devadr= xorriso->indev;
if(strncmp(dev_path, "stdio:", 6) == 0)
dev_path+= 6;
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
give_up= 3;
else
......@@ -8447,7 +8451,9 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
2);
if(ret<=0)
goto ex;
devadr= xorriso->outdev;
dev_path= devadr= xorriso->outdev;
if(strncmp(dev_path, "stdio:", 6) == 0)
dev_path+= 6;
if(xorriso->in_drive_handle == xorriso->out_drive_handle)
give_up= 3;
else
......@@ -8513,7 +8519,7 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
if(strstr(devadr, "stdio:") == devadr)
devadr+= 6;
ret= Xorriso_make_mount_cmd(xorriso, cmd, lba, track, session, volid, devadr,
mount_command, 0);
mount_command, flag & (2 | 4));
if(ret <= 0)
goto ex;
if(ret == 2)
......@@ -8539,23 +8545,24 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
} else {
sprintf(xorriso->info_text, "Mount command: %s\n", mount_command);
Xorriso_info(xorriso, 0);
if(geteuid() != getuid() || getgid() != getegid()) {
if(!is_safe) {
Xorriso_msgs_submit(xorriso, 0,
"-mount : Detected own setuid/gid identity. Will not perform mount command.",
"-mount : Will not perform mount command which stems from command template.",
0, "SORRY", 0);
sprintf(xorriso->result_line, "%s\n", mount_command);
Xorriso_result(xorriso,0);
} else if(!is_safe) {
#ifdef NIX
} else if(geteuid() != getuid() || getgid() != getegid()) {
Xorriso_msgs_submit(xorriso, 0,
"-mount : Will not perform mount command which stems from command template.",
"-mount : Detected own setuid/gid identity. Will not perform mount command.",
0, "SORRY", 0);
sprintf(xorriso->result_line, "%s\n", mount_command);
Xorriso_result(xorriso,0);
} else {
/* >>> find safer way to perform command */;
ret= system(mount_command);
if(WIFEXITED(ret) && WEXITSTATUS(ret) != 0) {
sprintf(xorriso->info_text,
"-mount : mount command failed with exit value %d",
......@@ -8563,13 +8570,30 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode,
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
sprintf(xorriso->info_text, "Mounted session %d of device %s",
#else
} else {
ret= Xorriso_execv(xorriso, mount_command, "/bin:/sbin", &status, 1);
if(WIFEXITED(status) && WEXITSTATUS(status) != 0) {
sprintf(xorriso->info_text,
"-mount : mount command failed with exit value %d",
(int) WEXITSTATUS(ret));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
#endif
sprintf(xorriso->info_text, "\nMounted session %d of device %s",
session, Text_shellsafe(dev_path, sfe, 0));
dpt= strchr(cmd, ':');
if(dpt == NULL)
dpt= cmd;
dpt= cmd ;
else
dpt++;
sprintf(xorriso->info_text + strlen(xorriso->info_text),
" as directory %s\n", Text_shellsafe(dpt + 1, sfe, 0));
" as directory %s\n", Text_shellsafe(dpt, sfe, 0));
Xorriso_info(xorriso, 0);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment