uid.c 926 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <openssl/crypto.h>
  10. #include <openssl/opensslconf.h>
  11. #if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD__ > 2) || defined(__DragonFly__)
  12. # include OPENSSL_UNISTD
  13. int OPENSSL_issetugid(void)
  14. {
  15. return issetugid();
  16. }
  17. #elif defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)
  18. int OPENSSL_issetugid(void)
  19. {
  20. return 0;
  21. }
  22. #else
  23. # include OPENSSL_UNISTD
  24. # include <sys/types.h>
  25. int OPENSSL_issetugid(void)
  26. {
  27. if (getuid() != geteuid())
  28. return 1;
  29. if (getgid() != getegid())
  30. return 1;
  31. return 0;
  32. }
  33. #endif