- pw = getpwuid(me);
- if (!pw) {
- syslog(LOG_ERR, "executed by non-existant user (uid = %i)", (int)me);
- fprintf(stderr, "%s: you don't exist. Go away.\n", quis);
- exit(EXIT_FAILURE);
- }
- if (strcmp(pw->pw_shell, CHROOTSH_PATH) != 0) {
- syslog(LOG_ERR, "executed by non-chrooted user `%s'", pw->pw_name);
- fprintf(stderr, "%s: you aren't a chrooted user\n", quis);
- exit(EXIT_FAILURE);
+ {
+ uid_t eff = geteuid();
+
+ setreuid(eff, me);
+ pw = getpwuid(me);
+ if (!pw) {
+ syslog(LOG_ERR, "executed by non-existant user (uid = %i)", (int)me);
+ fprintf(stderr, "%s: you don't exist. Go away.\n", quis);
+ exit(EXIT_FAILURE);
+ }
+ if (strcmp(pw->pw_shell, CHROOTSH_PATH) != 0) {
+ syslog(LOG_ERR, "executed by non-chrooted user `%s'", pw->pw_name);
+ fprintf(stderr, "%s: you aren't a chrooted user\n", quis);
+ exit(EXIT_FAILURE);
+ }
+ endpwent();
+ setreuid(me, eff);