pks-mail.c 587 B

123456789101112131415161718192021222324252627282930
  1. #include <stdlib.h>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. #define RUN_DIR L_PREFIX "/var/pks"
  5. #define RUN_SCRIPT L_PREFIX "/libexec/pks/pks-mail"
  6. int main(int argc, char *argv[])
  7. {
  8. static char *const exec_env[] = {
  9. "PATH=/bin:/usr/bin:/sbin:/usr/sbin",
  10. NULL
  11. };
  12. if (chdir(RUN_DIR) == -1) {
  13. perror("chdir");
  14. exit(1);
  15. }
  16. if (setuid(geteuid()) == -1) {
  17. perror("setuid");
  18. exit(1);
  19. }
  20. if (setgid(getegid()) == -1) {
  21. perror("setgid");
  22. exit(1);
  23. }
  24. execve(RUN_SCRIPT, argv, exec_env);
  25. }