Skip to content
This repository has been archived by the owner on Aug 31, 2018. It is now read-only.

Commit

Permalink
test: handle blank shells in test-os.js
Browse files Browse the repository at this point in the history
The shell in /etc/passwd can be blank, in which case the user is given
the default shell. Handle this by only checking the shell contains a
path separator if the string isn't empty.

PR-URL: nodejs/node#16287
Fixes: nodejs/node#15684
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
gibfahn authored and addaleax committed Oct 26, 2017
1 parent 7f88b4d commit d40d48e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/parallel/test-os.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ if (common.isWindows) {
} else {
is.number(pwd.uid);
is.number(pwd.gid);
assert.ok(pwd.shell.includes(path.sep));
assert.strictEqual(typeof pwd.shell, 'string');
// It's possible for /etc/passwd to leave the user's shell blank.
if (pwd.shell.length > 0) {
assert(pwd.shell.includes(path.sep));
}
assert.strictEqual(pwd.uid, pwdBuf.uid);
assert.strictEqual(pwd.gid, pwdBuf.gid);
assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8'));
Expand Down

0 comments on commit d40d48e

Please sign in to comment.