delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/09/03/11:59:28

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_74,J_CHICKENPOX_82,SPF_HELO_PASS,SPF_PASS
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: Eric Blake <ebb9 AT byu DOT net>
Subject: [1.7] bugs in faccessat
Date: Thu, 3 Sep 2009 15:58:51 +0000 (UTC)
Lines: 33
Message-ID: <loom.20090903T175736-252@post.gmane.org>
Mime-Version: 1.0
User-Agent: Loom/3.14 (http://gmane.org/)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

faccessat has at least two, and probably three bugs.

First, a typo - the EINVAL check is done against flags (the fourth argument) 
rather than mode (third argument), such that faccessat(AT_FDCWD,".",-1,0) 
passes even though the corresponding access(".",-1) fails.

Second, it is not performing the proper checks when AT_EACCESS is set and the 
applications' effective id differs from the real id (to fix this would require 
adding a parameter to fhandler_base::fhaccess).  If this latter bug is fixed, 
then it would be nice to copy Linux and export:

euidaccess(file,mode) => faccessat(AT_FDCWD,file,mode,AT_EACCESS)
eaccess(file,mode) => euidaccess(file,mode)

Third, POSIX permits us to return EINVAL to reject flags we don't support.  For 
example, both:

faccessat(fd,name,F_OK,AT_REMOVEDIR)
fchownat(fd,name,uid,gid,AT_EACCESS)

should probably fail with EINVAL.  In other words, we should support only the 
following:

faccessat - AT_SYMLINK_NOFOLLOW, AT_EACCESS (POSIX doesn't require 
AT_SYMLINK_NOFOLLOW, but Linux supports it)
fchownat, fchmodat, fstatat, utimensat - AT_SYMLINK_NOFOLLOW
linkat - AT_SYMLINK_FOLLOW
unlinkat - AT_REMOVEDIR

-- 
Eric Blake




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019