Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ssh-pool

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ssh-pool - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

11

lib/connection.js

@@ -56,3 +56,4 @@ var _ = require('lodash');

// In sudo mode, we use a TTY channel.
var args = /^sudo/.exec(command) ? ['-tt'] : [];
var isSudo = /^sudo/.exec(command);
var args = isSudo ? ['-tt'] : [];
args.push.apply(args, connection.sshArgs);

@@ -64,2 +65,10 @@ args.push(remote.format(connection.remote));

if (_.isString(connection.options.asUser)) {
if (isSudo) {
command = command.replace('sudo', '');
}
command = 'sudo -u ' + connection.options.asUser + command;
}
// Complete arguments.

@@ -66,0 +75,0 @@ args = ['ssh'].concat(args).concat(['"' + command + '"']);

2

package.json
{
"name": "ssh-pool",
"version": "1.4.2",
"version": "1.5.0",
"description": "Run remote commands over a pool of server using SSH.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -173,2 +173,31 @@ var rewire = require('rewire');

describe('#run asUser', function () {
var connection;
beforeEach(function () {
connection = new Connection({
remote: 'user@host',
asUser: 'test'
});
});
it('should handle sudo as user correctly', function (done) {
connection.run('sudo my-command -x', {cwd: '/root'}, done);
expect(childProcess.exec).to.be.calledWith(
'ssh -tt user@host "sudo -u test my-command -x"',
{cwd: '/root', maxBuffer: 1000 * 1024}
);
});
it('should handle sudo as user without double sudo', function (done) {
connection.run('sudo my-command -x', {cwd: '/root'}, done);
expect(childProcess.exec).to.be.calledWith(
'ssh -tt user@host "sudo -u test my-command -x"',
{cwd: '/root', maxBuffer: 1000 * 1024}
);
});
});
describe('#copy', function () {

@@ -175,0 +204,0 @@ var connection;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc