Skip to content

Commit c5a9f1c

Browse files
committed
Merge branch 'main' into testing6
2 parents e21f6c2 + 8814abd commit c5a9f1c

File tree

12 files changed

+177
-213
lines changed

12 files changed

+177
-213
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ The following users are available for testing:
5151

5252
### Changes to Dev Environment
5353

54-
Should the default schema of the web portal change, the `ldap/bootstrap.ldif` and `sql/bootstrap.sql` must be updated for the LDAP server and the MySQL server, respectively.
54+
Should the default schema of the web portal change, the `ldap/bootstrap.ldif` and `sql/bootstrap.sql` must be updated for the LDAP server and the MySQL server, respectively.

defaults/config.ini.default

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ title[] = "Test Medium Footer"
7575
[loginshell] ; Login shells that show up as options in the account settings page
7676
shell[] = "/bin/bash"
7777
shell[] = "/bin/zsh"
78+
shell[] = "/bin/tcsh"
7879

7980
[menuitems] ; menu items, add a label and link for each
8081
labels[] = "Global Menuitem 1"

resources/lib/UnityGroup.php

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -198,44 +198,44 @@ public function denyGroup($operator = null, $send_mail = true)
198198
}
199199
}
200200

201-
/**
202-
* This method will delete the group, either by admin action or PI action
203-
*/
204-
public function removeGroup($send_mail = true)
205-
{
206-
// remove any pending requests
207-
// this will silently fail if the request doesn't exist (which is what we want)
208-
$this->SQL->removeRequests($this->pi_uid);
209-
210-
// we don't need to do anything extra if the group is already deleted
211-
if (!$this->exists()) {
212-
return;
213-
}
214-
215-
// first, we must record the users in the group currently
216-
$users = $this->getGroupMembers();
217-
218-
// now we delete the ldap entry
219-
$ldapPiGroupEntry = $this->getLDAPPiGroup();
220-
if ($ldapPiGroupEntry->exists()) {
221-
$ldapPiGroupEntry->delete();
222-
$this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID());
223-
foreach ($users as $user) {
224-
$this->REDIS->removeCacheArray($user->getUID(), "groups", $this->getPIUID());
225-
}
226-
}
227-
228-
// send email to every user of the now deleted PI group
229-
if ($send_mail) {
230-
foreach ($users as $user) {
231-
$this->MAILER->sendMail(
232-
$user->getMail(),
233-
"group_disband",
234-
array("group_name" => $this->pi_uid)
235-
);
236-
}
237-
}
238-
}
201+
// /**
202+
// * This method will delete the group, either by admin action or PI action
203+
// */
204+
// public function removeGroup($send_mail = true)
205+
// {
206+
// // remove any pending requests
207+
// // this will silently fail if the request doesn't exist (which is what we want)
208+
// $this->SQL->removeRequests($this->pi_uid);
209+
210+
// // we don't need to do anything extra if the group is already deleted
211+
// if (!$this->exists()) {
212+
// return;
213+
// }
214+
215+
// // first, we must record the users in the group currently
216+
// $users = $this->getGroupMembers();
217+
218+
// // now we delete the ldap entry
219+
// $ldapPiGroupEntry = $this->getLDAPPiGroup();
220+
// if ($ldapPiGroupEntry->exists()) {
221+
// $ldapPiGroupEntry->delete();
222+
// $this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID());
223+
// foreach ($users as $user) {
224+
// $this->REDIS->removeCacheArray($user->getUID(), "groups", $this->getPIUID());
225+
// }
226+
// }
227+
228+
// // send email to every user of the now deleted PI group
229+
// if ($send_mail) {
230+
// foreach ($users as $user) {
231+
// $this->MAILER->sendMail(
232+
// $user->getMail(),
233+
// "group_disband",
234+
// array("group_name" => $this->pi_uid)
235+
// );
236+
// }
237+
// }
238+
// }
239239

