Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions lib/handshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ function sha1 (input) {
return shasum.digest('hex');
}

function getUserHome () {
function getUid() {
if ('DBUS_UID' in process.env)
return Number(process.env.DBUS_UID);
if ('getuid' in process)
return process.getuid();
return null
}

function getUserHome() {
return process.env[process.platform.match(/$win/) ? 'USERPROFILE' : 'HOME'];
}

Expand All @@ -33,7 +41,8 @@ function getCookie (context, id, cb) {
)
);
}
if ('getuid' in process && stat.uid !== process.getuid()) {
const uid = getUid();
if (uid !== null && stat.uid !== uid) {
return cb(
new Error(
'Keyrings directory is not owned by the current user. Aborting authentication!'
Expand Down Expand Up @@ -74,7 +83,7 @@ function tryAuth (stream, methods, cb) {
}

const authMethod = methods.shift();
const uid = 'getuid' in process ? process.getuid() : 0;
const uid = getUid() || 0;
const id = hexlify(uid);

function beginOrNextAuth () {
Expand Down