Do not duplicate sshd_config file path
This commit is contained in:
@@ -59,9 +59,10 @@ async function canEnableRemoteSupport(req, res, next) {
|
||||
|
||||
if (!supportConfig.remoteSupport) return next(new HttpError(405, 'feature disabled by admin'));
|
||||
|
||||
const sshdConfig = safe.fs.readFileSync('/etc/ssh/sshd_config', 'utf8');
|
||||
if (!sshdConfig) return next(new HttpError(412, 'Failed to read sshd config'));
|
||||
if (!sshdConfig.split('\n').find(function (line) { return line.search(/^PermitRootLogin.*yes/) !== -1; })) return next(new HttpError(417, 'Set "PermitRootLogin yes" in /etc/ssh/sshd_config'));
|
||||
const SSHD_CONFIG_FILE = '/etc/ssh/sshd_config';
|
||||
const sshdConfig = safe.fs.readFileSync(SSHD_CONFIG_FILE, 'utf8');
|
||||
if (!sshdConfig) return next(new HttpError(412, `Failed to read file ${SSHD_CONFIG_FILE}`));
|
||||
if (!sshdConfig.split('\n').find(function (line) { return line.search(/^PermitRootLogin.*yes/) !== -1; })) return next(new HttpError(417, `Set "PermitRootLogin yes" in ${SSHD_CONFIG_FILE}`));
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user