[Patch] Define secure_getenv (was: Re: [Patch] Document __secure_getenv)

Florian Weimer fweimer@redhat.com
Fri Jul 13 13:36:00 GMT 2012


On 07/13/2012 11:52 AM, Andreas Schwab wrote:
> Florian Weimer <fweimer@redhat.com> writes:
>
>> I don't want to use secure_getenv for the public symbol because I think I
>> need three symbols: __secure_getenv (public, but without a default
>> version) for backwards compatibility, getenv_secure (public) for the new
>> interface, and __getenv_secure (GLIBC_PRIVATE) for the internal
>> cross-references, both within libc itself and from libnss_hesiod and
>> others.
>
> You don't need the third name, a symbol can have more than one version.
> Also, libc internal references are resolved internally via the hidden
> mechanism.

I figured out what I was doing wrong.  I didn't include <shlib-compat.h> and

compat_symbol (libc, secure_getenv, __secure_getenv, GLIBC_2_0);

was parsed as a function declaration.

Anyway, I couldn't get a GLIBC_PRIVATE symbol for __secure_getenv.  So 
I've renamed all the internal calls and ended up with:

$ readelf -s --wide libc.so | grep secure_getenv
    851: 00000000000378c0    27 FUNC    GLOBAL DEFAULT   12 
__secure_getenv@GLIBC_2.2.5
   1702: 00000000000378c0    27 FUNC    GLOBAL DEFAULT   12 
secure_getenv@@GLIBC_2.16
   4649: 00000000000378c0    27 FUNC    LOCAL  DEFAULT   12 
__GI_secure_getenv
   6819: 00000000000378c0    27 FUNC    GLOBAL DEFAULT   12 
__secure_getenv@GLIBC_2.2.5
   6843: 00000000000378c0    27 FUNC    GLOBAL DEFAULT   12 secure_getenv
$ readelf -s --wide hesiod/libnss_hesiod.so | grep secure_getenv
     25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND 
secure_getenv@GLIBC_2.16 (7)
    119: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND 
secure_getenv@@GLIBC_2.16

Is this acceptable?

(I'm using GLIBC_2.16 for testing because there isn't a GLIBC_2.17 or 
GLIBC_2.18 on the trunk.  Eventually, it will be GLIBC_2.18.)


-- 
Florian Weimer / Red Hat Product Security Team
-------------- next part --------------
A non-text attachment was scrubbed...
Name: secure_getenv.patch
Type: text/x-patch
Size: 9514 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20120713/efb1663e/attachment.bin>


More information about the Libc-alpha mailing list