2 # Copyright (C) 2006-2020 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
14 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.bz2
16 https
://matt.ucc.asn.au
/dropbear
/releases
/ \
17 https
://dropbear.nl
/mirror
/releases
/
18 PKG_HASH
:=bc5a121ffbc94b5171ad5ebe01be42746d50aa797c9549a4639894a16749443b
21 PKG_LICENSE_FILES
:=LICENSE libtomcrypt
/LICENSE libtommath
/LICENSE
22 PKG_CPE_ID
:=cpe
:/a
:matt_johnston
:dropbear_ssh_server
25 PKG_ASLR_PIE_REGULAR
:=1
26 PKG_BUILD_FLAGS
:=no-mips16 gc-sections lto
30 PKG_CONFIG_DEPENDS
:= \
31 CONFIG_TARGET_INIT_PATH CONFIG_DROPBEAR_ECC CONFIG_DROPBEAR_ECC_FULL \
32 CONFIG_DROPBEAR_CURVE25519 CONFIG_DROPBEAR_ZLIB \
33 CONFIG_DROPBEAR_ED25519 CONFIG_DROPBEAR_CHACHA20POLY1305 \
34 CONFIG_DROPBEAR_UTMP CONFIG_DROPBEAR_PUTUTLINE \
35 CONFIG_DROPBEAR_DBCLIENT CONFIG_DROPBEAR_SCP CONFIG_DROPBEAR_ASKPASS \
36 CONFIG_DROPBEAR_DBCLIENT_AGENTFORWARD CONFIG_DROPBEAR_AGENTFORWARD
38 include $(INCLUDE_DIR
)/package.mk
41 STAMP_CONFIGURED
:=$(strip $(STAMP_CONFIGURED
))_
$(shell echo
$(CONFIG_TARGET_INIT_PATH
) |
$(MKHASH
) md5
)
44 define Package
/dropbear
/Default
45 URL
:=https
://matt.ucc.asn.au
/dropbear
/
48 define Package
/dropbear
/config
49 source
"$(SOURCE)/Config.in"
52 define Package
/dropbear
53 $(call Package
/dropbear
/Default
)
56 TITLE
:=Small SSH2 client
/server
57 DEPENDS
:= +DROPBEAR_ZLIB
:zlib
59 $(if
$(CONFIG_DROPBEAR_SCP
),ALTERNATIVES
+= \
60 100:/usr
/bin
/scp
:/usr
/sbin
/dropbear
,)
61 $(if
$(CONFIG_DROPBEAR_DBCLIENT
),ALTERNATIVES
+= \
62 100:/usr
/bin
/ssh
:/usr
/sbin
/dropbear
,)
66 define Package
/dropbear
/description
67 A small SSH2 server
/client designed for small memory environments.
70 define Package
/dropbear
/conffiles
71 $(if
$(CONFIG_DROPBEAR_ED25519
),/etc
/dropbear
/dropbear_ed25519_host_key
)
72 $(if
$(CONFIG_DROPBEAR_ECC
),/etc
/dropbear
/dropbear_ecdsa_host_key
)
73 /etc
/dropbear
/dropbear_rsa_host_key
77 define Package
/dropbearconvert
78 $(call Package
/dropbear
/Default
)
81 TITLE
:=Utility for converting SSH keys
82 DEPENDS
:= +DROPBEAR_ZLIB
:zlib
91 $(if
$(CONFIG_DROPBEAR_UTMP
),,--disable-utmp
) \
95 $(if
$(CONFIG_DROPBEAR_PUTUTLINE
),,--disable-pututline
) \
96 --disable-pututxline \
97 $(if
$(CONFIG_DROPBEAR_ZLIB
),,--disable-zlib
) \
98 --enable-bundled-libtom
100 ##############################################################################
102 # option,value - add option to localoptions.h
103 # !!option,value - replace option in sysoptions.h
105 ##############################################################################
107 # adjust allowed shell list (if getusershell(3) is missing):
108 # - COMPAT_USER_SHELLS
109 # remove protocol idented software version number:
111 # disable legacy/unsafe methods and unused functionality:
112 # - DROPBEAR_CLI_NETCAT
115 # - DROPBEAR_DH_GROUP14_SHA1
116 # - DROPBEAR_SHA1_HMAC
118 !!LOCAL_IDENT
,"SSH-2.0-dropbear" \
119 COMPAT_USER_SHELLS
,"/bin/ash","/bin/sh" \
120 DEFAULT_PATH
,"$(TARGET_INIT_PATH)" \
121 DEFAULT_ROOT_PATH
,"$(TARGET_INIT_PATH)" \
123 DROPBEAR_CLI_NETCAT
,0 \
125 DROPBEAR_DH_GROUP14_SHA1
,0 \
126 DROPBEAR_SHA1_HMAC
,0 \
129 ##############################################################################
131 # option,config,enabled,disabled = add option to localoptions.h
132 # !!option,config,enabled,disabled = replace option in sysoptions.h
134 # option := (config) ? enabled : disabled
136 ##############################################################################
139 !!DROPBEAR_ECC_384
,CONFIG_DROPBEAR_ECC_FULL
,1,0 \
140 !!DROPBEAR_ECC_521
,CONFIG_DROPBEAR_ECC_FULL
,1,0 \
141 DROPBEAR_CURVE25519
,CONFIG_DROPBEAR_CURVE25519
,1,0 \
142 DROPBEAR_CHACHA20POLY1305
,CONFIG_DROPBEAR_CHACHA20POLY1305
,1,0 \
143 DROPBEAR_ED25519
,CONFIG_DROPBEAR_ED25519
,1,0 \
144 DROPBEAR_SK_ED25519
,CONFIG_DROPBEAR_ED25519
,1,0 \
145 DROPBEAR_ECDSA
,CONFIG_DROPBEAR_ECC
,1,0 \
146 DROPBEAR_SK_ECDSA
,CONFIG_DROPBEAR_ECC
,1,0 \
147 DROPBEAR_ECDH
,CONFIG_DROPBEAR_ECC
,1,0 \
148 DROPBEAR_CLI_ASKPASS_HELPER
,CONFIG_DROPBEAR_ASKPASS
,1,0 \
149 DROPBEAR_CLI_AGENTFWD
,CONFIG_DROPBEAR_DBCLIENT_AGENTFORWARD
,1,0 \
150 DROPBEAR_SVR_AGENTFWD
,CONFIG_DROPBEAR_AGENTFORWARD
,1,0 \
153 TARGET_CFLAGS
+= -DARGTYPE
=3
155 xsedx
:=$(shell printf
'\027')
157 db_opt_add
=echo
'\#define $(1) $(2)' >> $(PKG_BUILD_DIR
)/localoptions.h
158 db_opt_replace
=$(ESED
) '/^\#define $(1) .*$$$$/{h;:a;$$$$!n;/^\#.+$$$$/bb;/^$$$$/bb;H;ba;:b;x;s$(xsedx)^.+$$$$$(xsedx)\#define $(1) $(2)$(xsedx)p;x};p' -n
$(PKG_BUILD_DIR
)/sysoptions.h
160 define Build
/Configure
/dropbear_headers
161 $(strip $(foreach s
,$(DB_OPT_COMMON
), \
162 $(if
$(filter !!%,$(word 1,$(subst $(comma
),$(space
),$(s
)))), \
163 $(call db_opt_replace
,$(patsubst !!%,%,$(word 1,$(subst $(comma
),$(space
),$(s
)))),$(subst $(space
),$(comma
),$(wordlist
2,$(words $(subst $(comma
),$(space
),$(s
))),$(subst $(comma
),$(space
),$(s
))))), \
164 $(call db_opt_add
,$(word 1,$(subst $(comma
),$(space
),$(s
))),$(subst $(space
),$(comma
),$(wordlist
2,$(words $(subst $(comma
),$(space
),$(s
))),$(subst $(comma
),$(space
),$(s
))))) \
168 $(strip $(foreach s
,$(DB_OPT_CONFIG
), \
169 $(if
$(filter !!%,$(word 1,$(subst $(comma
),$(space
),$(s
)))), \
170 $(call db_opt_replace
,$(patsubst !!%,%,$(word 1,$(subst $(comma
),$(space
),$(s
)))),$(if
$($(word 2,$(subst $(comma
),$(space
),$(s
)))),$(word 3,$(subst $(comma
),$(space
),$(s
))),$(word 4,$(subst $(comma
),$(space
),$(s
))))), \
171 $(call db_opt_add
,$(word 1,$(subst $(comma
),$(space
),$(s
))),$(if
$($(word 2,$(subst $(comma
),$(space
),$(s
)))),$(word 3,$(subst $(comma
),$(space
),$(s
))),$(word 4,$(subst $(comma
),$(space
),$(s
))))) \
176 define Build
/Configure
/dropbear_objects
177 grep
-ERZl
-e
'($(subst $(space),|,$(strip $(sort $(patsubst !!%,%,$(foreach s,$(DB_OPT_COMMON) $(DB_OPT_CONFIG),$(word 1,$(subst $(comma),$(space),$(s)))))))))' \
178 $(PKG_BUILD_DIR
)/ | sed
-zE
's/^(.+)\.[^.]+$$$$/\1.o/' |
sort -uV | xargs
-0 -r
rm -fv ||
:
181 define Build
/Configure
182 rm -f
$(PKG_BUILD_DIR
)/localoptions.h
183 $(Build
/Configure
/Default
)
185 : > $(PKG_BUILD_DIR
)/localoptions.h
186 $(Build
/Configure
/dropbear_headers
)
188 # Enforce rebuild of files depending on configured options
189 $(Build
/Configure
/dropbear_objects
)
191 # Rebuild them on config change
192 +$(MAKE
) -C
$(PKG_BUILD_DIR
)/libtomcrypt
clean
193 +$(MAKE
) -C
$(PKG_BUILD_DIR
)/libtommath
clean
197 +$(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
) \
198 $(TARGET_CONFIGURE_OPTS
) \
200 PROGRAMS
="dropbear $(if $(CONFIG_DROPBEAR_DBCLIENT),dbclient,) dropbearkey $(if $(CONFIG_DROPBEAR_SCP),scp,)" \
201 MULTI
=1 SCPPROGRESS
=1
202 +$(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
) \
203 $(TARGET_CONFIGURE_OPTS
) \
205 PROGRAMS
="dropbearconvert"
208 define Package
/dropbear
/install
209 $(INSTALL_DIR
) $(1)/usr
/sbin
210 $(INSTALL_BIN
) $(PKG_BUILD_DIR
)/dropbearmulti
$(1)/usr
/sbin
/dropbear
211 $(INSTALL_DIR
) $(1)/usr
/bin
212 $(if
$(CONFIG_DROPBEAR_DBCLIENT
),$(LN
) ..
/sbin
/dropbear
$(1)/usr
/bin
/dbclient
,)
213 $(LN
) ..
/sbin
/dropbear
$(1)/usr
/bin
/dropbearkey
214 $(INSTALL_DIR
) $(1)/etc
/config
215 $(INSTALL_CONF
) .
/files
/dropbear.config
$(1)/etc
/config
/dropbear
216 $(INSTALL_DIR
) $(1)/etc
/init.d
217 $(INSTALL_BIN
) .
/files
/dropbear.init
$(1)/etc
/init.d
/dropbear
218 $(INSTALL_DIR
) $(1)/usr
/lib
/opkg
/info
219 $(INSTALL_DIR
) $(1)/etc
/dropbear
220 $(INSTALL_DIR
) $(1)/lib
/preinit
221 $(INSTALL_DATA
) .
/files
/dropbear.failsafe
$(1)/lib
/preinit
/99_10_failsafe_dropbear
222 $(if
$(CONFIG_DROPBEAR_ED25519
),touch
$(1)/etc
/dropbear
/dropbear_ed25519_host_key
)
223 $(if
$(CONFIG_DROPBEAR_ECC
),touch
$(1)/etc
/dropbear
/dropbear_ecdsa_host_key
)
224 touch
$(1)/etc
/dropbear
/dropbear_rsa_host_key
227 define Package
/dropbearconvert
/install
228 $(INSTALL_DIR
) $(1)/usr
/bin
229 $(INSTALL_BIN
) $(PKG_BUILD_DIR
)/dropbearconvert
$(1)/usr
/bin
/dropbearconvert
232 $(eval
$(call BuildPackage
,dropbear
))
233 $(eval
$(call BuildPackage
,dropbearconvert
))