stat/fstat incompatibility w/ unix sockets

Paul Swartz z3p@twistedmatrix.com
Thu Feb 20 18:54:00 GMT 2003


OK, here's what the script looks like on Cygwin:
-----
stat from filename (49536, 1374655, 27579L, 1, 1005, 513, 51, 
1045764368, 1045764368, 1045764368)
stat from fileno   (49590, 1672, 2816L, 1, 0, 0, 0, 1045764368, 
1045764368, 1045764368)
-----
The lists correspond to (st_mode, st_ino, st_dev, st_nlink, st_uid, 
st_gid, st_size, st_atime, st_mtime, st_ctime)

As you can see, most of the numbers are not the same.  In fact, the 
only ones that /are/ the same at st_nlink and st_atime.

On *nix, the results look like this:
-----
stat from filename (49536, 3228941L, 769L, 1, 1037, 1037, 0L, 
1045736044, 1045736044, 1045736044)
stat from fileno   (49663, 5351966L, 0L, 1, 1037, 1037, 0L, 
1045736044, 1045736044, 1045736044)
-----
The only ones on *nix that are different are the first three 
(st_mode, st_ino, and, st_dev).

The difference in the fstat on the opened fileno and the stat on 
the filename make it difficult, and probably impossible in some 
cases, to tell if the socket opened is the same as the file.  This 
makes writing secure software that uses UNIX sockets difficult, if 
not impossible.

-p
-- 
     Paul Swartz
(o_  http://twistedmatrix.com/users/z3p.twistd/
//\  z3p@twistedmatrix.com
V_/_ AIM: Z3Penguin


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list