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

Commit a2ec683

Browse files
gibfahnaddaleax
authored andcommitted
test: handle blank shells in test-os.js
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 <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>
1 parent 1aa1c59 commit a2ec683

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/parallel/test-os.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,11 @@ if (common.isWindows) {
208208
} else {
209209
is.number(pwd.uid);
210210
is.number(pwd.gid);
211-
assert.ok(pwd.shell.includes(path.sep));
211+
assert.strictEqual(typeof pwd.shell, 'string');
212+
// It's possible for /etc/passwd to leave the user's shell blank.
213+
if (pwd.shell.length > 0) {
214+
assert(pwd.shell.includes(path.sep));
215+
}
212216
assert.strictEqual(pwd.uid, pwdBuf.uid);
213217
assert.strictEqual(pwd.gid, pwdBuf.gid);
214218
assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8'));

0 commit comments

Comments
 (0)