Created
December 5, 2012 02:56
-
-
Save orefalo/4211720 to your computer and use it in GitHub Desktop.
Change node.js process owner after bind on port 80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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