From fdf85cf245cddf121d35799637aaea8795db2ebd Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 10 Apr 2014 18:58:09 -0400
Subject: [PATCH] Fix exception handling for account with no public keys
---
src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
index 7088fef..4162a40 100644
--- a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
+++ b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
@@ -48,8 +48,13 @@
private static final Logger log = LoggerFactory.getLogger(BaseCommand.class);
- /** Ssh context */
- protected SshCommandContext ctx;
+ private static final int PRIVATE_STATUS = 1 << 30;
+
+ public final static int STATUS_CANCEL = PRIVATE_STATUS | 1;
+
+ public final static int STATUS_NOT_FOUND = PRIVATE_STATUS | 2;
+
+ public final static int STATUS_NOT_ADMIN = PRIVATE_STATUS | 3;
protected InputStream in;
@@ -60,6 +65,9 @@
protected ExitCallback exit;
protected ServerSession session;
+
+ /** Ssh command context */
+ private SshCommandContext ctx;
/** Text of the command line which lead up to invoking this instance. */
private String commandName = "";
@@ -86,6 +94,8 @@
@Override
public void destroy() {
+ log.debug("destroying " + getClass().getName());
+ session = null;
ctx = null;
}
@@ -96,10 +106,22 @@
@Override
public abstract void start(Environment env) throws IOException;
+ protected void provideStateTo(final BaseCommand cmd) {
+ cmd.setContext(ctx);
+ cmd.setInputStream(in);
+ cmd.setOutputStream(out);
+ cmd.setErrorStream(err);
+ cmd.setExitCallback(exit);
+ }
+
public void setContext(SshCommandContext ctx) {
this.ctx = ctx;
}
+ public SshCommandContext getContext() {
+ return ctx;
+ }
+
@Override
public void setInputStream(final InputStream in) {
this.in = in;
--
Gitblit v1.9.1