Re: Symlinks and Cryogenic Sleep

2000-01-07 Thread Pavel Kankovsky
On Mon, 3 Jan 2000, Olaf Kirch wrote: > 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: The problem lies in the premises: these files should not be stored in /tmp.

Re: Symlinks and Cryogenic Sleep

2000-01-07 Thread Antonomasia
My post yesterday seems to have died during moderation. This happened to my last 2 incidentally - both looked worthwhile to me. Olaf Kirch: > That's not true for setuid processes. You're allowed to signal a process > if _either_ the effective or the real uid match. Try running passwd in > one win

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Casper Dik
>>When >>the application reaches the critical section of code between the >>lstat and the open, you stop it by sending it a SIGSTOP. You record >>the device and inode number of your /tmp file, remove it, and wait. The ploy should fail right here: as far as I'm aware, this protection only works on

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Pavel Machek
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); >

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Marc Heuse
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: [...] >I did something that way: oh, not a good idea: >FILE *DoOpen(const char *cpFile, long bAppend) >{ >

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Marc Heuse
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); >

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Christos Zoulas
On Jan 4, 12:11pm, [EMAIL PROTECTED] (Goetz Babin-Ebell) wrote: -- Subject: Re: Symlinks and Cryogenic Sleep | At 21:24 03.01.00 +0100, Olaf Kirch wrote: | >Hi all, | Hallo Olaf, | | >when you're dealing with files in /tmp that are supposed to be re-opened | >(rather than opened

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread John Cochran
der Mouse <[EMAIL PROTECTED]> wrote: > > [symlink-paranoia code] > > > However, consider an average setuid root application, [...]. When > > the application reaches the critical section of code between the > > lstat and the open, you stop it by sending it a SIGSTOP. > > If you can send it a SIGS

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Antonomasia
Olaf Kirch asked about checking files when you reopen them and questioned the usefulness of > 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,

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Wietse Venema
Olaf Kirch: > Hi all, > > 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

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Henrik Nordstrom
Mark A. Heilpern wrote: > Maybe I'm just naive, but it's my understanding that you cannot > send signals to a process you don't own unless you are root. You can if you control the pty where the program is running. Then simulate susp characters (usually ^Z) to generate SIGTSTP, break (^C) to gene

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread pedward
Why not do an: fd = open(file, O_RDWR); fstat(fd, &fi); lstat(file, &li); if (fi.st_ino == li.st_ino && fi.st_dev == li.st_dev && S_ISREG(fi.st_mode)) { /* it's a real, plain, file */ } That guarantees that the directory structure reflects your file descriptor. The method below has

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Olaf Kirch
On Mon, Jan 03, 2000 at 05:34:45PM -0500, Mark A. Heilpern wrote: > Maybe I'm just naive, but it's my understanding that you cannot send signals > to a process you don't own unless you are root. That's not true for setuid processes. You're allowed to signal a process if _either_ the effective or

Re: Symlinks and Cryogenic Sleep

2000-01-05 Thread Mikael Olsson
I think I see a flaw with this... Goetz Babin-Ebell wrote: > > I did something that way: > > FILE *DoOpen(const char *cpFile, long bAppend) > { >FILE *spNew; >FILE *spTest; >struct stat sStat; > >spTest = fopen(cpFile,"a"); >if (!spTest) >{ > Log("ERR FILE OPEN",cpFi

Re: Symlinks and Cryogenic Sleep

2000-01-04 Thread der Mouse
> [symlink-paranoia code] > However, consider an average setuid root application, [...]. When > the application reaches the critical section of code between the > lstat and the open, you stop it by sending it a SIGSTOP. If you can send it a SIGSTOP, either you're running as root (in which case

Re: Symlinks and Cryogenic Sleep

2000-01-04 Thread Goetz Babin-Ebell
At 21:24 03.01.00 +0100, Olaf Kirch wrote: >Hi all, Hallo Olaf, >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

Re: Symlinks and Cryogenic Sleep

2000-01-04 Thread Mark A. Heilpern
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 At 09:24 PM 1/3/00 +0100, you wrote: [snip] >When >the application reaches the critical section of code between the >lstat and the open, you stop it by sending it a SIGSTOP. You record >the device and inode number of your /tmp file, remove it, and wa

Symlinks and Cryogenic Sleep

2000-01-03 Thread Olaf Kirch
Hi all, 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);