|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
Re: Symlinks and Cryogenic Sleep
Subject: Re: Symlinks and Cryogenic Sleep
From: Pavel Machek (pavel
SUSE.CZ)
Date: Tue Jan 04 2000 - 15:47:09 CST
- Next message: Chris Siebenmann: "Security problem with Solstice Backup/Legato Networker recover command"
- Previous message: Sonny Parlin: "Re: Flaw in 3c59x.c or in Kernel?"
- In reply to: Olaf Kirch: "Symlinks and Cryogenic Sleep"
- Next in thread: Antonomasia: "Re: Symlinks and Cryogenic Sleep"
- Reply: Pavel Machek: "Re: Symlinks and Cryogenic Sleep"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi!
> when you're dealing with files in /tmp that are supposed to be re-opened
> (rather than opened once and then discarded) there's an established
> way to do it which goes like this:
>
> if (lstat(fname, &stb1) >= 0 && S_ISREG(stb1.st_mode)) {
> fd = open(fname, O_RDWR);
> if (fd < 0 || fstat(fd, &stb2) < 0
> || ino_or_dev_mismatch(&stb1, &stb2))
> raise_big_stink()
If you add (at this place)
if (lstat(fname, &stb2) < 0 || !S_ISREG(stb2.st_mode))
ino_or_dev_mismatch(&stb1, &stb2)
it is safe.
Idea is: once opened, dev/ino is stable, therefore if I followed link
to interesting file, there's no way to create other regular file with
same dev/ino.
> Comments? Suggestions?
See above. Does it work?
Pavel
PS: Do you need to _symlink_ it? What about hardlinks?
-- I'm pavelucw.cz. "In my country we have almost anarchy and I don't care." Panos Katsaloulis describing me w.r.t. patents me at discuss
linmodems.org
- Next message: Chris Siebenmann: "Security problem with Solstice Backup/Legato Networker recover command"
- Previous message: Sonny Parlin: "Re: Flaw in 3c59x.c or in Kernel?"
- In reply to: Olaf Kirch: "Symlinks and Cryogenic Sleep"
- Next in thread: Antonomasia: "Re: Symlinks and Cryogenic Sleep"
- Reply: Pavel Machek: "Re: Symlinks and Cryogenic Sleep"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
This archive was generated by hypermail 2b27 : Wed Jan 05 2000 - 17:23:34 CST