Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Oct 2002 14:56:46 -0700 (PDT)
From:      Chris BeHanna <behanna@zbzoom.net>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   standards/44425: getcwd() succeeds even if current dir has perm 000.
Message-ID:  <200210232156.g9NLukQY020603@www.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         44425
>Category:       standards
>Synopsis:       getcwd() succeeds even if current dir has perm 000.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 23 15:00:10 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Chris BeHanna
>Release:        4.7
>Organization:
>Environment:
FreeBSD topperwein.pennasoft.com 4.7-STABLE FreeBSD 4.7-STABLE #0: Mon Oct 21 14:19:21 EDT 2002     behanna@topperwein.pennasoft.com:/raid0/usr/src/sys/TOPPERWEIN  i386
>Description:
POSIX requires that getcwd() return EACCES if any component of the
pathname lacks either read or search permission; however, even in a
directory for which the permissions mask is 000, getcwd() succeeds.
>How-To-Repeat:
Compile the following program:

/*
 * getcwd bug demo
 */

#include <sys/param.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

int
main(int argc, char* argv[])
{
    char* retbuf;

    if ((retbuf = getcwd(NULL, MAXPATHLEN+1)) == NULL) {
        fprintf(stderr, "getcwd() failed: errno = %d (%s)\n",
                errno,
                strerror(errno));
        exit(1);
    }

    printf("%s\n", retbuf);
    free(retbuf);
    exit(0);
}

as, say gcc -o /tmp/t t.c

then do the following:

mkdir foo
cd foo
chmod 000 .
/tmp/t
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-standards" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210232156.g9NLukQY020603>