Mise à jour effectuée, merci de nous signaler tout dysfonctionnement ! | Upgrade done, please let us know about any dysfunction!

Commit 3554d39a authored by Cédric Moreau's avatar Cédric Moreau

Now can give a PGP key without password to ucoin's node

parent 47cae357
#!/bin/bash
gpg --batch --no-default-keyring --secret-keyring $1 --import $2 > /dev/null 2> /dev/null
gpg --batch --no-default-keyring --secret-keyring $1 --delete-secret-key $3
gpg --batch --no-default-keyring --secret-keyring $1 --import $2
#!/bin/bash
gpg --batch --no-default-keyring --secret-keyring $1 --local-user $2 $3 < <(echo -n "$MESSAGE")
\ No newline at end of file
......@@ -7,7 +7,7 @@ module.exports = function GPG(privateKey, passphrase, fingerprint, keyring, done
var fs = require('fs');
var privateKeyName = 'key' + Date.now();
var gpgimport = __dirname + '/gpg-import.sh ';
var gpgsh = __dirname + '/gpg.sh';
var gpgsh = passphrase ? __dirname + '/gpg.sh' : __dirname + '/gpg-nopasswd.sh';
this.init = function (done) {
async.waterfall([
......@@ -16,7 +16,13 @@ module.exports = function GPG(privateKey, passphrase, fingerprint, keyring, done
},
function (next){
var exec = require('child_process').exec;
exec(gpgimport + keyring + ' ' + privateKeyName, function (error, stdout, stderr) {
exec(gpgimport + [keyring, privateKeyName, fingerprint].join(' '), function (error, stdout, stderr) {
if (stdout) {
logger.trace(stdout);
}
if (stderr) {
logger.trace(stderr);
}
fs.unlink(privateKeyName, function (errUnlink) {
next(errUnlink);
});
......@@ -36,7 +42,9 @@ module.exports = function GPG(privateKey, passphrase, fingerprint, keyring, done
var signature = '';
var child = spawn(gpgsh, [keyring, fingerprint, options], { env: { MESSAGE: message }});
child.stdin.write(passphrase);
if (passphrase) {
child.stdin.write(passphrase);
}
child.stdin.end();
child.stderr.setEncoding('utf8');
......
......@@ -171,6 +171,9 @@ module.exports.express = {
// Checking configuration
privateKey = openpgp.key.readArmored(conf.pgpkey).keys[0];
if (conf.pgppasswd == null) {
conf.pgppasswd = "";
}
if (!privateKey) {
onLoaded('A private key for this node is mandatory. Relaunch with --pgpkey <pathToKey>.');
return;
......@@ -468,7 +471,7 @@ function httpgp(app, conf, done) {
var privateKey = conf.pgpkey;
async.waterfall([
function (next) {
var keyring = 'ucoin_' + module.exports.fingerprint();
var keyring = '~/.gnupg/ucoin_' + module.exports.fingerprint();
pgplogger.debug("Keyring = %s", keyring);
var gnupg = new (require('./gnupg'))(privateKey, conf.pgppasswd, module.exports.fingerprint(), keyring);
gnupg.init(function (err) {
......
......@@ -245,7 +245,7 @@ function overrideConf(conf) {
conf.ipv6 = cli.server.ipv6address || conf.ipv6;
conf.port = cli.server.port || conf.port;
conf.pgpkey = cli.server.pgp.key || conf.pgpkey;
conf.pgppasswd = cli.server.pgp.password || conf.pgppasswd;
conf.pgppasswd = cli.server.pgp.password != undefined ? cli.server.pgp.password : conf.pgppasswd;
conf.remotehost = cli.server.remote.host != undefined ? cli.server.remote.host : (conf.remotehost || conf.host);
conf.remoteipv4 = cli.server.remote.ipv4 != undefined ? cli.server.remote.ipv4 : (conf.remoteipv4 || conf.ipv4);
conf.remoteipv6 = cli.server.remote.ipv6 != undefined ? cli.server.remote.ipv6 : (conf.remoteipv6 || conf.ipv6);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment