dropbear.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ################################################################################
  2. #
  3. # dropbear
  4. #
  5. ################################################################################
  6. DROPBEAR_VERSION = 2024.85
  7. DROPBEAR_SITE = https://matt.ucc.asn.au/dropbear/releases
  8. DROPBEAR_SOURCE = dropbear-$(DROPBEAR_VERSION).tar.bz2
  9. DROPBEAR_LICENSE = MIT, BSD-2-Clause, Public domain
  10. DROPBEAR_LICENSE_FILES = LICENSE
  11. DROPBEAR_TARGET_BINS = dropbearkey dropbearconvert scp
  12. DROPBEAR_PROGRAMS = dropbear $(DROPBEAR_TARGET_BINS)
  13. DROPBEAR_CPE_ID_VENDOR = dropbear_ssh_project
  14. DROPBEAR_CPE_ID_PRODUCT = dropbear_ssh
  15. # Disable hardening flags added by dropbear configure.ac, and let
  16. # Buildroot add them when the relevant options are enabled. This
  17. # prevents dropbear from using SSP support when not available.
  18. DROPBEAR_CONF_OPTS = --disable-harden
  19. ifeq ($(BR2_PACKAGE_DROPBEAR_CLIENT),y)
  20. # Build dbclient, and create a convenience symlink named ssh
  21. DROPBEAR_PROGRAMS += dbclient
  22. DROPBEAR_TARGET_BINS += dbclient ssh
  23. endif
  24. DROPBEAR_MAKE = \
  25. $(MAKE) MULTI=1 SCPPROGRESS=1 \
  26. PROGRAMS="$(DROPBEAR_PROGRAMS)"
  27. # With BR2_SHARED_STATIC_LIBS=y the generic infrastructure adds a
  28. # --enable-static flags causing dropbear to be built as a static
  29. # binary. Adding a --disable-static reverts this
  30. ifeq ($(BR2_SHARED_STATIC_LIBS),y)
  31. DROPBEAR_CONF_OPTS += --disable-static
  32. endif
  33. ifeq ($(BR2_PACKAGE_LINUX_PAM),y)
  34. define DROPBEAR_SVR_PAM_AUTH
  35. echo '#define DROPBEAR_SVR_PASSWORD_AUTH 0' >> $(@D)/localoptions.h
  36. echo '#define DROPBEAR_SVR_PAM_AUTH 1' >> $(@D)/localoptions.h
  37. endef
  38. define DROPBEAR_INSTALL_PAM_CONF
  39. $(INSTALL) -D -m 644 package/dropbear/etc-pam.d-sshd $(TARGET_DIR)/etc/pam.d/sshd
  40. endef
  41. DROPBEAR_DEPENDENCIES += linux-pam
  42. DROPBEAR_CONF_OPTS += --enable-pam
  43. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_SVR_PAM_AUTH
  44. DROPBEAR_POST_INSTALL_TARGET_HOOKS += DROPBEAR_INSTALL_PAM_CONF
  45. else
  46. # Ensure that dropbear doesn't use crypt() when it's not available
  47. define DROPBEAR_SVR_PASSWORD_AUTH
  48. echo '#if !HAVE_CRYPT' >> $(@D)/localoptions.h
  49. echo '#define DROPBEAR_SVR_PASSWORD_AUTH 0' >> $(@D)/localoptions.h
  50. echo '#endif' >> $(@D)/localoptions.h
  51. endef
  52. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_SVR_PASSWORD_AUTH
  53. endif
  54. ifeq ($(BR2_PACKAGE_DROPBEAR_LEGACY_CRYPTO),y)
  55. define DROPBEAR_ENABLE_LEGACY_CRYPTO
  56. echo '#define DROPBEAR_3DES 1' >> $(@D)/localoptions.h
  57. echo '#define DROPBEAR_ENABLE_CBC_MODE 1' >> $(@D)/localoptions.h
  58. echo '#define DROPBEAR_SHA1_96_HMAC 1' >> $(@D)/localoptions.h
  59. echo '#define DROPBEAR_DH_GROUP1 1' >> $(@D)/localoptions.h
  60. echo '#define DROPBEAR_DSS 1' >> $(@D)/localoptions.h
  61. endef
  62. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_ENABLE_LEGACY_CRYPTO
  63. endif
  64. ifeq ($(BR2_PACKAGE_DROPBEAR_DISABLE_REVERSEDNS),)
  65. define DROPBEAR_ENABLE_REVERSE_DNS
  66. echo '#define DO_HOST_LOOKUP 1' >> $(@D)/localoptions.h
  67. endef
  68. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_ENABLE_REVERSE_DNS
  69. endif
  70. ifeq ($(BR2_PACKAGE_DROPBEAR_SMALL),y)
  71. DROPBEAR_LICENSE += , Unlicense, WTFPL
  72. DROPBEAR_LICENSE_FILES += libtommath/LICENSE libtomcrypt/LICENSE
  73. DROPBEAR_CONF_OPTS += --disable-zlib --enable-bundled-libtom
  74. else
  75. define DROPBEAR_BUILD_FEATURED
  76. echo '#define DROPBEAR_SMALL_CODE 0' >> $(@D)/localoptions.h
  77. endef
  78. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_BUILD_FEATURED
  79. DROPBEAR_DEPENDENCIES += zlib libtomcrypt
  80. DROPBEAR_CONF_OPTS += --disable-bundled-libtom
  81. endif
  82. define DROPBEAR_CUSTOM_PATH
  83. echo '#define DEFAULT_PATH $(BR2_SYSTEM_DEFAULT_PATH)' >>$(@D)/localoptions.h
  84. endef
  85. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_CUSTOM_PATH
  86. define DROPBEAR_INSTALL_INIT_SYSTEMD
  87. $(INSTALL) -D -m 644 package/dropbear/dropbear.service \
  88. $(TARGET_DIR)/usr/lib/systemd/system/dropbear.service
  89. endef
  90. ifeq ($(BR2_USE_MMU),y)
  91. define DROPBEAR_INSTALL_INIT_SYSV
  92. $(INSTALL) -D -m 755 package/dropbear/S50dropbear \
  93. $(TARGET_DIR)/etc/init.d/S50dropbear
  94. endef
  95. else
  96. define DROPBEAR_DISABLE_STANDALONE
  97. echo '#define NON_INETD_MODE 0' >> $(@D)/localoptions.h
  98. endef
  99. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_DISABLE_STANDALONE
  100. endif
  101. ifneq ($(BR2_PACKAGE_DROPBEAR_WTMP),y)
  102. DROPBEAR_CONF_OPTS += --disable-wtmp
  103. endif
  104. ifneq ($(BR2_PACKAGE_DROPBEAR_LASTLOG),y)
  105. DROPBEAR_CONF_OPTS += --disable-lastlog
  106. endif
  107. DROPBEAR_LOCALOPTIONS_FILE = $(call qstrip,$(BR2_PACKAGE_DROPBEAR_LOCALOPTIONS_FILE))
  108. ifneq ($(DROPBEAR_LOCALOPTIONS_FILE),)
  109. define DROPBEAR_APPEND_LOCALOPTIONS_FILE
  110. cat $(DROPBEAR_LOCALOPTIONS_FILE) >> $(@D)/localoptions.h
  111. endef
  112. DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_APPEND_LOCALOPTIONS_FILE
  113. endif
  114. define DROPBEAR_INSTALL_TARGET_CMDS
  115. $(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear
  116. for f in $(DROPBEAR_TARGET_BINS); do \
  117. ln -snf ../sbin/dropbear $(TARGET_DIR)/usr/bin/$$f ; \
  118. done
  119. ln -snf /var/run/dropbear $(TARGET_DIR)/etc/dropbear
  120. endef
  121. $(eval $(autotools-package))