dosbox

CommentBasically dosbox allows to mount the local file system, so that it can be altered using DOS commands. Note that the DOS filename convention (8.3) is used.

File write

This executable can write data to local files.
  1. CommentNote that echo terminates the string with a DOS-style line terminator (\r\n), if that’s a problem and your scenario allows it, you can create the file outside dosbox, then use copy to do the actual write.
    This function can be performed by any unprivileged user.
    dosbox -c 'mount c /' -c "echo DATA >c:\path\to\output" -c exit
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    dosbox -c 'mount c /' -c "echo DATA >c:\path\to\output" -c exit
    This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the effective privileges are not dropped.
    dosbox -c 'mount c /' -c "echo DATA >c:\path\to\output" -c exit

File read

This executable can read data from local files.
  1. CommentThe file content will be displayed in the DOSBox graphical window.
    This function can be performed by any unprivileged user.
    dosbox -c 'mount c /' -c 'type c:\path\to\input'
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    dosbox -c 'mount c /' -c 'type c:\path\to\input'
    This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the effective privileges are not dropped.
    dosbox -c 'mount c /' -c 'type c:\path\to\input'
  2. CommentThe file is copied to a readable location.
    This function can be performed by any unprivileged user.
    dosbox -c 'mount c /' -c 'copy c:\path\to\input c:\path\to\output' -c exit
    cat /path/to/OUTPUT
    This function is performed by the privileged user if executed via sudo because the acquired privileges are not dropped.
    RemarksIf there are environment variables involved, they must be passed via sudo VAR=value ... or exported then sudo -E ....
    dosbox -c 'mount c /' -c 'copy c:\path\to\input c:\path\to\output' -c exit
    cat /path/to/OUTPUT
    This function is performed by the privileged user if the executable has the SUID bit set and the right ownership because the effective privileges are not dropped.
    dosbox -c 'mount c /' -c 'copy c:\path\to\input c:\path\to\output' -c exit
    cat /path/to/OUTPUT