diff mbox series

package: dropbear: add support for displaying /etc/motd

Message ID 20190523121115.26098-1-ardeleanalex@gmail.com
State Changes Requested
Headers show
Series package: dropbear: add support for displaying /etc/motd | expand

Commit Message

Alexandru Ardelean May 23, 2019, 12:11 p.m. UTC
When dropbear changed the way how to configure things, by providing a
`localoptions.h` file, it also defaulted (somehow) to disable the display
of /etc/motd by default.

This can be configured by adding a `#define DO_MOTD 1` in the
`localoptions.h`, which requires it's own `BR2_PACKAGE_DROPBEAR_MOTD`
Kconfig option.

By default, support for displaying `/etc/motd` on login is disabled.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
---
 package/dropbear/Config.in   | 6 ++++++
 package/dropbear/dropbear.mk | 8 ++++++++
 2 files changed, 14 insertions(+)

Comments

Thomas Petazzoni May 23, 2019, 12:28 p.m. UTC | #1
Hello Alexandru,

On Thu, 23 May 2019 15:11:15 +0300
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:

> When dropbear changed the way how to configure things, by providing a
> `localoptions.h` file, it also defaulted (somehow) to disable the display
> of /etc/motd by default.
> 
> This can be configured by adding a `#define DO_MOTD 1` in the
> `localoptions.h`, which requires it's own `BR2_PACKAGE_DROPBEAR_MOTD`
> Kconfig option.
> 
> By default, support for displaying `/etc/motd` on login is disabled.
> 
> Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>

Thanks for your patch.

> +config BR2_PACKAGE_DROPBEAR_MOTD
> +	bool "display motd on login"
> +	help
> +	  Add support for displaying the contents of /etc/motd
> +	  when a user logs into a SSH session.

In fact, I am a bit worried by all those additional dropbear options to
tweak "minor" details of the dropbear configuration.

Perhaps we should bite the bullet and add an option like this:

config BR2_PACKAGE_DROPBEAR_CONFIG_FILE
	string "path to dropbear config file"
	help
	  Path to a file whose contents will be appended to Dropbear
	  localoptions.h. It can be used to tweak the Dropbear
	  configuration.

And then, in the .mk:

DROPBEAR_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_DROPBEAR_CONFIG_FILE))
ifneq ($(DROPBEAR_CONFIG_FILE),)
define DROPBEAR_APPEND_CONFIG_FILE
	cat $(DROPBEAR_CONFIG_FILE) >> $(@D)/localoptions.h
endef
DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_APPEND_CONFIG_FILE
endif

This way, we have something that is much more flexible, as it allows
you to define whatever Dropbear option you like.

Note: this is just a suggestion; I don't know what other
maintainers/developers will think about it.

Best regards,

Thomas
Alexandru Ardelean May 23, 2019, 1 p.m. UTC | #2
On Thu, May 23, 2019 at 3:28 PM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello Alexandru,
>
> On Thu, 23 May 2019 15:11:15 +0300
> Alexandru Ardelean <ardeleanalex@gmail.com> wrote:
>
> > When dropbear changed the way how to configure things, by providing a
> > `localoptions.h` file, it also defaulted (somehow) to disable the display
> > of /etc/motd by default.
> >
> > This can be configured by adding a `#define DO_MOTD 1` in the
> > `localoptions.h`, which requires it's own `BR2_PACKAGE_DROPBEAR_MOTD`
> > Kconfig option.
> >
> > By default, support for displaying `/etc/motd` on login is disabled.
> >
> > Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
>
> Thanks for your patch.
>
> > +config BR2_PACKAGE_DROPBEAR_MOTD
> > +     bool "display motd on login"
> > +     help
> > +       Add support for displaying the contents of /etc/motd
> > +       when a user logs into a SSH session.
>
> In fact, I am a bit worried by all those additional dropbear options to
> tweak "minor" details of the dropbear configuration.
>
> Perhaps we should bite the bullet and add an option like this:
>
> config BR2_PACKAGE_DROPBEAR_CONFIG_FILE
>         string "path to dropbear config file"
>         help
>           Path to a file whose contents will be appended to Dropbear
>           localoptions.h. It can be used to tweak the Dropbear
>           configuration.
>
> And then, in the .mk:
>
> DROPBEAR_CONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_DROPBEAR_CONFIG_FILE))
> ifneq ($(DROPBEAR_CONFIG_FILE),)
> define DROPBEAR_APPEND_CONFIG_FILE
>         cat $(DROPBEAR_CONFIG_FILE) >> $(@D)/localoptions.h
> endef
> DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_APPEND_CONFIG_FILE
> endif
>

