diff --git a/lib/auth.js b/lib/auth.js index 95b948f..264a3f2 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -60,7 +60,13 @@ function readXauthority(cb) { if(err.code == 'ENOENT') { // Xming/windows uses %HOME%/Xauthority ( .Xauthority with no dot ) - try with this name filename = process.env.XAUTHORITY || path.join(homedir(), 'Xauthority'); - return fs.readFile(filename, cb); + fs.readFile(filename, function (err, data) { + if (err.code == 'ENOENT') { + cb(null, null); + } else { + cb(err); + } + }); } else { cb(err); } @@ -72,6 +78,13 @@ module.exports = function( display, host, cb ) readXauthority(function(err, data) { if(err) return cb(err); + if (!data) { + return cb(null, { + authName: '', + authData: '' + }); + } + var auth = parseXauth(data); for (var cookieNum in auth) {