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 Subject: [1.7] bugs in faccessat Date: Thu, 3 Sep 2009 15:58:51 +0000 (UTC) Lines: 33 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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: 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 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