Patchwork [base,12/13] openssh/sftp-server: sftp-server remove libcrypto dependency.

login
register
mail settings
Submitter Jacob Kjaergaard
Date Sept. 30, 2013, 8:25 a.m.
Message ID <70bd5d021bc56870050d2a7fe15856bd26f9cbf9.1380529272.git.jacob.kjaergaard@prevas.dk>
Download mbox | patch
Permalink /patch/278961/
State Accepted
Delegated to: Esben Haabendal
Headers show

Comments

Jacob Kjaergaard - Sept. 30, 2013, 8:25 a.m.
From: Jacob Kjaergaard <jacob.kjaergaard@prevas.dk>

sftp-server does not use libcrypto at all but is dynamically linked against
it. in systems with small footprint requirement where only the sftp-server
is used this requires an additional 1.6MB. This patch circumvents the
linking against that lib for sftp-server and libcrypto can be omitted
runtime
---
 .../openssh/files/sftp-server-skip-libcrypto.patch |   14 ++++++++++++
 recipes/openssh/openssh.inc                        |   23 ++++++++++++++++++--
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 recipes/openssh/files/sftp-server-skip-libcrypto.patch
Esben Haabendal - Oct. 14, 2013, 1:12 p.m.
Merged to master, thanks.

/Esben

Patch

diff --git a/recipes/openssh/files/sftp-server-skip-libcrypto.patch b/recipes/openssh/files/sftp-server-skip-libcrypto.patch
new file mode 100644
index 0000000..94b8f96
--- /dev/null
+++ b/recipes/openssh/files/sftp-server-skip-libcrypto.patch
@@ -0,0 +1,14 @@ 
+diff -c /home/jabk/projects/deif/oe-lite/tmp/work/machine/powerpc-e300c3-linux-gnu/openssh-6.1p1/src/openssh-6.1p1/Makefile.in\~ /home/jabk/projects/deif/oe-lite/tmp/work/machine/powerpc-e300c3-linux-gnu/openssh-6.1p1/src/openssh-6.1p1/Makefile.in
+--- a/Makefile.in~	2012-04-04 03:27:57.000000000 +0200
++++ b/Makefile.in	2013-08-06 11:58:16.303164455 +0200
+@@ -166,7 +166,7 @@
+ 	$(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
+ 
+ sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
+-	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
++	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(SFTP_LIBS)
+ 
+ sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
+ 	$(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
+
+Diff finished.  Tue Aug  6 11:58:21 2013
diff --git a/recipes/openssh/openssh.inc b/recipes/openssh/openssh.inc
index 75d5795..9c032c5 100644
--- a/recipes/openssh/openssh.inc
+++ b/recipes/openssh/openssh.inc
@@ -17,6 +17,7 @@  inherit autotools passwd
 SRC_URI = "ftp://ftp.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-${PV}.tar.gz"
 SRC_URI += "file://sshd_config file://ssh_config file://init"
 SRC_URI += "file://passwd file://group"
+SRC_URI += "file://sftp-server-skip-libcrypto.patch"
 
 DEPENDS = "libcrypto libssl libz ${DEPENDS_LIBC}"
 DEPENDS_LIBC = "libdl libutil libresolv libcrypt"
@@ -26,7 +27,7 @@  export ASKPASS_PROGRAM = "${bindir}/ssh-askpass"
 export LD = "${CC}"
 CFLAGS =+ "-I${S} "
 CFLAGS += "-D__FILE_OFFSET_BITS=64"
-LDFLAGS =+ "-L${S} -L${S}/openbsd-compat "
+LDFLAGS =+ "-L${S} -L${S}/openbsd-compat"
 
 EXTRA_OECONF = "--disable-suid-ssh --with-ssl \
 	--with-rand-helper=no \
@@ -46,6 +47,13 @@  do_patch_aclocal_mangle () {
 	fi
 }
 
+#remove unnecessary crypto dependency
+do_configure[postfuncs] += "do_configure_sftp_server"
+do_configure_sftp_server () {
+    echo SFTP_LIBS=`grep ^LIBS= ${S}/Makefile | cut -b6- | sed 's/-lcrypto//'` >> ${S}/Makefile
+}
+
+
 do_compile[postfuncs] += "do_compile_install_config_files"
 do_compile_install_config_files () {
 	install -m 0644 ${SRCDIR}/sshd_config ${S}/
@@ -73,9 +81,20 @@  FILES_${PN}-sshd = "${sysconfdir}/init.d/sshd \
 FILES_${PN}-sshd-doc = "${mandir}/*/moduli.* ${mandir}/*/sshd_config.*"
 
 RDEPENDS_${PN} += "${AUTO_PACKAGE_UTILS_PACKAGES}"
-AUTO_PACKAGE_UTILS_RDEPENDS = "libc libgcc libdl libutil libcrypto libz"
+AUTO_PACKAGE_UTILS_RDEPENDS = "libc libgcc libdl libutil libz"
 RDEPENDS_${PN}-sshd = "${PN}-keygen"
 
+RDEPENDS_${PN}-ssh-add           += "libcrypto"
+RDEPENDS_${PN}-ssh-agent         += "libcrypto"
+RDEPENDS_${PN}-ssh-keyscan       += "libcrypto"
+RDEPENDS_${PN}-ssh-keygen        += "libcrypto"
+RDEPENDS_${PN}-ssh-keysign       += "libcrypto"
+RDEPENDS_${PN}-scp               += "libcrypto"
+RDEPENDS_${PN}-ssh               += "libcrypto"
+RDEPENDS_${PN}-sshd              += "libcrypto"
+RDEPENDS_${PN}-sftp              += "libcrypto"
+RDEPENDS_${PN}-ssh-pkcs11-helper += "libcrypto"
+
 inherit sysvinit
 RECIPE_FLAGS = "sshd_sysvinit_start sshd_sysvinit_stop"
 DEFAULT_USE_sshd_sysvinit_start = "25"