Skip to content

Instantly share code, notes, and snippets.

@orefalo
Created December 5, 2012 02:56
Show Gist options
  • Save orefalo/4211720 to your computer and use it in GitHub Desktop.
Save orefalo/4211720 to your computer and use it in GitHub Desktop.
Change node.js process owner after bind on port 80
app.listen(80, 'localhost', null, function() {
// Listening
try {
console.log('Old User ID: ' + process.getuid() + ', Old Group ID: ' + process.getgid());
process.setgid('users');
process.setuid('orefalo');
console.log('New User ID: ' + process.getuid() + ', New Group ID: ' + process.getgid());
} catch (err) {
console.log('Cowardly refusing to keep the process alive as root.');
process.exit(1);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment