From 93cff52c1f1837eafdc525c1303680f632509798 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 22 Oct 2015 11:04:50 -0600 Subject: [PATCH] * Allow SSHPMPT.ASC for displaying SSH/secure app info/instructions --- core/config.js | 4 +++- core/servers/ssh.js | 27 +++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/core/config.js b/core/config.js index c2e6b033..40068bb8 100644 --- a/core/config.js +++ b/core/config.js @@ -77,7 +77,9 @@ function getDefaultConfig() { invalidUsernames : [], groups : [ 'users', 'sysops' ], // built in groups - defaultGroups : [ 'users' ] // default groups new users belong to + defaultGroups : [ 'users' ], // default groups new users belong to + + newUserNames : [ 'new', 'apply' ], // Names reserved for applying }, // :TODO: better name for "defaults"... which is redundant here! diff --git a/core/servers/ssh.js b/core/servers/ssh.js index 8b8d01bd..c856d9d0 100644 --- a/core/servers/ssh.js +++ b/core/servers/ssh.js @@ -8,6 +8,7 @@ var Log = require('../logger.js').log; var ServerModule = require('../server_module.js').ServerModule; var userLogin = require('../user_login.js').userLogin; var enigVersion = require('../../package.json').version; +var theme = require('../theme.js'); var ssh2 = require('ssh2'); var fs = require('fs'); @@ -63,6 +64,8 @@ function SSHClient(clientConn) { // :TODO: Can we display somthing here? termConnection(); return; + } else { + return ctx.reject(SSHClient.ValidAuthMethods); } } else { ctx.accept(); @@ -73,6 +76,8 @@ function SSHClient(clientConn) { return ctx.reject(SSHClient.ValidAuthMethods); } + console.log(ctx.method) + if(0 === username.length) { // :TODO: can we display something here? return ctx.reject(); @@ -88,13 +93,27 @@ function SSHClient(clientConn) { if(err.existingConn) { // :TODO: can we display something here? termConnection(); - } else { - interactivePrompt.prompt = 'Access denied\n' + ctx.username + '\'s password: '; - + } else { if(loginAttempts >= conf.config.general.loginAttempts) { termConnection(); } else { - return ctx.prompt(interactivePrompt, retryPrompt); + var artOpts = { + client : self, + name : 'SSHPMPT.ASC', + readSauce : false, + }; + theme.getThemeArt(artOpts, function gotArt(err, artInfo) { + if(err) { + interactivePrompt.prompt = 'Access denied\n' + ctx.username + '\'s password: '; + } else { + var newUserNameList = '"' + (conf.config.users.newUserNames || []).join(', ') + '"'; + interactivePrompt.prompt = + 'Access denied\n' + + artInfo.data.format( { newUserNames : newUserNameList } ) + + '\n' + ctx.username + '\'s password: '; + } + return ctx.prompt(interactivePrompt, retryPrompt); + }); } } } else {