Skip to content

Commit ec41697

Browse files
3cptschaub
authored andcommitted
fix: uid 0 means root on POSIX, but not on Windows
1 parent ae38cfe commit ec41697

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/item.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Item.prototype.canRead = function() {
108108
const uid = getUid();
109109
const gid = getGid();
110110
let can = false;
111-
if (uid === 0) {
111+
if (process.getuid && uid === 0) {
112112
can = true;
113113
} else if (uid === this._uid) {
114114
can = (permissions.USER_READ & this._mode) === permissions.USER_READ;
@@ -128,7 +128,7 @@ Item.prototype.canWrite = function() {
128128
const uid = getUid();
129129
const gid = getGid();
130130
let can = false;
131-
if (uid === 0) {
131+
if (process.getuid && uid === 0) {
132132
can = true;
133133
} else if (uid === this._uid) {
134134
can = (permissions.USER_WRITE & this._mode) === permissions.USER_WRITE;
@@ -148,7 +148,7 @@ Item.prototype.canExecute = function() {
148148
const uid = getUid();
149149
const gid = getGid();
150150
let can = false;
151-
if (uid === 0) {
151+
if (process.getuid && uid === 0) {
152152
can = true;
153153
} else if (uid === this._uid) {
154154
can = (permissions.USER_EXEC & this._mode) === permissions.USER_EXEC;

0 commit comments

Comments
 (0)