getgid.c 306 B

123456789101112131415161718192021
  1. #include <sys/types.h>
  2. #include <grp.h>
  3. #include <unistd.h>
  4. /*
  5. * BUG: assumes group that is same as user name
  6. * is the one wanted (plan 9 has no "current group")
  7. */
  8. gid_t
  9. getgid(void)
  10. {
  11. struct group *g;
  12. g = getgrnam(getlogin());
  13. return g? g->gr_gid : 1;
  14. }
  15. gid_t
  16. getegid(void)
  17. {
  18. return getgid();
  19. }