I'd be fine with this approach as well.

> This way, we have something that is much more flexible, as it allows
> you to define whatever Dropbear option you like.
>
> Note: this is just a suggestion; I don't know what other
> maintainers/developers will think about it.
>
> Best regards,
>

Thanks
Alex

> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Peter Korsgaard May 23, 2019, 1:18 p.m. UTC | #3
>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:

Hi,

 > This way, we have something that is much more flexible, as it allows
 > you to define whatever Dropbear option you like.

 > Note: this is just a suggestion; I don't know what other
 > maintainers/developers will think about it.

Agreed, if we want such finegrained configuration then that would be the
way to go.
Peter Korsgaard May 24, 2019, 7:50 a.m. UTC | #4
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:

>>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:
 > Hi,

 >> This way, we have something that is much more flexible, as it allows
 >> you to define whatever Dropbear option you like.

 >> Note: this is just a suggestion; I don't know what other
 >> maintainers/developers will think about it.

 > Agreed, if we want such finegrained configuration then that would be the
 > way to go.

Alexandru, will you send such a patch? In the mean time I have marked
this patch as changes requested in patchwork.
Alexandru Ardelean May 29, 2019, 6:51 a.m. UTC | #5
On Fri, May 24, 2019 at 10:50 AM Peter Korsgaard <peter@korsgaard.com> wrote:
>
> >>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
>
> >>>>> "Thomas" == Thomas Petazzoni <thomas.petazzoni@bootlin.com> writes:
>  > Hi,
>
>  >> This way, we have something that is much more flexible, as it allows
>  >> you to define whatever Dropbear option you like.
>
>  >> Note: this is just a suggestion; I don't know what other
>  >> maintainers/developers will think about it.
>
>  > Agreed, if we want such finegrained configuration then that would be the
>  > way to go.
>
> Alexandru, will you send such a patch? In the mean time I have marked
> this patch as changes requested in patchwork.

Yes.

Sorry for the late reply.
I left the thread unread (I do it as personal task-tracker), and I did
not notice this mail.

Thanks
Alex

>
> --
> Bye, Peter Korsgaard
diff mbox series

Patch

diff --git a/package/dropbear/Config.in b/package/dropbear/Config.in
index 62f77bad9d..936379d10c 100644
--- a/package/dropbear/Config.in
+++ b/package/dropbear/Config.in
@@ -56,6 +56,12 @@  config BR2_PACKAGE_DROPBEAR_LASTLOG
 	  Enable logging of dropbear access to lastlog. Notice that
 	  Buildroot does not generate lastlog by default.
 
+config BR2_PACKAGE_DROPBEAR_MOTD
+	bool "display motd on login"
+	help
+	  Add support for displaying the contents of /etc/motd
+	  when a user logs into a SSH session.
+
 config BR2_PACKAGE_DROPBEAR_LEGACY_CRYPTO
 	bool "enable legacy crypto"
 	help
diff --git a/package/dropbear/dropbear.mk b/package/dropbear/dropbear.mk
index e10c851606..d16b578b2d 100644
--- a/package/dropbear/dropbear.mk
+++ b/package/dropbear/dropbear.mk
@@ -71,6 +71,10 @@  define DROPBEAR_ENABLE_REVERSE_DNS
 	echo '#define DO_HOST_LOOKUP 1'                 >> $(@D)/localoptions.h
 endef
 
+define DROPBEAR_ENABLE_MOTD
+	echo '#define DO_MOTD 1'                        >> $(@D)/localoptions.h
+endef
+
 define DROPBEAR_BUILD_FEATURED
 	echo '#define DROPBEAR_SMALL_CODE 0'            >> $(@D)/localoptions.h
 	echo '#define DROPBEAR_TWOFISH128 1'            >> $(@D)/localoptions.h
@@ -124,6 +128,10 @@  ifneq ($(BR2_PACKAGE_DROPBEAR_LASTLOG),y)
 DROPBEAR_CONF_OPTS += --disable-lastlog
 endif
 
+ifeq ($(BR2_PACKAGE_DROPBEAR_MOTD),y)
+DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_ENABLE_MOTD
+endif
+
 define DROPBEAR_INSTALL_TARGET_CMDS
 	$(INSTALL) -m 755 $(@D)/dropbearmulti $(TARGET_DIR)/usr/sbin/dropbear
 	for f in $(DROPBEAR_TARGET_BINS); do \