Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Jun 2006 11:29:59 +0200
From:      "=?ISO-8859-1?Q?Alex_Mart=EDnez?=" <unledev@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   __getcwd() question
Message-ID:  <5e4707340606040229s1689fa5cl758d8d7df1ce2b60@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi guys,

I've come across some problems while porting to FreeBSD a wrapper library
which protects the filesystem from unauthorized accesses by overriding
potentially dangerous functions and making some checks before calling the
real thing. Turns out that overriding getcwd() resulted in segfaults because
the library wrapped both getcwd() and __getcwd(), so that libc's getcwd()
would call my wrapped __getcwd() instead of its own version, and my version
would call libc's getcwd() again (which is wrong anyways), effectively
building an infinite recursion loop.

This stems from the fact that __getcwd() is exported by FreeBSD's libc (as a
weak alias to __sys___getcwd(), along with ___getcwd()), while the libc this
library ran originally on (GNU) does not export it. So here come my
questions: is there any legal use of __getcwd() (and the other two functions
for that matter) outside the libc? Any reason explaining why it should be
exported? I guess backwards compatibility can be one such reason, but I'd
like to know what you people think about it, specially if they were
initially exported on purpose.

TIA,

Alex



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