if (!pw)
die("invalid user %s", user);
+ setgid(pw->pw_gid);
setuid(pw->pw_uid);
}
+/* Set the user and group permissions back to the requesting user */
+static void reset_user()
+{
+ setgid(getgid());
+ setuid(getuid());
+}
+
static char *dequote(char *arg)
{
char* narg = NULL;
fprintf(stderr, "\n");
die("only repository access is allowed");
}
- setuid(getuid());
+ reset_user();
argv[0] = SHELL;
execvp(argv[0], (char *const *) argv);
return 1;
if (!cfg.allow_interactive)
die("only repository access is allowed");
- setuid(getuid());
+ reset_user();
cd_to_homedir();
argv[0] = SHELL;
execvp(argv[0], (char *const *) argv);