cuserid.c 343 B

123456789101112131415161718192021
  1. #include <unistd.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. /*
  5. * BUG: supposed to be for effective uid,
  6. * but plan9 doesn't have that concept
  7. */
  8. char *
  9. cuserid(char *s)
  10. {
  11. char *logname;
  12. static char buf[L_cuserid];
  13. if((logname = getlogin()) == NULL)
  14. return(NULL);
  15. if(s == 0)
  16. s = buf;
  17. strncpy(s, logname, sizeof buf);
  18. return(s);
  19. }