openssh: Package server configuration
cover openssh: Package server configuration
This serie of patches provides a way to package OpenSSH sshd configuration. This way, it should be easier to change the configuration either in distro and/or BSP layers.
It also simplifies management for R/O rootfs
David Vincent (3):
openssh: Package server configuration
core-image: Set default sshd configuration
rootfs-postcommands: Modify ssh-related commands
meta/classes/core-image.bbclass | 3 +- meta/classes/rootfs-postcommands.bbclass | 17 +++----- meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51 ++++++++++++++++++---- 3 files changed, 50 insertions(+), 21 deletions(-)
Signature · 1 line
2.13.0
PATCH RESEND 1/3 openssh: Package server configuration
Split sshd configuration for read-write/read-only rootfs in two distinct packages. Also, add a package dependency between openssh-sshd package and a provider of sshd-config.
--- meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51 ++++++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-)
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +42 -9
@@ -91,13 +91,17 @@ do_compile_ptest() { } do_install_append () { - if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then + # Create default config files + install -m 0644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_default + rm -f ${D}${sysconfdir}/ssh/sshd_config + + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = "pam" ]; then install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd - sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config + sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config_default fi - if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then - sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = "x11" ]; then + sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config_default fi install -d ${D}${sysconfdir}/init.d
@@ -110,7 +114,7 @@ do_install_append () { # Create config files for read-only rootfs install -d ${D}${sysconfdir}/ssh - install -m 644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly + install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default ${D}${sysconfdir}/ssh/sshd_config_readonly sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly
@@ -134,30 +138,59 @@ do_install_ptest () { ALLOW_EMPTY_${PN} = "1" -PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server" +PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config ${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server" FILES_${PN}-scp = "${bindir}/scp.${BPN}" FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config" +FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default" +FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly" FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_unitdir}/system" -FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd" +FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd" FILES_${PN}-sftp = "${bindir}/sftp" FILES_${PN}-sftp-server = "${libexecdir}/sftp-server" FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*" FILES_${PN}-keygen = "${bindir}/ssh-keygen" RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen" -RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}" +RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}" RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make" RPROVIDES_${PN}-ssh = "ssh" +RPROVIDES_${PN}-sshd-config = "sshd-config" +RPROVIDES_${PN}-sshd-config-readonly = "sshd-config" RPROVIDES_${PN}-sshd = "sshd" RCONFLICTS_${PN} = "dropbear" +RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly" +RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config" RCONFLICTS_${PN}-sshd = "dropbear" RCONFLICTS_${PN}-keygen = "ssh-keygen" -CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config" +CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default" +CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly" CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config" +pkg_postinst_${PN}-sshd-config () { +#!/bin/sh +if [ -e $D${sysconfdir}/ssh/sshd_config ]; then + rm $D${sysconfdir}/ssh/sshd_config +fi + +# Make sure destination directory exists, before creating the symlink +mkdir -p $D${sysconfdir}/ssh +ln -s sshd_config_default $D${sysconfdir}/ssh/sshd_config +} + +pkg_postinst_${PN}-sshd-config-readonly () { +#!/bin/sh +if [ -e $D${sysconfdir}/ssh/sshd_config ]; then + rm $D${sysconfdir}/ssh/sshd_config +fi + +# Make sure destination directory exists, before creating the symlink +mkdir -p $D${sysconfdir}/ssh +ln -s sshd_config_readonly $D${sysconfdir}/ssh/sshd_config +} + ALTERNATIVE_PRIORITY = "90" ALTERNATIVE_${PN}-scp = "scp" ALTERNATIVE_${PN}-ssh = "ssh"
Signature · 1 line
2.13.0
PATCH RESEND 2/3 core-image: Set default sshd configuration
In reply to David VincentWhen selecting OpenSSH as ssh server provider instead of dropbear, also install the correct configuration depending on whether the final rootfs is read-only or not.
--- meta/classes/core-image.bbclass | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/classes/core-image.bbclass +2 -1
@@ -45,7 +45,7 @@ FEATURE_PACKAGES_tools-sdk = "packagegroup-core-sdk packagegroup-core-standalone FEATURE_PACKAGES_nfs-server = "packagegroup-core-nfs-server" FEATURE_PACKAGES_nfs-client = "packagegroup-core-nfs-client" FEATURE_PACKAGES_ssh-server-dropbear = "packagegroup-core-ssh-dropbear" -FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh" +FEATURE_PACKAGES_ssh-server-openssh = "packagegroup-core-ssh-openssh ${SSHD_CONFIG}" FEATURE_PACKAGES_hwcodecs = "${MACHINE_HWCODECS}"
@@ -56,6 +56,7 @@ IMAGE_FEATURES_REPLACES_ssh-server-openssh = "ssh-server-dropbear" # IMAGE_FEATURES_CONFLICTS_foo = 'bar1 bar2' # An error exception would be raised if both image features foo and bar1(or bar2) are included +SSHD_CONFIG ??= "${@bb.utils.contains('IMAGE_FEATURES','read-only-rootfs','openssh-sshd-config-readonly','openssh-sshd-config',d)}" MACHINE_HWCODECS ??= "" CORE_IMAGE_BASE_INSTALL = '\
Signature · 1 line
2.13.0
PATCH RESEND 3/3 rootfs-postcommands: Modify ssh-related commands
In reply to David VincentOpenSSH configuration is now a symlink which points to the desired configuration, so the functions that modified it must be updated to modify the target and not override it.
--- meta/classes/rootfs-postcommands.bbclass | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
meta/classes/rootfs-postcommands.bbclass +6 -11
@@ -89,15 +89,12 @@ read_only_rootfs_hook () { fi # If we're using openssh and the /etc/ssh directory has no pre-generated keys, - # we should configure openssh to use the configuration file /etc/ssh/sshd_config_readonly - # and the keys under /var/run/ssh. + # we should configure openssh to use the keys under /var/run/ssh. if [ -d ${IMAGE_ROOTFS}/etc/ssh ]; then if [ -e ${IMAGE_ROOTFS}/etc/ssh/ssh_host_rsa_key ]; then echo "SYSCONFDIR=/etc/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh - echo "SSHD_OPTS=" >> ${IMAGE_ROOTFS}/etc/default/ssh else echo "SYSCONFDIR=/var/run/ssh" >> ${IMAGE_ROOTFS}/etc/default/ssh - echo "SSHD_OPTS='-f /etc/ssh/sshd_config_readonly'" >> ${IMAGE_ROOTFS}/etc/default/ssh fi fi
@@ -140,12 +137,10 @@ zap_empty_root_password () { # allow dropbear/openssh to accept root logins and logins from accounts with an empty password string # ssh_allow_empty_password () { - for config in sshd_config sshd_config_readonly; do - if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config ]; then - sed -i 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config - sed -i 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/$config - fi - done + if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then + sed -i --follow-symlinks 's/^[#[:space:]]*PermitRootLogin.*/PermitRootLogin yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config + sed -i --follow-symlinks 's/^[#[:space:]]*PermitEmptyPasswords.*/PermitEmptyPasswords yes/' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config + fi if [ -e ${IMAGE_ROOTFS}${sbindir}/dropbear ] ; then if grep -q DROPBEAR_EXTRA_ARGS ${IMAGE_ROOTFS}${sysconfdir}/default/dropbear 2>/dev/null ; then
@@ -164,7 +159,7 @@ ssh_allow_empty_password () { ssh_disable_dns_lookup () { if [ -e ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config ]; then - sed -i -e 's:#UseDNS yes:UseDNS no:' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config + sed -i --follow-symlinks -e 's:#UseDNS yes:UseDNS no:' ${IMAGE_ROOTFS}${sysconfdir}/ssh/sshd_config fi }
Signature · 1 line
2.13.0
Quoted 35 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of David Vincent
Sent: den 9 juni 2017 09:04
To: [email protected]
Subject: [OE-core] [PATCH RESEND 1/3] openssh: Package server configurationSplit sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package and a provider of sshd-config.Signed-off-by David Vincent <[email protected]>--- meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51 ++++++++++++++++++---- 1 file changed, 42 insertions(+), 9 deletions(-)meta/recipes-connectivity/openssh/openssh_7.5p1.bb +5
-1@@ -91,13 +91,17 @@ do_compile_ptest() { } do_install_append () { - if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then + # Create default config files + install -m 0644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_default + rm -f ${D}${sysconfdir}/ssh/sshd_config + + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" = "pam" ]; then
meta/recipes-connectivity/openssh/openssh_7.5p1.bb do_compile_ptest() { · line 105
Quoted 10 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +3
-3install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd - sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config + sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/sshd_config_default fi - if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then - sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = "x11" ]; then + sed -i -e 's:#X11Forwarding no:X11Forwarding yes:' ${D}${sysconfdir}/ssh/sshd_config_default fi
Instead of all the changes above you could just do this here instead:
mv ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_defaultmeta/recipes-connectivity/openssh/openssh_7.5p1.bb do_install_append () { · line 116
Quoted 5 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-0install -d ${D}${sysconfdir}/init.d@@ -110,7 +114,7 @@ do_install_append () { # Create config files for read-only rootfs install -d ${D}${sysconfdir}/ssh
Creating the directory here again is unnecessary.
Quoted 56 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +24
-5- install -m 644 ${D}${sysconfdir}/ssh/sshd_config ${D}${sysconfdir}/ssh/sshd_config_readonly + install -m 644 ${D}${sysconfdir}/ssh/sshd_config_default ${D}${sysconfdir}/ssh/sshd_config_readonly sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly@@ -134,30 +138,59 @@ do_install_ptest () { ALLOW_EMPTY_${PN} = "1" -PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server" +PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config ${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server" FILES_${PN}-scp = "${bindir}/scp.${BPN}" FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config" +FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default" +FILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly" FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_unitdir}/system" -FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd" +FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd" FILES_${PN}-sftp = "${bindir}/sftp" FILES_${PN}-sftp-server = "${libexecdir}/sftp-server" FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*" FILES_${PN}-keygen = "${bindir}/ssh-keygen" RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen" -RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}" +RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}" RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make" RPROVIDES_${PN}-ssh = "ssh" +RPROVIDES_${PN}-sshd-config = "sshd-config" +RPROVIDES_${PN}-sshd-config-readonly = "sshd-config" RPROVIDES_${PN}-sshd = "sshd" RCONFLICTS_${PN} = "dropbear" +RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly" +RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config" RCONFLICTS_${PN}-sshd = "dropbear" RCONFLICTS_${PN}-keygen = "ssh-keygen" -CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config" +CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default" +CONFFILES_${PN}-sshd-config-readonly = "${sysconfdir}/ssh/sshd_config_readonly" CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config" +pkg_postinst_${PN}-sshd-config () { +#!/bin/sh +if [ -e $D${sysconfdir}/ssh/sshd_config ]; then + rm $D${sysconfdir}/ssh/sshd_config +fi + +# Make sure destination directory exists, before creating the symlink +mkdir -p $D${sysconfdir}/ssh +ln -s sshd_config_default $D${sysconfdir}/ssh/sshd_config +} + +pkg_postinst_${PN}-sshd-config-readonly () {
meta/recipes-connectivity/openssh/openssh_7.5p1.bb do_install_ptest () { · line 193
Quoted 10 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +10
-0+#!/bin/sh +if [ -e $D${sysconfdir}/ssh/sshd_config ]; then + rm $D${sysconfdir}/ssh/sshd_config +fi + +# Make sure destination directory exists, before creating the symlink +mkdir -p $D${sysconfdir}/ssh +ln -s sshd_config_readonly $D${sysconfdir}/ssh/sshd_config +} +
I do not like changing /etc/ssh/sshd_config to be a link. I know at least we have our own rootfs-postcommands that will be affected by such a change.
How about you use a PACKAGESPLITFUNCS function instead and move the files back into place before they are packaged, so that both configuration packages contain the /etc/ssh/sshd_config file.
Something like this should work (totally untested):
PACKAGESPLITFUNCS += "restore_sshd_config"
restore_sshd_config() {
for file in ${PKGDEST}/*${sysconfdir}/sshd/sshd_config_*; do
mv $file ${file%_*}
done
}Quoted 5 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-1ALTERNATIVE_PRIORITY = "90" ALTERNATIVE_${PN}-scp = "scp" ALTERNATIVE_${PN}-ssh = "ssh" --2.13.0
//Peter
Hi.
Quoted 6 lines · David Vincent
This serie of patches provides a way to package OpenSSH sshd configuration. This
way, it should be easier to change the configuration either in distro and/or BSP
layers.
It also simplifies management for R/O rootfs
Looking at some previous patches and comments, this split seems to have been done with the intention to better support R/O rootfs.
I have a sent a patch that addresses the R/O rootfs issue in a different way, which I believe to be a simpler and less intrusive approach. We've been using this for a while.
http://lists.openembedded.org/pipermail/openembedded-core/2017-June/137848.html
Let me know what you think.
Cheers,
Andre'
Quoted 14 lines
David Vincent (3):
openssh: Package server configuration
core-image: Set default sshd configuration
rootfs-postcommands: Modify ssh-related commandsmeta/classes/core-image.bbclass | 3 +- meta/classes/rootfs-postcommands.bbclass | 17 +++----- meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51
++++++++++++++++++----3 files changed, 50 insertions(+), 21 deletions(-)--
2.13.0
Quoted 44 lines · On vendredi 9 juin 2017 11:41:25 CEST Peter Kjellerstedt wrote:
Quoted 44 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of David Vincent
Sent: den 9 juni 2017 09:04
To: [email protected]
Subject: [OE-core] [PATCH RESEND 1/3] openssh: Package server configurationSplit sshd configuration for read-write/read-only rootfs in two distinct
packages. Also, add a package dependency between openssh-sshd package and a provider of sshd-config.Signed-off-by David Vincent <[email protected]>---
meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51++++++++++++++++++----
1 file changed, 42 insertions(+), 9 deletions(-)meta/recipes-connectivity/openssh/openssh_7.5p1.bb +2
-1@@ -91,13 +91,17 @@ do_compile_ptest() { } do_install_append () { - if [ "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)}" ]; then + # Create default config files + install -m 0644 ${D}${sysconfdir}/ssh/sshd_config${D}${sysconfdir}/ssh/sshd_config_default + rm -f
${D}${sysconfdir}/ssh/sshd_configmeta/recipes-connectivity/openssh/openssh_7.5p1.bb +2
-0+ + if [ "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" ="pam" ]; then>
install -D -m 0644 ${WORKDIR}/sshd ${D}${sysconfdir}/pam.d/sshd
Quoted 1 line
meta/recipes-connectivity/openssh/openssh_7.5p1.bb
Quoted 1 line
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-1- sed -i -e 's:#UsePAM no:UsePAM yes:' ${D}${sysconfdir}/ssh/
sshd_config
Quoted 4 lines
Quoted 4 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +1
-0+ sed -i -e 's:#UsePAM no:UsePAM yes:'${D}${sysconfdir}/ssh/sshd_config_default>
fi
Quoted 9 lines
Quoted 7 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-2- if [ "${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)}" ]; then - sed -i -e 's:#X11Forwarding no:X11Forwarding yes:'${D}${sysconfdir}/ssh/sshd_config + if [
"${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)}" = "x11"
]; then + sed -i -e 's:#X11Forwarding no:X11Forwarding yes:'
${D}${sysconfdir}/ssh/sshd_config_default>
fiInstead of all the changes above you could just do this here instead:
Yes, it is simpler that way. If a v2 is to be sent, I will do that change.
Quoted 11 lines
mv ${D}${sysconfdir}/ssh/sshd_config${D}${sysconfdir}/ssh/sshd_config_default
meta/recipes-connectivity/openssh/openssh_7.5p1.bb do_install_append () { · line 116
Quoted 6 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-0install -d ${D}${sysconfdir}/init.d@@ -110,7 +114,7 @@ do_install_append () { # Create config files for read-only rootfs install -d ${D}${sysconfdir}/sshCreating the directory here again is unnecessary.
That's the old code, maybe it should be dropped.
Quoted 92 lines
Quoted 78 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-1- install -m 644 ${D}${sysconfdir}/ssh/sshd_config${D}${sysconfdir}/ssh/sshd_config_readonly + install -m 644
${D}${sysconfdir}/ssh/sshd_config_default
${D}${sysconfdir}/ssh/sshd_config_readonly>meta/recipes-connectivity/openssh/openssh_7.5p1.bb +0
-1sed -i '/HostKey/d' ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey /var/run/ssh/ssh_host_rsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly echo "HostKey /var/run/ssh/ssh_host_dsa_key" >> ${D}${sysconfdir}/ssh/sshd_config_readonly>@@ -134,30 +138,59 @@ do_install_ptest () { ALLOW_EMPTY_${PN} = "1" -PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-sftp${PN}-misc ${PN}-sftp-server" +PACKAGES =+ "${PN}-keygen ${PN}-scp ${PN}-ssh ${PN}-sshd-config ${PN}-sshd-config-readonly ${PN}-sshd ${PN}-sftp ${PN}-misc ${PN}-sftp-server">
FILES_${PN}-scp = "${bindir}/scp.${BPN}"
FILES_${PN}-ssh = "${bindir}/ssh.${BPN} ${sysconfdir}/ssh/ssh_config"meta/recipes-connectivity/openssh/openssh_7.5p1.bb +2
-0+FILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default" +FILES_${PN}-sshd-config-readonly ="${sysconfdir}/ssh/sshd_config_readonly">
FILES_${PN}-sshd = "${sbindir}/sshd ${sysconfdir}/init.d/sshd ${systemd_unitdir}/system">
-FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/ssh/sshd_config ${sysconfdir}/ssh/sshd_config_readonly ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd" +FILES_${PN}-sshd += "${sysconfdir}/ssh/moduli ${sysconfdir}/default/volatiles/99_sshd ${sysconfdir}/pam.d/sshd">
FILES_${PN}-sftp = "${bindir}/sftp" FILES_${PN}-sftp-server = "${libexecdir}/sftp-server" FILES_${PN}-misc = "${bindir}/ssh* ${libexecdir}/ssh*" FILES_${PN}-keygen = "${bindir}/ssh-keygen"RDEPENDS_${PN} += "${PN}-scp ${PN}-ssh ${PN}-sshd ${PN}-keygen"
-RDEPENDS_${PN}-sshd += "${PN}-keygen ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}" +RDEPENDS_${PN}-sshd += "${PN}-keygen sshd-config ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam-plugin-keyinit pam-plugin-loginuid', '', d)}">
RDEPENDS_${PN}-ptest += "${PN}-sftp ${PN}-misc ${PN}-sftp-server make"RPROVIDES_${PN}-ssh = "ssh"
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +6
-1+RPROVIDES_${PN}-sshd-config = "sshd-config" +RPROVIDES_${PN}-sshd-config-readonly = "sshd-config" RPROVIDES_${PN}-sshd = "sshd" RCONFLICTS_${PN} = "dropbear" +RCONFLICTS_${PN}-sshd-config = "${PN}-sshd-config-readonly" +RCONFLICTS_${PN}-sshd-config-readonly = "${PN}-sshd-config" RCONFLICTS_${PN}-sshd = "dropbear" RCONFLICTS_${PN}-keygen = "ssh-keygen" -CONFFILES_${PN}-sshd = "${sysconfdir}/ssh/sshd_config" +CONFFILES_${PN}-sshd-config = "${sysconfdir}/ssh/sshd_config_default" +CONFFILES_${PN}-sshd-config-readonly ="${sysconfdir}/ssh/sshd_config_readonly">
CONFFILES_${PN}-ssh = "${sysconfdir}/ssh/ssh_config"meta/recipes-connectivity/openssh/openssh_7.5p1.bb +12
-0+pkg_postinst_${PN}-sshd-config () { +#!/bin/sh +if [ -e $D${sysconfdir}/ssh/sshd_config ]; then + rm $D${sysconfdir}/ssh/sshd_config +fi + +# Make sure destination directory exists, before creating the symlink +mkdir -p $D${sysconfdir}/ssh +ln -s sshd_config_default $D${sysconfdir}/ssh/sshd_config +} + +pkg_postinst_${PN}-sshd-config-readonly () {meta/recipes-connectivity/openssh/openssh_7.5p1.bb do_install_ptest () { · line 193
Quoted 10 lines
meta/recipes-connectivity/openssh/openssh_7.5p1.bb +10
-0+#!/bin/sh +if [ -e $D${sysconfdir}/ssh/sshd_config ]; then + rm $D${sysconfdir}/ssh/sshd_config +fi + +# Make sure destination directory exists, before creating the symlink +mkdir -p $D${sysconfdir}/ssh +ln -s sshd_config_readonly $D${sysconfdir}/ssh/sshd_config +} +I do not like changing
/etc/ssh/sshd_configto be a link. I know at least we have our own rootfs-postcommands that will be affected by such a change.
Quoted 3 lines
How about you use a PACKAGESPLITFUNCS function instead and move the files back into place before they are packaged, so that both configuration packages contain the
/etc/ssh/sshd_configfile.
I have another problem, when I package my configuration, I do not want any postcommand tasks to modify it unpredictibly in my release builds. Maybe I should find another workaround to not break the current workflows.
Quoted 11 lines
Something like this should work (totally untested):
PACKAGESPLITFUNCS += "
restore_sshd_config"restore_sshd_config() { for file in ${PKGDEST}/*${sysconfdir}/sshd/sshd_config_*; do mv $file ${file%_*} done }
Quoted 8 lines
Quoted 6 lines
ALTERNATIVE_PRIORITY= "90"
ALTERNATIVE_${PN}-scp = "scp"
ALTERNATIVE_${PN}-ssh = "ssh"--
2.13.0//Peter
--
David
Quoted 10 lines · On vendredi 9 juin 2017 15:53:40 CEST André Draszik wrote:
Hi.
Quoted 6 lines · David Vincent
This serie of patches provides a way to package OpenSSH sshd configuration. This
way, it should be easier to change the configuration either in distro and/or BSP
layers.
It also simplifies management for R/O rootfs
Quoted 2 lines
Looking at some previous patches and comments, this split seems to have been done with the intention to better support R/O rootfs.
Not only, it has been done with the intention of providing a completely custom configuration. But maybe it wasn't the proper way to do it.
Quoted 3 lines
I have a sent a patch that addresses the R/O rootfs issue in a different way, which I believe to be a simpler and less intrusive approach. We've been using this for a while.
Yes, I saw it has been merged recently. I'm not sure it addresses the problem I had in mind but I agree it simplifies the configuration for R/O rootfs.
Quoted 23 lines
http://lists.openembedded.org/pipermail/openembedded-core/2017-June/137848.h
tmlLet me know what you think.
Cheers,
Andre'Quoted 13 lines
David Vincent (3):
openssh: Package server configuration
core-image: Set default sshd configuration
rootfs-postcommands: Modify ssh-related commandsmeta/classes/core-image.bbclass | 3 +- meta/classes/rootfs-postcommands.bbclass | 17 +++----- meta/recipes-connectivity/openssh/openssh_7.5p1.bb | 51 ++++++++++++++++++---- 3 files changed, 50 insertions(+), 21 deletions(-)Signature · 1 line
2.13.0
--
David