Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A C++ add-on for Node.js to enable simple daemons in Javascript plus some useful wrappers in Javascript.
curl http://npmjs.org/install.sh | sh
[sudo] npm install daemon
node-waf configure build
There is a great getting started article on daemons and node.js by Slashed that you can read here. The API has changed slightly from that version thanks to contributions from ptge and fugue; there is no longer a daemon.closeIO() method, this is done automatically for you.
Starting a daemon is easy, just call daemon.start() and daemon.lock().
var daemon = require('daemon');
// Your awesome code here
fs.open('somefile.log', 'w+', function (err, fd) {
daemon.start(fd);
daemon.lock('/tmp/yourprogram.pid');
});
This library also exposes a higher level facility through javascript for starting daemons:
var daemon = require('daemon');
//
// Your awesome code here
//
daemon.daemonize({ stdout: 'somefile.log', stderr: 'error.log' }, '/tmp/yourprogram.pid', function (err, pid) {
//
// We are now in the daemon process
//
if (err) {
return console.log('Error starting daemon: ' + err);
}
console.log('Daemon started successfully with pid: ' + pid);
});
If you wish you can also simply pass a single pass which you wish to be used for both stdout
and stderr
:
var daemon = require('daemon');
//
// Your awesome code here
//
daemon.daemonize('stdout-and-stderr.log', '/tmp/yourprogram.pid', function (err, pid) {
//
// We are now in the daemon process
//
if (err) {
return console.log('Error starting daemon: ' + err);
}
console.log('Daemon started successfully with pid: ' + pid);
});
Takes two file descriptors, one for stdout
and one for stderr
. If only stdout
is supplied, stderr
will use the same fd. If no arguments are passed, stdout
and stderr
output will be sent to /dev/null
.
Closes stdin and reopens fd as /dev/null.
Closes stdout and reopens fd as /dev/null.
Closes stderr and reopens fd as /dev/null.
Closes std[in|out|err] and reopens fd as /dev/null.
Try to lock the file. If it's unable to OPEN the file it will exit. If it's unable to get a LOCK on the file it will return false. Else it will return true.
Starts a new session for the process. Returns the SID as an integer.
Attempts to chroot the process, returns exception on error, returns true on success.
Change the effective user of the process. Can take either an integer (UID) or a string (Username). Returns exceptions on error and true on success.
This library is available under the MIT LICENSE. See the LICENSE file for more details. It was created by Slashed and forked / improved / hacked upon by a lot of good people. Special thanks to Isaacs for npm and a great example in glob.
FAQs
Add-on for creating *nix daemons
We found that daemon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.