Discussion:
Protect files from opening
(too old to reply)
bar
2007-10-28 16:17:38 UTC
Permalink
Hello

I have an app which download and create some graphic files (.jpg,.gif etc)
to the local disk of the user. Is there any way to prevent opening files
manually by user. changing extension or something.
Regards
SA
Clayton Arends
2007-10-28 16:32:50 UTC
Permalink
Is there any way to prevent opening files manually by user. changing
extension or something.
That's one way. You would have to have some naming scheme so that your
program knows the correct file format when loading back in. For example,
drop the first letter, reverse the letter ordering, etc. ie. "_if" or "fig"
for "gif"

That solves the problem of double-click loading but a person could still
rename the file and load. To protect against that you could
encrypt/encode/compress the files before writing them to disk.

However, unless the images are of sensitive nature going through the hassle
usually isn't worth it.

Clayton
Remy Lebeau (TeamB)
2007-10-29 17:37:40 UTC
Permalink
Post by bar
I have an app which download and create some graphic files
(.jpg,.gif etc) to the local disk of the user. Is there any way to
prevent opening files manually by user. changing extension or
something.
Even if you changed the file extension, the user can still specify the new
filename in any "File Open" dialog outside of your application.

You could try compressing the files into an archive file, such as a .zip
file, and then password-protect it. Or encrypt the files during downloading
and then decrypt them whenever your app needs to use them.

What exactly are you trying to prevent?


Gambit
bar
2007-10-31 07:02:42 UTC
Permalink
Post by Remy Lebeau (TeamB)
What exactly are you trying to prevent?
I want to prevent file from editing.

Thanks
SA
Remy Lebeau (TeamB)
2007-10-31 19:00:16 UTC
Permalink
Post by bar
I want to prevent file from editing.
Then you will have to either:

1) encrypt the file, like I suggested earlier

2) open the file for exclusive access at the time you download it. This
will only work while the downloading app is running, though. Once the file
is closed, the user can access it.

3) lock the file contents via LockFile/Ex(). Again, this only works until
the file is closed.

4) change the permissions on the file after downloading it (which will
likely require the downloading app to have admin rights) so the user can't
access the file at all. This introduces a timing issue, though, since the
user could get to the file before the app can update it.


Gambit
Ed Mulroy [TeamB]
2007-10-31 22:58:36 UTC
Permalink
Wouldn't ACL be able to lock it from access by other users?

. Ed
Post by Remy Lebeau (TeamB)
Post by bar
I want to prevent file from editing.
1) encrypt the file, like I suggested earlier
2) open the file for exclusive access at the time you download it. This
will only work while the downloading app is running, though. Once the
file is closed, the user can access it.
3) lock the file contents via LockFile/Ex(). Again, this only works until
the file is closed.
4) change the permissions on the file after downloading it (which will
likely require the downloading app to have admin rights) so the user can't
access the file at all. This introduces a timing issue, though, since the
user could get to the file before the app can update it.
bar
2007-11-11 16:33:32 UTC
Permalink
Hi Remy
Thanks for reply.

Is there any way to do this.
I have a folder "Test" say in C:\Windows\Temp\Test where i have some images.

Either my appliation is running or not. can i prevent the user without
opening this folder or accessing this folder.

SA
Barry
2007-11-12 16:45:34 UTC
Permalink
I have a similar requirement but for text data files, that need to be non
user editable.

Ie Binary. Does anyone still use binary file formats? Last time I looked at
that was dos days, and using Turbo Basic.
Post by bar
Hi Remy
Thanks for reply.
Is there any way to do this.
I have a folder "Test" say in C:\Windows\Temp\Test where i have some images.
Either my appliation is running or not. can i prevent the user without
opening this folder or accessing this folder.
SA
Chris Uzdavinis (TeamB)
2007-11-12 18:24:08 UTC
Permalink
Post by Barry
I have a similar requirement but for text data files, that need to
be non user editable.
Ie Binary. Does anyone still use binary file formats? Last time I
looked at that was dos days, and using Turbo Basic.
Sorry to say, but binary files are user-editable as well, though
somewhat less convenient.

The usual way to prevent access to a file is through file permissions,
which is pretty much outside of C++, and now into OS features.
--
Chris (TeamB);
Barry
2007-11-13 05:34:40 UTC
Permalink
Post by Chris Uzdavinis (TeamB)
Post by Barry
I have a similar requirement but for text data files, that need to
be non user editable.
Ie Binary. Does anyone still use binary file formats? Last time I
looked at that was dos days, and using Turbo Basic.
Sorry to say, but binary files are user-editable as well, though
somewhat less convenient.
The usual way to prevent access to a file is through file permissions,
which is pretty much outside of C++, and now into OS features.
OK, I can accept that binary format is editible, but not by a less
experienced person. I personally don't have a requirement to hide the
file contents, but the controlling authority responsible for approval of
the software now requires certain input data to be hidden from the user,
or not readily editable.

Would you recommend binary, or file permissions. I guess file
permissions could be easier, in that I don't have to change my code, but
can one ship a file, say via email, that has a built in permission. I
doubt it. It is something that has to be set up on each computer on
which it is installed....right?

Harry
2007-11-12 20:27:50 UTC
Permalink
Hello,

Have you evaluate that files could be corrupted and just have to test
them by CRC computing ?
Loading...