240240
/**
241241
* This method is executed when a user is approved to join the group (either by admin or the group owner)

resources/lib/UnityUser.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,16 @@ public function getSSHKeys($ignorecache = false)
424424
*/
425425
public function setLoginShell($shell, $operator = null, $send_mail = true)
426426
{
427-
// FIXME throw error if shell is not ascii
428427
// ldap schema syntax is "IA5 String (1.3.6.1.4.1.1466.115.121.1.26)"
428+
if (!mb_check_encoding($shell, 'ASCII')) {
429+
throw new Exception("non ascii characters are not allowed in a login shell!");
430+
}
431+
if ($shell != trim($shell)) {
432+
throw new Exception("leading/trailing whitespace is not allowed in a login shell!");
433+
}
434+
if (empty($shell)) {
435+
throw new Exception("login shell must not be empty!");
436+
}
429437
$ldapUser = $this->getLDAPUser();
430438
if ($ldapUser->exists()) {
431439
$ldapUser->setAttribute("loginshell", $shell);

test/functional/LoginShellSetTest.php

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,22 @@ public static function getShells()
2626
return [["/bin/bash"]] + array_map(function($x){return [$x];}, $HTTP_HEADER_TEST_INPUTS);
2727
}
2828

29-
#[DataProvider("getShells")]
30-
public function testSetLoginShellCustom(string $shell): void
29+
private function isShellValid(string $shell)
3130
{
32-
global $USER;
33-
// FIXME add check to avoid warning from ldap_modify
34-
if (!mb_check_encoding($shell, 'ASCII')) {
35-
$this->expectException("Exception");
36-
}
37-
// FIXME shell is not validated
38-
post(
39-
__DIR__ . "/../../webroot/panel/account.php",
40-
["form_type" => "loginshell", "shellSelect" => "custom", "shell" => $shell]
31+
return (
32+
(mb_check_encoding($shell, 'ASCII')) &&
33+
($shell == trim($shell)) &&
34+
(!empty($shell))
4135
);
42-
$this->assertEquals($shell, $USER->getLoginShell());
4336
}
4437

4538
#[DataProvider("getShells")]
46-
public function testSetLoginShellSelect(string $shell): void
39+
public function testSetLoginShell(string $shell): void
4740
{
4841
global $USER;
49-
// FIXME add check to avoid warning from ldap_modify
50-
if (!mb_check_encoding($shell, 'ASCII')) {
51-
$this->expectException(RuntimeException::class);
42+
if (!$this->isShellValid($shell)) {
43+
$this->expectException("Exception");
5244
}
53-
// FIXME shell is not validated
5445
post(
5546
__DIR__ . "/../../webroot/panel/account.php",
5647
["form_type" => "loginshell", "shellSelect" => $shell]

webroot/admin/pi-mgmt.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
$group->denyGroup($OPERATOR);
2727
}
2828

29-
break;
30-
case "remGroup":
31-
$remGroup = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
32-
$remGroup->removeGroup();
33-
3429
break;
3530
case "reqChild":
3631
$parent_group = new UnityGroup($_POST["pi"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK);
@@ -128,15 +123,6 @@
128123
" " . $pi_user->getLastname() . "</td>";
129124
echo "<td>" . $pi_group->getPIUID() . "</td>";
130125
echo "<td><a href='mailto:" . $pi_user->getMail() . "'>" . $pi_user->getMail() . "</a></td>";
131-
echo "<td>";
132-
echo
133-
"<form action='' method='POST'
134-
onsubmit='return confirm(\"Are you sure you want to remove " . $pi_group->getPIUID() . "?\")'>
135-
<input type='hidden' name='form_name' value='remGroup'>
136-
<input type='hidden' name='pi' value='" . $pi_group->getPIUID() . "'>
137-
<input type='submit' value='Remove'>
138-
</form>";
139-
echo "</td>";
140126
echo "</tr>";
141127
}
142128
?>

webroot/css/global.css

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ code {
2828
line-height: 22pt;
2929
}
3030

31+
.code {
32+
background: var(--light_panel_background);
33+
line-height: 22pt;
34+
font-family: monospace
35+
}
36+
3137
a {
3238
color: var(--accent);
3339
text-decoration: none;
@@ -98,14 +104,16 @@ p {
98104
transform: translateY(-50%);
99105
}
100106

101-
button.plusBtn {
107+
button.plusBtn span{
102108
font-size: 24pt;
103-
display: block;
109+
font-family: monospace;
110+
}
111+
112+
button.plusBtn{
104113
width: 100%;
105114
max-width: 200px;
106115
padding: 0;
107116
overflow: hidden;
108-
margin-top: 10px;
109117
}
110118

111119
/* Form Elements */
@@ -184,8 +192,7 @@ input[type=radio] {
184192
select {
185193
border: 1px solid var(--light_borders);
186194
background: white;
187-
padding: 5px;
188-
width: 100%;
195+
padding: 5px 10px 5px 20px;
189196
max-width: 300px;
190197
border-radius: 5px;
191198
}
@@ -335,4 +342,4 @@ div.searchWrapper>* {
335342

336343
div.searchWrapper>*:hover {
337344
background: var(--light_panel_background);
338-
}
345+
}

webroot/css/tables.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ table.longTable tr:not(:last-child) {
1616

1717
table tr,
1818
table td {
19-
padding: 8px 20px 8px 4px;
19+
padding: 0 20px 0 4px;
2020
overflow: hidden;
2121
white-space: nowrap;
2222
}
@@ -139,4 +139,4 @@ tr.key>td:first-child {
139139
tr.key>td:last-child {
140140
border-top-right-radius: 10px;
141141
border-bottom-right-radius: 10px;
142-
}
142+
}

webroot/js/ajax/ssh_validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

33
require_once __DIR__ . "/../../../resources/lib/UnitySite.php";
4+
require_once __DIR__ . "/../../../vendor/autoload.php";
45

56
echo UnityWebPortal\lib\UnitySite::testValidSSHKey($_POST["key"]) ? "true" : "false";

0 commit comments

Comments
 (0)