mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
Add an option to select the Fix-it tty. The current behavior is utterly
*useless* on serial consoled machines.
This commit is contained in:
parent
40316fa981
commit
9ee6ec34ef
8 changed files with 102 additions and 27 deletions
|
|
@ -398,17 +398,20 @@ fixit_common(void)
|
|||
if (!file_readable(TERMCAP_FILE))
|
||||
create_termcap();
|
||||
if (!(child = fork())) {
|
||||
int i, fd;
|
||||
int i, fd, fdstop;
|
||||
struct termios foo;
|
||||
extern int login_tty(int);
|
||||
|
||||
ioctl(0, TIOCNOTTY, NULL);
|
||||
for (i = getdtablesize(); i >= 0; --i)
|
||||
fdstop = strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0 ? 3 : 0;
|
||||
for (i = getdtablesize(); i >= fdstop; --i)
|
||||
close(i);
|
||||
fd = open("/dev/ttyv3", O_RDWR);
|
||||
ioctl(0, TIOCSCTTY, &fd);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
|
||||
fd = open("/dev/ttyv3", O_RDWR);
|
||||
ioctl(0, TIOCSCTTY, &fd);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
}
|
||||
DebugFD = 2;
|
||||
if (login_tty(fd) == -1)
|
||||
msgDebug("fixit: I can't set the controlling terminal.\n");
|
||||
|
|
@ -432,9 +435,15 @@ fixit_common(void)
|
|||
}
|
||||
else {
|
||||
dialog_clear_norefresh();
|
||||
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
|
||||
"typing ALT-F4. When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
|
||||
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
|
||||
"typing ALT-F4. When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
} else {
|
||||
msgNotify("Waiting for fixit shell to exit.\n"
|
||||
"When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
}
|
||||
(void)waitpid(child, &waitstatus, 0);
|
||||
}
|
||||
dialog_clear();
|
||||
|
|
@ -1086,6 +1095,7 @@ installVarDefaults(dialogMenuItem *self)
|
|||
variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0);
|
||||
variable_set2(VAR_FTP_STATE, "passive", 0);
|
||||
variable_set2(VAR_NFS_SECURE, "NO", -1);
|
||||
variable_set2(VAR_FIXIT_TTY, "standard", 0);
|
||||
variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
|
||||
variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0);
|
||||
if (getpid() != 1)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
#include "sysinstall.h"
|
||||
#include <ctype.h>
|
||||
|
||||
int fixitTtyWhich(dialogMenuItem *);
|
||||
|
||||
static char *
|
||||
varCheck(Option opt)
|
||||
{
|
||||
|
|
@ -140,6 +142,8 @@ static Option Options[] = {
|
|||
OPT_IS_VAR, PKG_PROMPT, VAR_PKG_TMPDIR, varCheck },
|
||||
{ "Newfs Args", "Default parameters for newfs(8)",
|
||||
OPT_IS_VAR, NEWFS_PROMPT, VAR_NEWFS_ARGS, varCheck },
|
||||
{ "Fixit Console", "Which tty to use for the Fixit action.",
|
||||
OPT_IS_FUNC, fixitTtyWhich, VAR_FIXIT_TTY, varCheck },
|
||||
{ "Config save", "Whether or not to save installation kernel config changes",
|
||||
OPT_IS_VAR, NULL, VAR_KGET, varCheck },
|
||||
{ "Re-scan Devices", "Re-run sysinstall's initial device probe",
|
||||
|
|
@ -310,3 +314,20 @@ optionsEditor(dialogMenuItem *self)
|
|||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
fixitTtyWhich(dialogMenuItem *self)
|
||||
{
|
||||
char *cp = variable_get(VAR_FIXIT_TTY);
|
||||
|
||||
if (!cp) {
|
||||
msgConfirm("The Fix-it TTY setting is not set to anything!");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
else {
|
||||
if (!strcmp(cp, "standard"))
|
||||
variable_set2(VAR_FIXIT_TTY, "serial", 0);
|
||||
else /* must be "serial" - wrap around */
|
||||
variable_set2(VAR_FIXIT_TTY, "standard", 0);
|
||||
}
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
#define VAR_EXTRAS "ifconfig_"
|
||||
#define VAR_COMMAND "command"
|
||||
#define VAR_CONFIG_FILE "configFile"
|
||||
#define VAR_FIXIT_TTY "fixitTty"
|
||||
#define VAR_FTP_DIR "ftpDirectory"
|
||||
#define VAR_FTP_PASS "ftpPass"
|
||||
#define VAR_FTP_PATH "_ftpPath"
|
||||
|
|
|
|||
|
|
@ -398,17 +398,20 @@ fixit_common(void)
|
|||
if (!file_readable(TERMCAP_FILE))
|
||||
create_termcap();
|
||||
if (!(child = fork())) {
|
||||
int i, fd;
|
||||
int i, fd, fdstop;
|
||||
struct termios foo;
|
||||
extern int login_tty(int);
|
||||
|
||||
ioctl(0, TIOCNOTTY, NULL);
|
||||
for (i = getdtablesize(); i >= 0; --i)
|
||||
fdstop = strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0 ? 3 : 0;
|
||||
for (i = getdtablesize(); i >= fdstop; --i)
|
||||
close(i);
|
||||
fd = open("/dev/ttyv3", O_RDWR);
|
||||
ioctl(0, TIOCSCTTY, &fd);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
|
||||
fd = open("/dev/ttyv3", O_RDWR);
|
||||
ioctl(0, TIOCSCTTY, &fd);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
}
|
||||
DebugFD = 2;
|
||||
if (login_tty(fd) == -1)
|
||||
msgDebug("fixit: I can't set the controlling terminal.\n");
|
||||
|
|
@ -432,9 +435,15 @@ fixit_common(void)
|
|||
}
|
||||
else {
|
||||
dialog_clear_norefresh();
|
||||
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
|
||||
"typing ALT-F4. When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
|
||||
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
|
||||
"typing ALT-F4. When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
} else {
|
||||
msgNotify("Waiting for fixit shell to exit.\n"
|
||||
"When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
}
|
||||
(void)waitpid(child, &waitstatus, 0);
|
||||
}
|
||||
dialog_clear();
|
||||
|
|
@ -1086,6 +1095,7 @@ installVarDefaults(dialogMenuItem *self)
|
|||
variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0);
|
||||
variable_set2(VAR_FTP_STATE, "passive", 0);
|
||||
variable_set2(VAR_NFS_SECURE, "NO", -1);
|
||||
variable_set2(VAR_FIXIT_TTY, "standard", 0);
|
||||
variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
|
||||
variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0);
|
||||
if (getpid() != 1)
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
#define VAR_EXTRAS "ifconfig_"
|
||||
#define VAR_COMMAND "command"
|
||||
#define VAR_CONFIG_FILE "configFile"
|
||||
#define VAR_FIXIT_TTY "fixitTty"
|
||||
#define VAR_FTP_DIR "ftpDirectory"
|
||||
#define VAR_FTP_PASS "ftpPass"
|
||||
#define VAR_FTP_PATH "_ftpPath"
|
||||
|
|
|
|||
|
|
@ -398,17 +398,20 @@ fixit_common(void)
|
|||
if (!file_readable(TERMCAP_FILE))
|
||||
create_termcap();
|
||||
if (!(child = fork())) {
|
||||
int i, fd;
|
||||
int i, fd, fdstop;
|
||||
struct termios foo;
|
||||
extern int login_tty(int);
|
||||
|
||||
ioctl(0, TIOCNOTTY, NULL);
|
||||
for (i = getdtablesize(); i >= 0; --i)
|
||||
fdstop = strcmp(variable_get(VAR_FIXIT_TTY), "serial") == 0 ? 3 : 0;
|
||||
for (i = getdtablesize(); i >= fdstop; --i)
|
||||
close(i);
|
||||
fd = open("/dev/ttyv3", O_RDWR);
|
||||
ioctl(0, TIOCSCTTY, &fd);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
|
||||
fd = open("/dev/ttyv3", O_RDWR);
|
||||
ioctl(0, TIOCSCTTY, &fd);
|
||||
dup2(0, 1);
|
||||
dup2(0, 2);
|
||||
}
|
||||
DebugFD = 2;
|
||||
if (login_tty(fd) == -1)
|
||||
msgDebug("fixit: I can't set the controlling terminal.\n");
|
||||
|
|
@ -432,9 +435,15 @@ fixit_common(void)
|
|||
}
|
||||
else {
|
||||
dialog_clear_norefresh();
|
||||
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
|
||||
"typing ALT-F4. When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
if (strcmp(variable_get(VAR_FIXIT_TTY), "standard") == 0) {
|
||||
msgNotify("Waiting for fixit shell to exit. Go to VTY4 now by\n"
|
||||
"typing ALT-F4. When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
} else {
|
||||
msgNotify("Waiting for fixit shell to exit.\n"
|
||||
"When you are done, type ``exit'' to exit\n"
|
||||
"the fixit shell and be returned here.");
|
||||
}
|
||||
(void)waitpid(child, &waitstatus, 0);
|
||||
}
|
||||
dialog_clear();
|
||||
|
|
@ -1086,6 +1095,7 @@ installVarDefaults(dialogMenuItem *self)
|
|||
variable_set2(VAR_BROWSER_BINARY, "/usr/local/bin/lynx", 0);
|
||||
variable_set2(VAR_FTP_STATE, "passive", 0);
|
||||
variable_set2(VAR_NFS_SECURE, "NO", -1);
|
||||
variable_set2(VAR_FIXIT_TTY, "standard", 0);
|
||||
variable_set2(VAR_PKG_TMPDIR, "/usr/tmp", 0);
|
||||
variable_set2(VAR_MEDIA_TIMEOUT, itoa(MEDIA_TIMEOUT), 0);
|
||||
if (getpid() != 1)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@
|
|||
#include "sysinstall.h"
|
||||
#include <ctype.h>
|
||||
|
||||
int fixitTtyWhich(dialogMenuItem *);
|
||||
|
||||
static char *
|
||||
varCheck(Option opt)
|
||||
{
|
||||
|
|
@ -140,6 +142,8 @@ static Option Options[] = {
|
|||
OPT_IS_VAR, PKG_PROMPT, VAR_PKG_TMPDIR, varCheck },
|
||||
{ "Newfs Args", "Default parameters for newfs(8)",
|
||||
OPT_IS_VAR, NEWFS_PROMPT, VAR_NEWFS_ARGS, varCheck },
|
||||
{ "Fixit Console", "Which tty to use for the Fixit action.",
|
||||
OPT_IS_FUNC, fixitTtyWhich, VAR_FIXIT_TTY, varCheck },
|
||||
{ "Config save", "Whether or not to save installation kernel config changes",
|
||||
OPT_IS_VAR, NULL, VAR_KGET, varCheck },
|
||||
{ "Re-scan Devices", "Re-run sysinstall's initial device probe",
|
||||
|
|
@ -310,3 +314,20 @@ optionsEditor(dialogMenuItem *self)
|
|||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
||||
int
|
||||
fixitTtyWhich(dialogMenuItem *self)
|
||||
{
|
||||
char *cp = variable_get(VAR_FIXIT_TTY);
|
||||
|
||||
if (!cp) {
|
||||
msgConfirm("The Fix-it TTY setting is not set to anything!");
|
||||
return DITEM_FAILURE;
|
||||
}
|
||||
else {
|
||||
if (!strcmp(cp, "standard"))
|
||||
variable_set2(VAR_FIXIT_TTY, "serial", 0);
|
||||
else /* must be "serial" - wrap around */
|
||||
variable_set2(VAR_FIXIT_TTY, "standard", 0);
|
||||
}
|
||||
return DITEM_SUCCESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@
|
|||
#define VAR_EXTRAS "ifconfig_"
|
||||
#define VAR_COMMAND "command"
|
||||
#define VAR_CONFIG_FILE "configFile"
|
||||
#define VAR_FIXIT_TTY "fixitTty"
|
||||
#define VAR_FTP_DIR "ftpDirectory"
|
||||
#define VAR_FTP_PASS "ftpPass"
|
||||
#define VAR_FTP_PATH "_ftpPath"
|
||||
|
|
|
|||
Loading…
Reference in a new issue