Skip to content

Commit

Permalink
Don't relinquish root until *after* we actually start listening
Browse files Browse the repository at this point in the history
Fixes #118

Forgot that listen is technically async; it worked fast enough on
my system that I didn't run into issues, but was able to repro
the above issue by trying to perform the op over ssh.
  • Loading branch information
dhleong committed May 10, 2019
1 parent 1263061 commit 1a1e41b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/waker.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ Waker.prototype.requestCredentials = function(callback) {
});
dummy.once('ready', () => {
this.ui.logEvent('"PS4-Waker" device should now be available...');

// once we're listening, try to drop root privileges
if (this.ui.options['user-id'] && process.setuid) {
process.setuid(this.ui.options['user-id']);
this.ui.logEvent('Relinquished root privileges');
}
});
dummy.listen();

// once we're done, try to drop root privileges
if (this.ui.options['user-id'] && process.setuid) {
process.setuid(this.ui.options['user-id']);
this.ui.logEvent('Relinquished root privileges');
}
};

/**
Expand Down

0 comments on commit 1a1e41b

Please sign in to comment.