become.c 430 B

12345678910111213141516171819202122232425262728
  1. #include "common.h"
  2. #include <auth.h>
  3. #include <ndb.h>
  4. /*
  5. * become powerless user
  6. */
  7. int
  8. become(char **cmd, char *who)
  9. {
  10. int fd;
  11. USED(cmd);
  12. if(strcmp(who, "none") == 0) {
  13. fd = open("#c/user", OWRITE);
  14. if(fd < 0 || write(fd, "none", strlen("none")) < 0) {
  15. werrstr("can't become none");
  16. return -1;
  17. }
  18. close(fd);
  19. if(newns("none", 0)) {
  20. werrstr("can't set new namespace");
  21. return -1;
  22. }
  23. }
  24. return 0;
  25. }