Skip to content

Commit 7e1a187

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 <[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]>
1 parent a16d314 commit 7e1a187

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/parallel/test-os.js

Lines changed: 5 additions & 1 deletion
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)