mirror of
https://github.com/danbulant/node-x11
synced 2026-06-16 21:21:20 +00:00
Handle nonexistent Xauthority file
This commit is contained in:
parent
582bd1a1b2
commit
86f977f9bd
1 changed files with 14 additions and 1 deletions
15
lib/auth.js
15
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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue