Skip to content

Commit 6592987

Browse files
committed
add check for empty shell
1 parent c0ae697 commit 6592987

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

resources/lib/UnityUser.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,9 @@ public function setLoginShell($shell, $operator = null, $send_mail = true)
453453
if ($shell != trim($shell)) {
454454
throw new Exception("leading/trailing whitespace is not allowed in a login shell!");
455455
}
456+
if (empty($shell)) {
457+
throw new Exception("login shell must not be empty!");
458+
}
456459
$ldapUser = $this->getLDAPUser();
457460
if ($ldapUser->exists()) {
458461
$ldapUser->setAttribute("loginshell", $shell);

test/functional/LoginShellSetTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ public function testSetLoginShellCustom(string $shell): void
3333
{
3434
global $USER;
3535
// FIXME add check to avoid warning from ldap_modify
36-
if (!mb_check_encoding($shell, 'ASCII')) {
37-
$this->expectException("Exception");
38-
}
39-
if ($shell != trim($shell)) {
36+
if (
37+
(!mb_check_encoding($shell, 'ASCII')) ||
38+
($shell != trim($shell)) ||
39+
(empty($shell))
40+
) {
4041
$this->expectException("Exception");
4142
}
4243
// FIXME shell is not validated

0 commit comments

Comments
 (0)