Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Protection of tied files

Reply
Thread Tools

Protection of tied files

 
 
J Krugman
Guest
Posts: n/a
 
      01-06-2005




Suppose that I have a Perl variable tied to some file. Does Perl
provide any facilities for preventing some other program from
modifying this file, and/or for detecting if such modification
happens? (I'm only interested in the UNIX case).

TIA!

jill

--
To s&e^n]d me m~a}i]l r%e*m?o\v[e bit from my a|d)d:r{e:s]s.

 
Reply With Quote
 
 
 
 
Anno Siegel
Guest
Posts: n/a
 
      01-06-2005
J Krugman <(E-Mail Removed)> wrote in comp.lang.perl.misc:
>
>
>
>
> Suppose that I have a Perl variable tied to some file. Does Perl
> provide any facilities for preventing some other program from
> modifying this file, and/or for detecting if such modification
> happens? (I'm only interested in the UNIX case).


That is really a question about Unix then. Perl can only offer services
that are supported by the OS.

The answer is no. There is no way to stop a process with sufficient
permissions to change a file. There may be implementations of mandatory
locking, but that's not standard.

Neither is there a reliable means of checking if the file was changed.
The one-second resolution of file times is too coarse to be sure. The
only way is to keep a copy and compare.

All this is quite independent of the possibility that some Perl program
could have decided to tie a variable (in what sense?) to the file.

The usual solution is to set file permissions so that only collaborating
users (normally just one) have access, and use (advisory) file locking
for access control. That can be made watertight.

Anno
 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      01-06-2005
J Krugman <(E-Mail Removed)> wrote:
> Suppose that I have a Perl variable tied to some file. Does Perl
> provide any facilities for preventing some other program from
> modifying this file, and/or for detecting if such modification
> happens? (I'm only interested in the UNIX case).
>
> TIA!


You could unlink the filename which the variable is tied to, so that the
only remaining link to the file inode is the one held by the perl program.
That should stop all but the most dedicated superusers from messing with
it. This still leaves a brief period in which someone could grab the file,
so to be even safer, you should avoid ever creating the filename entry in
the filesystem in the first place.

perldoc -f open:

As a special case the 3 arg form with a read/write mode and the
third argument being "undef":
open(TMP, "+>", undef) or die ...
opens a filehandle to an anonymous temporary file.

Of course doing this means that the filedata will be lost as soon as your
program exits, so I hope that that is OK with you.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
botfood
Guest
Posts: n/a
 
      01-07-2005
are you asking about flock() considerations to prevent other scripts
from stepping on a tied file, or a permission issue with keeping
network users from touching a file?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy protection / IP protection g Java 69 04-25-2006 04:10 PM
Is Xnews tied or connected to MS Internet Explorer in some way? MyName Computer Security 6 04-01-2006 07:33 PM
Linksys VoIP boxes NOT tied to a particular provider? Ramon F Herrera Cisco 2 02-15-2006 07:01 PM
Linksys VoIP boxes NOT tied to a particular provider? Ramon F Herrera VOIP 2 02-15-2006 07:01 PM



Advertisments