Skip to content

Commit 5095b99

Browse files
gibfahnMylesBorins
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: #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>
1 parent 62dd6a2 commit 5095b99

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
@@ -161,7 +161,11 @@ if (common.isWindows) {
161161
} else {
162162
is.number(pwd.uid);
163163
is.number(pwd.gid);
164-
assert.ok(pwd.shell.includes(path.sep));
164+
assert.strictEqual(typeof pwd.shell, 'string');
165+
// It's possible for /etc/passwd to leave the user's shell blank.
166+
if (pwd.shell.length > 0) {
167+
assert(pwd.shell.includes(path.sep));
168+
}
165169
assert.strictEqual(pwd.uid, pwdBuf.uid);
166170
assert.strictEqual(pwd.gid, pwdBuf.gid);
167171
assert.strictEqual(pwd.shell, pwdBuf.shell.toString('utf8'));

0 commit comments

Comments
 (0)