1
0
Fork 0

Implement simple access control for reading and writing files that are accessable from within DOSBox. Overlay not yet tested, hence not part of this commit.

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4245
This commit is contained in:
Peter Veenstra 2019-06-25 17:53:05 +00:00
parent 551ee5b2fd
commit 0abb573167
3 changed files with 12 additions and 12 deletions

View file

@ -607,9 +607,9 @@ private:
//File not found on mounted filesystem. Try regular filesystem
std::string filename_s(filename);
Cross::ResolveHomedir(filename_s);
tmpfile = fopen(filename_s.c_str(),"rb+");
tmpfile = fopen_wrap(filename_s.c_str(),"rb+");
if(!tmpfile) {
if( (tmpfile = fopen(filename_s.c_str(),"rb")) ) {
if( (tmpfile = fopen_wrap(filename_s.c_str(),"rb")) ) {
//File exists; So can't be opened in correct mode => error 2
// fclose(tmpfile);
// if(tryload) error = 2;
@ -1301,7 +1301,7 @@ public:
if(fstype=="fat") {
if (imgsizedetect) {
FILE * diskfile = fopen(temp_line.c_str(), "rb+");
FILE * diskfile = fopen_wrap(temp_line.c_str(), "rb+");
if (!diskfile) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_IMAGE"));
return;
@ -1448,7 +1448,7 @@ public:
WriteOut(MSG_Get("PROGRAM_MOUNT_STATUS_2"), drive, tmp.c_str());
} else {
FILE *newDisk = fopen(temp_line.c_str(), "rb+");
FILE *newDisk = fopen_wrap(temp_line.c_str(), "rb+");
if (!newDisk) {
WriteOut(MSG_Get("PROGRAM_IMGMOUNT_INVALID_IMAGE"));
return;

View file

@ -705,7 +705,7 @@ fatDrive::fatDrive(const char *sysFilename, Bit32u bytesector, Bit32u cylsector,
imgDTA = new DOS_DTA(imgDTAPtr);
}
diskfile = fopen(sysFilename, "rb+");
diskfile = fopen_wrap(sysFilename, "rb+");
if(!diskfile) {created_successfully = false;return;}
fseek(diskfile, 0L, SEEK_END);
filesize = (Bit32u)ftell(diskfile) / 1024L;

View file

@ -39,16 +39,16 @@ bool localDrive::FileCreate(DOS_File * * file,char * name,Bit16u /*attributes*/)
CROSS_FILENAME(newname);
char* temp_name = dirCache.GetExpandName(newname); //Can only be used in till a new drive_cache action is preformed */
/* Test if file exists (so we need to truncate it). don't add to dirCache then */
bool existing_file=false;
bool existing_file = false;
FILE * test=fopen(temp_name,"rb+");
FILE * test = fopen_wrap(temp_name,"rb+");
if(test) {
fclose(test);
existing_file=true;
}
FILE * hand=fopen(temp_name,"wb+");
FILE * hand = fopen_wrap(temp_name,"wb+");
if (!hand){
LOG_MSG("Warning: file creation failed: %s",newname);
return false;
@ -95,11 +95,11 @@ bool localDrive::FileOpen(DOS_File * * file,char * name,Bit32u flags) {
}
}
FILE * hand=fopen(newname,type);
FILE * hand = fopen_wrap(newname,type);
// Bit32u err=errno;
if (!hand) {
if((flags&0xf) != OPEN_READ) {
FILE * hmm=fopen(newname,"rb");
FILE * hmm = fopen_wrap(newname,"rb");
if (hmm) {
fclose(hmm);
LOG_MSG("Warning: file %s exists and failed to open in write mode.\nPlease Remove write-protection",newname);
@ -122,7 +122,7 @@ FILE * localDrive::GetSystemFilePtr(char const * const name, char const * const
CROSS_FILENAME(newname);
dirCache.ExpandName(newname);
return fopen(newname,type);
return fopen_wrap(newname,type);
}
bool localDrive::GetSystemFilename(char *sysName, char const * const dosName) {
@ -145,7 +145,7 @@ bool localDrive::FileUnlink(char * name) {
struct stat buffer;
if(stat(fullname,&buffer)) return false; // File not found.
FILE* file_writable = fopen(fullname,"rb+");
FILE* file_writable = fopen_wrap(fullname,"rb+");
if(!file_writable) return false; //No acces ? ERROR MESSAGE NOT SET. FIXME ?
fclose(file_writable);