openssh: Disable privilege separation by patching
[termux-packages] / packages / openssh / build.sh
CommitLineData
cff3a76b 1TERMUX_PKG_HOMEPAGE=https://www.openssh.com/
59f0d218 2TERMUX_PKG_DESCRIPTION="Secure shell for logging into a remote machine"
cff3a76b 3TERMUX_PKG_VERSION=7.5p1
a8b61adf 4TERMUX_PKG_SRCURL=http://mirrors.evowise.com/pub/OpenBSD/OpenSSH/portable/openssh-${TERMUX_PKG_VERSION}.tar.gz
cff3a76b 5TERMUX_PKG_SHA256=9846e3c5fab9f0547400b4d2c017992f914222b3fd1f8eee6c7dc6bc5e59f9f0
a8b61adf 6TERMUX_PKG_DEPENDS="libandroid-support, ldns, openssl, libutil"
59f0d218 7# --disable-strip to prevent host "install" command to use "-s", which won't work for target binaries:
cff3a76b
FF
8TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
9--disable-etc-default-login
10--disable-lastlog
11--disable-libutil
12--disable-pututline
13--disable-pututxline
14--disable-strip
15--disable-utmp
16--disable-utmpx
17--disable-wtmp
18--disable-wtmpx
19--sysconfdir=$TERMUX_PREFIX/etc/ssh
20--with-cflags=-Dfd_mask=int
21--with-ldns
22--without-ssh1
23--without-stackprotect
24--with-pid-dir=$TERMUX_PREFIX/var/run
25--with-privsep-path=$TERMUX_PREFIX/var/empty
26ac_cv_func_endgrent=yes
27ac_cv_func_fmt_scaled=no
28ac_cv_func_getlastlogxbyname=no
29ac_cv_func_readpassphrase=no
30ac_cv_func_strnvis=no
31ac_cv_header_sys_un_h=yes
32ac_cv_search_getrrsetbyname=no
33"
59f0d218
FF
34TERMUX_PKG_MAKE_INSTALL_TARGET="install-nokeys"
35TERMUX_PKG_RM_AFTER_INSTALL="bin/slogin share/man/man1/slogin.1"
36
7ce56385 37termux_step_pre_configure() {
cff3a76b
FF
38 # We patch configure.ac:
39 cd $TERMUX_PKG_SRCDIR
40 autoreconf
41
7ce56385
FF
42 LD=$CC # Needed to link the binaries
43 LDFLAGS+=" -llog" # liblog for android logging in syslog hack
44}
59f0d218 45
7b1f1bd3 46termux_step_post_configure() {
59f0d218
FF
47 # We need to remove this file before installing, since otherwise the
48 # install leaves it alone which means no updated timestamps.
49 rm -Rf $TERMUX_PREFIX/etc/moduli
50}
51
52termux_step_post_make_install () {
62c37b97 53 # OpenSSH 7.0 disabled ssh-dss by default, keep it for a while in Termux:
b79434aa 54 echo -e "PasswordAuthentication no\nPubkeyAcceptedKeyTypes +ssh-dss\nSubsystem sftp $TERMUX_PREFIX/libexec/sftp-server" > $TERMUX_PREFIX/etc/ssh/sshd_config
62c37b97 55 echo "PubkeyAcceptedKeyTypes +ssh-dss" > $TERMUX_PREFIX/etc/ssh/ssh_config
59f0d218
FF
56 cp $TERMUX_PKG_BUILDER_DIR/source-ssh-agent.sh $TERMUX_PREFIX/bin/source-ssh-agent
57 cp $TERMUX_PKG_BUILDER_DIR/ssh-with-agent.sh $TERMUX_PREFIX/bin/ssha
58
b0c457ae
FF
59 # Install ssh-copy-id:
60 cp $TERMUX_PKG_SRCDIR/contrib/ssh-copy-id.1 $TERMUX_PREFIX/share/man/man1/
61 cp $TERMUX_PKG_SRCDIR/contrib/ssh-copy-id $TERMUX_PREFIX/bin/
62 chmod +x $TERMUX_PREFIX/bin/ssh-copy-id
63
59f0d218
FF
64 mkdir -p $TERMUX_PREFIX/var/run
65 echo "OpenSSH needs this folder to put sshd.pid in" >> $TERMUX_PREFIX/var/run/README.openssh
66
67 mkdir -p $TERMUX_PREFIX/etc/ssh/
68 cp $TERMUX_PKG_SRCDIR/moduli $TERMUX_PREFIX/etc/ssh/moduli
69}
70
71termux_step_create_debscripts () {
72 echo "mkdir -p \$HOME/.ssh" > postinst
73 echo "" >> postinst
74 echo "for a in rsa dsa ecdsa ed25519; do" >> postinst
75 echo " KEYFILE=$TERMUX_PREFIX/etc/ssh/ssh_host_\${a}_key" >> postinst
76 echo " test ! -f \$KEYFILE && ssh-keygen -N '' -t \$a -f \$KEYFILE" >> postinst
77 echo "done" >> postinst
78 echo "exit 0" >> postinst
79 chmod 0755 postinst
80}