summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 9fb7f31..4ba1d4d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -228,14 +228,14 @@ int main(int argc, char* argv[]) {
return 1;
}
user = argv[1];
- // Read the USERNAME variable
+ // Set the USERNAME environment variable
setenv("USERNAME", user, 1);
// Ensure a command was specified
if(! getenv("SSH_ORIGINAL_COMMAND")) {
sprintf(msg, "[%s] logged in without specifying a command", user);
logmsg(msg);
- printf("No soup for you!\n");
+ fprintf(stderr, "No soup for you!\n");
return 1;
}
@@ -245,22 +245,20 @@ int main(int argc, char* argv[]) {
if(is_git_cmd(cmd)) {
// Read the repo path (command argument)
if(!validate_git(user)) {
- sprintf(msg, "[%s] attempted invalid git command \"%s\"",
- user, getenv("SSH_ORIGINAL_COMMAND"));
+ sprintf(msg, "[%s] attempted invalid git command \"%s\"", user, cmd);
logmsg(msg);
return 1;
}
} else if(! is_allowed_cmd(cmd)) {
- sprintf(msg, "[%s] attempted disallowed command \"%s\"",
- user, getenv("SSH_ORIGINAL_COMMAND"));
+ sprintf(msg, "[%s] attempted disallowed command \"%s\"", user, cmd);
logmsg(msg);
fprintf(stderr, "Command '%s' is not allowed\n", cmd);
return 1;
}
- sprintf(msg, "[%s] executed \"%s\"", user, getenv("SSH_ORIGINAL_COMMAND"));
+ sprintf(msg, "[%s] executed \"%s\"", user, cmd);
logmsg(msg);
- sprintf(gitsh, "/usr/bin/env git-shell -c \"%s\"", getenv("SSH_ORIGINAL_COMMAND"));
+ sprintf(gitsh, "/usr/bin/env git-shell -c \"%s\"", cmd);
system(gitsh);
return 0;

Generated by cgit