Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Delivered-To: corinna-cygwin AT cygwin DOT com From: "Paul Swartz" To: corinna-cygwin AT cygwin DOT com Date: Thu, 20 Feb 2003 13:23:43 -0500 MIME-Version: 1.0 Subject: Re: stat/fstat incompatibility w/ unix sockets CC: cygwin AT cygwin DOT com Message-ID: <3E54D6DF.19171.3D8BCC@localhost> In-reply-to: <20030220093011.GA1403@cygbert.vinschen.de> Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body 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 AT twistedmatrix DOT 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/