How to password protect mat files

Hi all.
I am looking for a way to password protect a .mat file. My requirements are that it cannot be changed or deleted without a password.
I'm not looking for encryption, I just don't want someone else to accidentally delete it, since it is on a network drive. I want to be able to load and save the file using MATLAB.
I thought about creating a password protected .zip file, but MATLAB cannot unzip protected files.
Any suggestions would be appreciated.

 채택된 답변

Jan
Jan 2013년 8월 7일

1 개 추천

Set the write-protection of a file:
fileattrib('myfile.m', '-w')
But look in the documentation: doc fileattrib:
'w' Write access (Windows and UNIX platforms). Results differ by platform and
application. For example, even though fileattrib disables the "write"
privilege for a folder, making it read only, files in the folder could be
writable for some platforms or applications.
You can change the permissions by calling system commands, so please explain on which OS the function should run.

댓글 수: 5

Yoav Livneh
Yoav Livneh 2013년 8월 7일
I will be running Windows XP. Can this function prevent other people from deleting the file? I think this could br a very good solution
Jan
Jan 2013년 8월 7일
You can write a small script, which removes write access to all users but the admin. But any user with admin privileges can still delete this file.
A big security problem is, that this script requires admin privileges also. To obtain them, you have to enter a password. When the password is stored in clear text in the script, anybody can find it there.
What is the required security level? In which situations should the deleting be forbidden? What about somebody, who boots your machine from a Linux-live-CD?
The only reliable technique is implemented in hardware: Install a CD-writer and insert a CD-R (not RW!). Then after a file is written to the disk, nobody can delete the file even not with any password.
Yoav Livneh
Yoav Livneh 2013년 8월 8일
I'm not looking to encrypt the file or prevent malicious action. I only want to protect it against accidents, such as deletion or moving of the file.
The file in question is a station calibration file, which might change over time. I want to be able to run a calibration script which automatically updates the file, while preventing other people from messing with the file.
Jan
Jan 2013년 8월 8일
This sounds to be a perfect task for a backup. E.g. store a duplicate file in a deeply nested folder and let Matlab check if both files are identical. Then a missing, moved or changed file can be fixed silently or verbosely by a simple file copy.
The much smaller complexity of this method and the independence from the OS will be a great improvement for the stability.
Yoav Livneh
Yoav Livneh 2013년 8월 8일
Thank you very much for the suggestions. My boss really liked the copy pretection idea, so I will go with that one.
But I have also added that every time someone runs the calibration program, MATLAB will save a backup of the previous calibration file before saving, just in case.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2013년 8월 6일

0 개 추천

Protection against deletion needs to be at the operating system level, not at the MATLAB level.
Generally speaking, you would set the ownership of the file to be different than any userid that will have normal access to the file, and you set the file to be only writable by the owner. The mechanisms to do these vary with the operating system you are using.

댓글 수: 3

Yoav Livneh
Yoav Livneh 2013년 8월 7일
Thanks for the answer.
Can I set permissions per application? I mean can I set that only MATLAB will be able to edit the file, and only using a password?
I want to implement this on a machine on the production line, so making it user selective might be a little difficult.
Walter Roberson
Walter Roberson 2013년 8월 7일
That might be difficult. Which operating system will be used?
Yoav Livneh
Yoav Livneh 2013년 8월 7일
I will be using Windows XP

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Share and Distribute Software에 대해 자세히 알아보기

제품

태그

질문:

2013년 8월 6일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by