Handle nonexistent Xauthority file

This commit is contained in:
Ian Scott 2016-01-28 16:35:04 -08:00
parent 582bd1a1b2
commit 86f977f9bd

View file

@ -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)
{