Fix OutOfScope exception when auditing ssh auth failure.

SshScope$ContextProvider cannot provide a session context when
authentication fails.

Change-Id: I29be6db323f251b1f6b90940655876665c268885
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
Signed-off-by: Sasa Zivkov <sasa.zivkov@sap.com>
This commit is contained in:
Sasa Zivkov
2012-10-24 16:33:34 +02:00
parent 547bb9a661
commit 5605262667

View File

@@ -101,7 +101,7 @@ class SshLog implements LifecycleListener {
void onLogin() {
async.append(log("LOGIN FROM " + session.get().getRemoteAddressAsString()));
audit("0", "LOGIN", new String[] {});
audit(context.get(), "0", "LOGIN", new String[] {});
}
void onAuthFail(final SshSession sd) {
@@ -127,7 +127,7 @@ class SshLog implements LifecycleListener {
}
async.append(event);
audit("FAIL", "AUTH", new String[] {sd.getRemoteAddressAsString()});
audit(null, "FAIL", "AUTH", new String[] {sd.getRemoteAddressAsString()});
}
void onExecute(int exitValue) {
@@ -165,7 +165,8 @@ class SshLog implements LifecycleListener {
event.setProperty(P_STATUS, status);
async.append(event);
audit(status, getCommand(commandLine), CommandFactoryProvider.split(commandLine));
audit(context.get(), status, getCommand(commandLine),
CommandFactoryProvider.split(commandLine));
}
private String getCommand(String commandLine) {
@@ -176,7 +177,7 @@ class SshLog implements LifecycleListener {
void onLogout() {
async.append(log("LOGOUT"));
audit("0", "LOGOUT", new String[] {});
audit(context.get(), "0", "LOGOUT", new String[] {});
}
private LoggingEvent log(final String msg) {
@@ -415,8 +416,7 @@ class SshLog implements LifecycleListener {
}
}
void audit(Object result, String commandName, String[] args) {
final Context ctx = context.get();
void audit(Context ctx, Object result, String commandName, String[] args) {
final String sid = extractSessionId(ctx);
final long created = extractCreated(ctx);
final String what = extractWhat(commandName, args);