Skip to content

Commit

Permalink
Proper ssh key file modes and callback usage
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyman727 committed Jun 13, 2015
1 parent fc14996 commit ac90f9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions bin/tessel-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ parser.command('key')
.callback(function(opts) {
key(opts)
.then(function() {
logs.info('Key successfully generated.');
process.exit(0);
})
.catch(function(err) {
Expand Down
17 changes: 9 additions & 8 deletions lib/tessel/provision.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,17 @@ function setupLocal(callback) {

function createKeyFile(filepath, key, successString, callback) {
// Put SSH keys for Tessel in that folder
fs.writeFile(filepath, key, function(err) {
fs.writeFile(filepath, key, {
mode: '0600'
}, function(err) {
// Handle any errors that may have occurred
if (Tessel._commonErrorHandler(err)) {
if (Tessel._commonErrorHandler(err, callback)) {
return;
} else {
if (typeof callback === 'function') {
callback();
}
}

fs.chmod(filepath + '.pub', '600', function() {
logs.info(successString);
callback();
});
});
}

Expand All @@ -70,7 +71,7 @@ function setupLocal(callback) {
],
function(err) {
// Handle any errors that may have occurred
if (Tessel._commonErrorHandler(err)) {
if (Tessel._commonErrorHandler(err, callback)) {
return;
} else {
if (typeof callback === 'function') {
Expand Down

0 comments on commit ac90f9d

Please sign in to comment.