Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always make fs.Stats.uid and .gid fields unsigned #87

Merged
merged 1 commit into from
Sep 26, 2016

Conversation

addaleax
Copy link
Contributor

At the time of writing, all currently published versions of Node.js return signed 32-bit integers in their return values for the uid and gid fields of fs.Stats instances.

This is problematic, because some of Node’s other fs methods like chown expect unsigned 32-bit integer input and throw when encountering negative integers; this has broken e.g. sudo npm install -g on OS X, where nobody has a UID that would be returned as -2 by fs.stat().

Ref: nodejs/node#8515
Ref: npm/npm#13918

At the time of writing, all currently published versions of Node.js
return signed 32-bit integers in their return values for the `uid`
and `gid` fields of `fs.Stats` instances.

This is problematic, because some of Node’s other `fs` methods like
`chown` expect unsigned 32-bit integer input and throw when encountering
negative integers; this has broken e.g. `sudo npm install -g` on `OS X`,
where `nobody` has a UID that would be returned as `-2` by `fs.stat()`.

Ref: nodejs/node#8515
Ref: npm/npm#13918
@isaacs isaacs merged commit f528729 into isaacs:master Sep 26, 2016
@addaleax addaleax deleted the signed-uid-gid branch September 26, 2016 21:48
Copy link

@manjaneqx manjaneqx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔌

fs.statSync = statFixSync(fs.statSync)
fs.fstatSync = statFixSync(fs.fstatSync)
fs.lstatSync = statFixSync(fs.lstatSync)

// if lchmod/lchown do not exist, then make them no-ops

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants