Skip to content

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: #16287
Fixes: #15684
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
gibfahn authored and MylesBorins committed Oct 23, 2017
1 parent a16d314 commit 7e1a187
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/parallel/test-os.js
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 7e1a187

Please sign in to comment.