Blame crypto/uid.c

Packit Service 084de1
/*
Packit Service 084de1
 * Copyright 2001-2019 The OpenSSL Project Authors. All Rights Reserved.
Packit Service 084de1
 *
Packit Service 084de1
 * Licensed under the OpenSSL license (the "License").  You may not use
Packit Service 084de1
 * this file except in compliance with the License.  You can obtain a copy
Packit Service 084de1
 * in the file LICENSE in the source distribution or at
Packit Service 084de1
 * https://www.openssl.org/source/license.html
Packit Service 084de1
 */
Packit Service 084de1
Packit Service 084de1
#include <openssl/crypto.h>
Packit Service 084de1
#include <openssl/opensslconf.h>
Packit Service 084de1
Packit Service 084de1
#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
Packit Service 084de1
Packit Service 084de1
int OPENSSL_issetugid(void)
Packit Service 084de1
{
Packit Service 084de1
    return 0;
Packit Service 084de1
}
Packit Service 084de1
Packit Service 084de1
#elif defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__)
Packit Service 084de1
Packit Service 084de1
# include OPENSSL_UNISTD
Packit Service 084de1
Packit Service 084de1
int OPENSSL_issetugid(void)
Packit Service 084de1
{
Packit Service 084de1
    return issetugid();
Packit Service 084de1
}
Packit Service 084de1
Packit Service 084de1
#else
Packit Service 084de1
Packit Service 084de1
# include OPENSSL_UNISTD
Packit Service 084de1
# include <sys/types.h>
Packit Service 084de1
Packit Service 084de1
# if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
Packit Service 084de1
#  if __GLIBC_PREREQ(2, 16)
Packit Service 084de1
#   include <sys/auxv.h>
Packit Service 084de1
#   define OSSL_IMPLEMENT_GETAUXVAL
Packit Service 084de1
#  endif
Packit Service 084de1
# endif
Packit Service 084de1
Packit Service 084de1
int OPENSSL_issetugid(void)
Packit Service 084de1
{
Packit Service 084de1
# ifdef OSSL_IMPLEMENT_GETAUXVAL
Packit Service 084de1
    return getauxval(AT_SECURE) != 0;
Packit Service 084de1
# else
Packit Service 084de1
    return getuid() != geteuid() || getgid() != getegid();
Packit Service 084de1
# endif
Packit Service 084de1
}
Packit Service 084de1
#endif