- if (!strcmp(argv[a], "-p")) {
- struct stat st;
-
- if (chdir(CTDLDIR) < 0) {
- perror("can't change to " CTDLDIR);
- logoff(NULL, 3);
- }
-
- /*
- * Drop privileges if necessary. We stat
- * citadel.config to get the uid/gid since it's
- * guaranteed to have the uid/gid we want.
- */
- if (!getuid() || !getgid()) {
- if (stat(file_citadel_config, &st) < 0) {
- perror("couldn't stat citadel.config");
- logoff(NULL, 3);
- }
- if (!getgid() && (setgid(st.st_gid) < 0)) {
- perror("couldn't change gid");
- logoff(NULL, 3);
- }
- if (!getuid() && (setuid(st.st_uid) < 0)) {
- perror("couldn't change uid");
- logoff(NULL, 3);
- }
- /*
- scr_printf("Privileges changed to uid %d gid %d\n",
- getuid(), getgid());
- */
- }
- argc = shift(argc, argv, a, 1);
- }