Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
d28b79a9
Commit
d28b79a9
authored
Nov 28, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: improve writing etc/ttys even more to disable virtual
parent
1b442b8e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
13 deletions
+20
-13
system.inc
src/etc/inc/system.inc
+20
-13
No files found.
src/etc/inc/system.inc
View file @
d28b79a9
...
...
@@ -1588,7 +1588,6 @@ function system_login_configure()
configd_run
(
'template reload OPNsense/Auth'
);
$serialspeed
=
(
!
empty
(
$config
[
'system'
][
'serialspeed'
])
&&
is_numeric
(
$config
[
'system'
][
'serialspeed'
]))
?
$config
[
'system'
][
'serialspeed'
]
:
'115200'
;
$serial_enabled
=
false
;
$new_boot_config
=
array
();
$new_boot_config
[
'comconsole_speed'
]
=
null
;
...
...
@@ -1602,13 +1601,14 @@ function system_login_configure()
foreach
(
array
(
'primaryconsole'
,
'secondaryconsole'
)
as
$console_order
)
{
if
(
!
empty
(
$config
[
'system'
][
$console_order
])
&&
isset
(
$console_types
[
$config
[
'system'
][
$console_order
]]))
{
$console_selection
[]
=
$console_types
[
$config
[
'system'
][
$console_order
]][
'value'
];
if
(
$config
[
'system'
][
$console_order
]
==
'serial'
)
{
/* make sure serial is enabled when selected, but not by checkbox */
$serial_enabled
=
true
;
}
}
}
$output_enabled
=
count
(
$console_selection
)
!=
1
||
in_array
(
'nullconsole'
,
$console_selection
);
$virtual_enabled
=
!
count
(
$console_selection
)
||
in_array
(
'vidconsole'
,
$console_selection
)
||
in_array
(
'efi'
,
$console_selection
);
$serial_enabled
=
in_array
(
'comconsole'
,
$console_selection
);
$console_selection
=
array_unique
(
$console_selection
);
$new_boot_config
[
'console'
]
=
'"'
.
implode
(
','
,
$console_selection
)
.
'"'
;
if
(
count
(
$console_selection
)
>=
2
)
{
...
...
@@ -1619,7 +1619,7 @@ function system_login_configure()
@
file_put_contents
(
'/boot.config'
,
"-S
{
$serialspeed
}
-D
\n
"
);
$new_boot_config
[
'comconsole_speed'
]
=
'"'
.
$serialspeed
.
'"'
;
$new_boot_config
[
'boot_serial'
]
=
'"YES"'
;
}
elseif
(
count
(
$console_selection
)
==
1
&&
$console_selection
[
0
]
==
'nullconsole'
)
{
}
elseif
(
!
$output_enabled
)
{
@
file_put_contents
(
'/boot.config'
,
"-q -m
\n
"
);
}
else
{
@
unlink
(
'/boot.config'
);
...
...
@@ -1644,10 +1644,11 @@ function system_login_configure()
/* write merged file back to target location */
@
file_put_contents
(
'/boot/loader.conf'
,
$new_loader_conf
);
/
/ ** setup /etc/ttys
/
* setup /etc/ttys */
$etc_ttys_lines
=
explode
(
"
\n
"
,
file_get_contents
(
'/etc/ttys'
));
$fd
=
fopen
(
'/etc/ttys'
,
'w'
);
$on_off_secure
=
$serial_enabled
?
'onifconsole secure'
:
'off secure'
;
$on_off_secure_u
=
$serial_enabled
?
'onifconsole secure'
:
'off secure'
;
$on_off_secure_v
=
$virtual_enabled
?
'off secure'
:
'on secure'
;
$terminal_type
=
'cons25'
;
/* XXX standard is 'xterm' for virtual, 'vt100' for serial */
if
(
isset
(
$config
[
'system'
][
'disableconsolemenu'
]))
{
$console_type
=
'Pc'
;
...
...
@@ -1657,16 +1658,22 @@ function system_login_configure()
$serial_type
=
'al.'
.
$serialspeed
;
}
foreach
(
$etc_ttys_lines
as
$tty
)
{
/* first virtual terminal */
if
(
strpos
(
$tty
,
'ttyv0'
)
===
0
)
{
/* first virtual terminal */
$on_off_secure2
=
count
(
$console_selection
)
==
1
&&
$console_selection
[
0
]
==
'nullconsole'
?
'off secure'
:
'on secure'
;
fwrite
(
$fd
,
"ttyv0
\t\"
/usr/libexec/getty
{
$console_type
}
\"\t\t
{
$terminal_type
}
\t
${on_off_secure2}
\n
"
);
fwrite
(
$fd
,
"ttyv0
\t\"
/usr/libexec/getty
{
$console_type
}
\"\t\t
{
$terminal_type
}
\t
${on_off_secure_v}
\n
"
);
continue
;
}
/* all other virtual terminals */
foreach
(
array
(
'ttyv1'
,
'ttyv2'
,
'ttyv3'
,
'ttyv4'
,
'ttyv5'
,
'ttyv6'
,
'ttyv7'
)
as
$virtualport
)
{
if
(
strpos
(
$tty
,
$virtualport
)
===
0
)
{
fwrite
(
$fd
,
"${virtualport}
\t\"
/usr/libexec/getty
{
$console_type
}
\"\t\t
xterm
\t
${on_off_secure_v}
\n
"
);
continue
2
;
}
}
/* each serial terminal */
foreach
(
array
(
'ttyu0'
,
'ttyu1'
,
'ttyu2'
,
'ttyu3'
)
as
$serialport
)
{
if
(
strpos
(
$tty
,
$serialport
)
===
0
)
{
/* each serial terminal */
fwrite
(
$fd
,
"
{
$serialport
}
\t\"
/usr/libexec/getty
{
$serial_type
}
\"\t
{
$terminal_type
}
\t
{
$on_off_secure
}
\n
"
);
fwrite
(
$fd
,
"
{
$serialport
}
\t\"
/usr/libexec/getty
{
$serial_type
}
\"\t
{
$terminal_type
}
\t
{
$on_off_secure_u
}
\n
"
);
/* skip to next line in outer loop */
continue
2
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment