Skip to content

Commit c561b0c

Browse files
authored
Merge pull request #4338 from flatcar/chewi/mode-leak
profile.bashrc: Fix SSH by not allowing *opts helper values to leak
2 parents f7c1c9c + c8717d8 commit c561b0c

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Alpha and Beta only: Fixed SSH client that was broken by a configuration file with bad permissions being unreadable. ([scripts#4338](https://github.com/flatcar/scripts/pull/4338))

‎sdk_container/src/third_party/coreos-overlay/coreos/config/env/net-misc/openssh‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cros_post_src_install_flatcar_modifications() {
1010
vendorize_pam_files
1111

1212
if [[ $(flatcar_target) != 'sdk' ]] ; then
13+
insopts -m 0644
1314
dosym -r /usr/share/flatcar/etc/ssh/ssh_config.d/50-flatcar-ssh.conf /usr/share/ssh/ssh_config
1415
insinto /usr/share/flatcar/etc/ssh/ssh_config.d/
1516
newins - 50-flatcar-ssh.conf
@@ -18,6 +19,7 @@ cros_post_src_install_flatcar_modifications() {
1819
# Use defaults for ssh client system-wide configuration.
1920
EOF
2021

22+
insopts -m 0600
2123
dosym -r /usr/share/flatcar/etc/ssh/sshd_config.d/50-flatcar-sshd.conf /usr/share/ssh/sshd_config
2224
insinto /usr/share/flatcar/etc/ssh/sshd_config.d/
2325
newins - 50-flatcar-sshd.conf
@@ -46,18 +48,16 @@ PrintMotd no
4648
HostkeyAlgorithms +ssh-rsa
4749
PubkeyAcceptedAlgorithms +ssh-rsa
4850
EOF
51+
4952
# Install our socket drop-in file that disables the rate
5053
# limiting on the sshd socket.
51-
(
52-
insopts -m 0644
53-
unit_dir=$(systemd_get_systemunitdir)
54-
insinto "${unit_dir}/sshd.socket.d"
55-
newins - no-trigger-limit-burst.conf <<'EOF'
54+
insopts -m 0644
55+
insinto "$(systemd_get_systemunitdir)/sshd.socket.d"
56+
newins - no-trigger-limit-burst.conf <<'EOF'
5657
[Socket]
5758
TriggerLimitBurst=0
5859
EOF
59-
# Enable some sockets that aren't enabled by their own ebuilds.
60-
systemd_enable_service sockets.target sshd.socket
61-
)
60+
# Enable some sockets that aren't enabled by their own ebuilds.
61+
systemd_enable_service sockets.target sshd.socket
6262
fi
6363
}

‎sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/profile.bashrc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,14 @@ cros_stack_hooks() {
9393
einfo "Running stacked hooks for ${phase}"
9494
header=false
9595
fi
96+
97+
# Don't allow *into or *opts helper values to leak between ebuilds and
98+
# hook functions. They normally leak between ebuild phases, but leaking
99+
# them to and from other scripts maintained by other people is
100+
# hazardous. These default values come from Portage's phase-helpers.sh.
101+
local -x __E_DESTTREE="/usr" __E_INSDESTTREE= __E_EXEDESTTREE= __E_DOCDESTTREE=
102+
local -x INSOPTIONS="-m0644" EXEOPTIONS="-m0755" LIBOPTIONS="-m0644" DIROPTIONS="-m0755"
103+
96104
ebegin " ${func#cros_${phase}_}"
97105
${func}
98106
eend $?

0 commit comments

Comments
 (0)