Skip to content

Commit b45d48b

Browse files
committed
remove custom login shell
1 parent d189ab6 commit b45d48b

File tree

2 files changed

+5
-83
lines changed

2 files changed

+5
-83
lines changed

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"

webroot/panel/account.php

Lines changed: 4 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@
6969
$USER->setSSHKeys($keys, $OPERATOR); // Update user keys
7070
break;
7171
case "loginshell":
72-
if ($_POST["shellSelect"] == "Custom") {
73-
$USER->setLoginShell($_POST["shell"], $OPERATOR);
74-
} else {
75-
$USER->setLoginShell($_POST["shellSelect"], $OPERATOR);
76-
}
72+
$USER->setLoginShell($_POST["shellSelect"], $OPERATOR);
7773
break;
7874
case "pi_request":
7975
if (!$USER->isPI()) {
@@ -210,19 +206,8 @@
210206
foreach ($CONFIG["loginshell"]["shell"] as $shell) {
211207
echo "<option>$shell</option>";
212208
}
213-
echo "<option id='customLoginSelectorOption'>Custom</option>";
214209
?>
215210
</select>
216-
<?php
217-
echo "
218-
<input
219-
id='customLoginBox'
220-
type='text'
221-
placeholder='Enter login shell path (ie. /bin/bash)'
222-
name='shell'
223-
/>
224-
";
225-
?>
226211
<br>
227212
<input id='submitLoginShell' type='submit' value='Set Login Shell' />
228213
<label id='labelSubmitLoginShell'> <!-- value set by JS --> </label>
@@ -266,83 +251,19 @@
266251
openModal("Add New Key", `${sitePrefix}/panel/modal/new_key.php`);
267252
});
268253

269-
var defaultShellSelected = false;
270254
$("#loginSelector option").each(function(i, e) {
271255
if ($(this).val() == ldapLoginShell) {
272256
$(this).prop("selected", true);
273-
defaultShellSelected = true;
274257
}
275258
});
276-
if (!defaultShellSelected) {
277-
$("#customLoginBox").val(ldapLoginShell);
278-
$("#customLoginSelectorOption").prop("selected", true);
279-
}
280-
281-
function showOrHideCustomLoginBox() {
282-
var customBox = $("#customLoginBox");
283-
if($("#loginSelector").val() == "Custom") {
284-
customBox.show();
285-
} else {
286-
customBox.hide();
287-
}
288-
}
289-
$("#loginSelector").change(showOrHideCustomLoginBox);
290-
showOrHideCustomLoginBox();
291-
292-
function getNewLoginShell() {
293-
var loginSelectorVal = $("#loginSelector").val();
294-
if (loginSelectorVal != "Custom") {
295-
return loginSelectorVal;
296-
}
297-
return $("#customLoginBox").val();
298-
}
299-
300-
function isLoginShellValid(x) {
301-
if (/^\s|\s$/.test(x)) {
302-
return [false, "must not have leading or trailing whitespace"];
303-
}
304-
if (x.length === 0) {
305-
return [false, "must not be empty"];
306-
}
307-
if (!(/^[\x00-\x7F]*$/.test(x))) {
308-
return [false, "must only contain ASCII characters"];
309-
}
310-
return [true, ""];
311-
}
312-
313-
function enableOrDisableCustomLoginBoxHighlight() {
314-
if (
315-
($("#customLoginSelectorOption").prop("selected") == true) &&
316-
!isLoginShellValid($("#customLoginBox").val())
317-
) {
318-
$("#customLoginBox").css("box-shadow", "0 0 0 0.3rem rgba(220, 53, 69, 0.25)");
319-
} else {
320-
$("#customLoginBox").css("box-shadow", "none");
321-
}
322-
}
323-
$("#customLoginBox").on("input", enableOrDisableCustomLoginBoxHighlight);
324-
$("#loginSelector").change(enableOrDisableCustomLoginBoxHighlight);
325-
enableOrDisableCustomLoginBoxHighlight();
326259

327260
function enableOrDisableSubmitLoginShell() {
328-
var newLoginShell = getNewLoginShell();
329-
isValidArr = isLoginShellValid(newLoginShell);
330-
isValid = isValidArr[0];
331-
isValidReason = isValidArr[1];
332-
if (!isValid) {
261+
if ($("#loginSelector").val() == ldapLoginShell) {
333262
$("#submitLoginShell").prop("disabled", true);
334-
$("#labelSubmitLoginShell").text(`(invalid login shell: ${isValidReason})`);
335-
return;
336-
}
337-
if (newLoginShell == ldapLoginShell) {
338-
$("#submitLoginShell").prop("disabled", true);
339-
$("#labelSubmitLoginShell").text("(no change)");
340-
return;
263+
} else {
264+
$("#submitLoginShell").prop("disabled", false);
341265
}
342-
$("#submitLoginShell").prop("disabled", false);
343-
$("#labelSubmitLoginShell").text("");
344266
}
345-
$("#customLoginBox").on("input", enableOrDisableSubmitLoginShell);
346267
$("#loginSelector").change(enableOrDisableSubmitLoginShell);
347268
enableOrDisableSubmitLoginShell()
348269
</script>

0 commit comments

Comments
 (0)