Skip to contentSkip to conversation

package/sudo: removed template config, added convenient 'sudo' group config options.

PATCH New Stephan Henningsen 3 participants 8 messages Oct 23, 2019 – Oct 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

---
 package/sudo/Config.in | 21 ++++++++++++++++++++-
 package/sudo/sudo.mk   | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
package/sudo/Config.in +20 -1
index cbef15d67b..aee077fe3b 100644
@@ -1,4 +1,4 @@
-config BR2_PACKAGE_SUDO
+menuconfig BR2_PACKAGE_SUDO
 	bool "sudo"
 	# uses fork()
 	depends on BR2_USE_MMU
@@ -9,3 +9,22 @@ config BR2_PACKAGE_SUDO
 	  but still allow people to get their work done.
 
 	  http://www.sudo.ws/sudo/
+
+
+if BR2_PACKAGE_SUDO
+
+config BR2_PACKAGE_SUDO_GROUP
+	bool "add system group 'sudo'"
+	help
+	  Create a convenient system group named 'sudo' for
+	  granting users sudo permissions.
+
+config BR2_PACKAGE_SUDO_GROUP_RULE
+	bool "allow member of group 'sudo' to execute any command."
+	select BR2_PACKAGE_SUDO_GROUP
+	help
+	  Reinserts this rule from the /etc/sudoers configuration file:
+
+	  %sudo ALL=(ALL) ALL
+
+endif
package/sudo/sudo.mk +20 -0
index cf8b63b1db..34b1869e98 100644
@@ -64,4 +64,24 @@ define SUDO_PERMISSIONS
 	/usr/bin/sudo f 4755 0 0 - - - - -
 endef
 
+ifeq ($(BR2_PACKAGE_SUDO_GROUP_RULE),y)
+define SUDO_ENABLE_SUDO_GROUP_RULE
+sed -e '/^# \%sudo\tALL=(ALL) ALL/s/^# //' -i $(TARGET_DIR)/etc/sudoers
+endef
+SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_ENABLE_SUDO_GROUP_RULE
+endif
+
+
+ifeq ($(BR2_PACKAGE_SUDO_GROUP),y)
+define SUDO_USERS
+    -               -1   sudo            -1   -             -            -         -
+endef
+endif
+
+define SUDO_REMOVE_GARBAGE
+	$(RM) -fv $(TARGET_DIR)/etc/sudoers.dist # Remove stray example file
+	$(RM) -frv $(TARGET_DIR)/etc/sudoers.d # Remove unused configuration directory
+endef
+SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_REMOVE_GARBAGE
+
 $(eval $(autotools-package))
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

Hi Stephan,

Thank you for this patch. I have a few comments, could you respin your patch
taking them into account?

package/sudo/Config.in line 1

Quoted 13 lines · Stephan Henningsen
---
 package/sudo/Config.in | 21 ++++++++++++++++++++-
 package/sudo/sudo.mk   | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
package/sudo/Config.in +1 -1
index cbef15d67b..aee077fe3b 100644
@@ -1,4 +1,4 @@
-config BR2_PACKAGE_SUDO
+menuconfig BR2_PACKAGE_SUDO

With just a few sub-options, it's not worth making an additional menu. Kconfig
will indent the sub-options when they're conditional on the immediately preceding symbol, as is the case here. That's enough.

Quoted 14 lines
package/sudo/Config.in +7 -0
 	bool "sudo"
 	# uses fork()
 	depends on BR2_USE_MMU
@@ -9,3 +9,22 @@ config BR2_PACKAGE_SUDO
 	  but still allow people to get their work done.
 
 	  http://www.sudo.ws/sudo/
+
+
+if BR2_PACKAGE_SUDO
+
+config BR2_PACKAGE_SUDO_GROUP
+	bool "add system group 'sudo'"
+	help

package/sudo/Config.in config BR2_PACKAGE_SUDO · line 28

Quoted 10 lines
package/sudo/Config.in +10 -0
+	  Create a convenient system group named 'sudo' for
+	  granting users sudo permissions.
+
+config BR2_PACKAGE_SUDO_GROUP_RULE
+	bool "allow member of group 'sudo' to execute any command."
+	select BR2_PACKAGE_SUDO_GROUP
+	help
+	  Reinserts this rule from the /etc/sudoers configuration file:
+
+	  %sudo ALL=(ALL) ALL

Does it really make sense to have separate options for these two aspects? If
you add a sudo group, it's most likely because you have something like that in your sudoers file. Without this option, you'll anyway need a custom sudoers file so it's pretty much irrelevant what you have in it.

In fact, does it make sense to have the sudo group optional to begin with?

Quoted 15 lines
package/sudo/Config.in +2 -0
+
+endif
package/sudo/sudo.mk +5 -0
index cf8b63b1db..34b1869e98 100644
@@ -64,4 +64,24 @@ define SUDO_PERMISSIONS
 	/usr/bin/sudo f 4755 0 0 - - - - -
 endef
 
+ifeq ($(BR2_PACKAGE_SUDO_GROUP_RULE),y)
+define SUDO_ENABLE_SUDO_GROUP_RULE
+sed -e '/^# \%sudo\tALL=(ALL) ALL/s/^# //' -i $(TARGET_DIR)/etc/sudoers
+endef
+SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_ENABLE_SUDO_GROUP_RULE

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 81

Quoted 10 lines
package/sudo/sudo.mk +10 -0
+endif
+
+
+ifeq ($(BR2_PACKAGE_SUDO_GROUP),y)
+define SUDO_USERS
+    -               -1   sudo            -1   -             -            -         -
+endef
+endif
+
+define SUDO_REMOVE_GARBAGE

Please split this into two patches, because they're doing two separate,
unrelated things. In fact, your commit message already suggests this because you say "this and that".

Speaking of the commit message: it should use imperative (remove, add) and
should not end with a dot (at least the summary line shouldn't).

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 82

Quoted 1 line
package/sudo/sudo.mk +1 -0
+	$(RM) -fv $(TARGET_DIR)/etc/sudoers.dist # Remove stray example file

$(RM) already has the -f, and the -v is not neded. Also the comment is not needed.

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 83

Quoted 1 line
package/sudo/sudo.mk +1 -0
+	$(RM) -frv $(TARGET_DIR)/etc/sudoers.d # Remove unused configuration directory

We don't usually remove those empty .d directories, but it's true that there's
no good reason to have it there.

Maybe you could use -rmdir instead, because the directory is supposed to be
empty and if it's not, it's probably not a good idea to remove it (e.g. because the skeleton installed something in it, or some other package that uses sudo and that was installed before because it only has a runtime dependency).

Regards,
Arnout

Quoted 5 lines
package/sudo/sudo.mk +3 -0
+endef
+SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_REMOVE_GARBAGE
+
 $(eval $(autotools-package))
#2 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

Hey,

Quoted 6 lines · Arnout Vandecappelle

Hi Stephan,

Thank you for this patch. I have a few comments, could you respin your
patch
taking them into account?

I'll get back to this in about a week.

Quoted 6 lines · Stephan Henningsen
Quoted 6 lines
---
 package/sudo/Config.in | 21 ++++++++++++++++++++-
 package/sudo/sudo.mk   | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
Quoted 13 lines

package/sudo/Config.in line 1

Quoted 7 lines
package/sudo/Config.in +1 -1
index cbef15d67b..aee077fe3b 100644
@@ -1,4 +1,4 @@
-config BR2_PACKAGE_SUDO
+menuconfig BR2_PACKAGE_SUDO

With just a few sub-options, it's not worth making an additional menu.
Kconfig
will indent the sub-options when they're conditional on the immediately preceding symbol, as is the case here. That's enough.

Will do. I did this to prevent the package list from being cluttered.

Quoted 7 lines
Quoted 7 lines
package/sudo/Config.in +7 -0
+config BR2_PACKAGE_SUDO_GROUP
+     bool "add system group 'sudo'"
+     help
+       Create a convenient system group named 'sudo' for
+       granting users sudo permissions.
+
+config BR2_PACKAGE_SUDO_GROUP_RULE
Quoted 8 lines

package/sudo/Config.in config BR2_PACKAGE_SUDO · line 28

Quoted 6 lines
package/sudo/Config.in +6 -0
+     bool "allow member of group 'sudo' to execute any command."
+     select BR2_PACKAGE_SUDO_GROUP
+     help
+       Reinserts this rule from the /etc/sudoers configuration file:
+
+       %sudo ALL=(ALL) ALL

Does it really make sense to have separate options for these two aspects?

If you add a sudo group, it's most likely because you have something like

Quoted 7 lines

that in
your sudoers file. Without this option, you'll anyway need a custom sudoers file
so it's pretty much irrelevant what you have in it.

In fact, does it make sense to have the sudo group optional to begin with?

I know that I'm always checking both on my system, so I'm perfectly fine by merging the two options into one.

Quoted 22 lines

+

Quoted 10 lines
package/sudo/Config.in +1 -0
+endif
package/sudo/sudo.mk +1 -0
index cf8b63b1db..34b1869e98 100644
@@ -64,4 +64,24 @@ define SUDO_PERMISSIONS
      /usr/bin/sudo f 4755 0 0 - - - - -
 endef
 
+ifeq ($(BR2_PACKAGE_SUDO_GROUP_RULE),y)

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 77

Quoted 10 lines
package/sudo/sudo.mk +10 -0
+define SUDO_ENABLE_SUDO_GROUP_RULE
+sed -e '/^# \%sudo\tALL=(ALL) ALL/s/^# //' -i $(TARGET_DIR)/etc/sudoers
+endef
+SUDO_POST_INSTALL_TARGET_HOOKS += SUDO_ENABLE_SUDO_GROUP_RULE
+endif
+
+
+ifeq ($(BR2_PACKAGE_SUDO_GROUP),y)
+define SUDO_USERS
+    -               -1   sudo            -1   -             -

- -

Quoted 10 lines

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 81

Quoted 4 lines
package/sudo/sudo.mk +4 -0
+endef
+endif
+
+define SUDO_REMOVE_GARBAGE

Please split this into two patches, because they're doing two separate,
unrelated things. In fact, your commit message already suggests this because you
say "this and that".

You're right, I'll see to it.

Speaking of the commit message: it should use imperative (remove, add) and

Quoted 2 lines

should not end with a dot (at least the summary line shouldn't).

Right.

Quoted 13 lines

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 82

Quoted 1 line
package/sudo/sudo.mk +1 -0
+     $(RM) -fv $(TARGET_DIR)/etc/sudoers.dist # Remove stray example

file

$(RM) already has the -f, and the -v is not neded. Also the comment is
not needed.

package/sudo/sudo.mk define SUDO_PERMISSIONS · line 83

Quoted 1 line
package/sudo/sudo.mk +1 -0
+     $(RM) -frv $(TARGET_DIR)/etc/sudoers.d # Remove unused

configuration directory

We don't usually remove those empty .d directories, but it's true that
there's
no good reason to have it there.

Quoted 8 lines

Maybe you could use -rmdir instead, because the directory is supposed to
be
empty and if it's not, it's probably not a good idea to remove it (e.g. because
the skeleton installed something in it, or some other package that uses sudo and
that was installed before because it only has a runtime dependency).

Great idea, I'll take care of it.

Yours,
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20191024/8000b70e/attachment.html>

#3 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

In reply to Arnout Vandecappelle

Hello,

Quoted 3 lines · On Thu, 24 Oct 2019 00:15:01 +0200 Arnout Vandecappelle <[email protected]> wrote:

With just a few sub-options, it's not worth making an additional menu. Kconfig
will indent the sub-options when they're conditional on the immediately preceding symbol, as is the case here. That's enough.

Agreed.

Quoted 19 lines

package/sudo/Config.in config BR2_PACKAGE_SUDO · line 28

Quoted 13 lines
package/sudo/Config.in +13 -0
+config BR2_PACKAGE_SUDO_GROUP
+	bool "add system group 'sudo'"
+	help
+	  Create a convenient system group named 'sudo' for
+	  granting users sudo permissions.
+
+config BR2_PACKAGE_SUDO_GROUP_RULE
+	bool "allow member of group 'sudo' to execute any command."
+	select BR2_PACKAGE_SUDO_GROUP
+	help
+	  Reinserts this rule from the /etc/sudoers configuration file:
+
+	  %sudo ALL=(ALL) ALL  

Does it really make sense to have separate options for these two aspects? If
you add a sudo group, it's most likely because you have something like that in your sudoers file. Without this option, you'll anyway need a custom sudoers file so it's pretty much irrelevant what you have in it.

Quoted 1 line

In fact, does it make sense to have the sudo group optional to begin with?

I think we don't need any new option at all:

(1) Just create the sudo group unconditionally

(2) Leave the customization of the /etc/sudoers file to the user, through an overlay/post-build script. We cannot add zillions of options to customize all aspects of each package configuration.

Quoted 8 lines
Quoted 1 line

+define SUDO_REMOVE_GARBAGE

Please split this into two patches, because they're doing two separate,
unrelated things. In fact, your commit message already suggests this because you say "this and that".

Speaking of the commit message: it should use imperative (remove, add) and
should not end with a dot (at least the summary line shouldn't).

Agreed. Also please don't use "garbage", I think we can find a better word than garbage.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

Quoted 7 lines · Thomas Petazzoni
Quoted 3 lines
Quoted 3 lines

+config BR2_PACKAGE_SUDO_GROUP_RULE

I think we don't need any new option at all:

(1) Just create the sudo group unconditionally

I don't know about that. It wouldn't have any effect unless addition configuration was done, and so it would just be yet another unused system group filling up. That's why I agree that the two options should be combined.

Quoted 4 lines

(2) Leave the customization of the /etc/sudoers file to the user, through an overlay/post-build script. We cannot add zillions of options to customize all aspects of each package configuration.

I think it's fair to say that the option I've added is a pretty standard usage of sudo. It's how it works in Ubuntu and Debian. So I consider it a very important option of this package that would definitely add a very common sudo use case and therefore something useful to Buildroot.

Signature · 2 lines
Yours,
Stephan
#5 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

Quoted 21 lines · Stephan Henningsen
Quoted 7 lines · Thomas Petazzoni
Quoted 3 lines
Quoted 3 lines

+config BR2_PACKAGE_SUDO_GROUP_RULE

I think we don't need any new option at all:

(1) Just create the sudo group unconditionally

I don't know about that. It wouldn't have any effect unless addition configuration was done, and so it would just be yet another unused system group filling up. That's why I agree that the two options should be combined.

Quoted 4 lines

(2) Leave the customization of the /etc/sudoers file to the user, through an overlay/post-build script. We cannot add zillions of options to customize all aspects of each package configuration.

Quoted 5 lines

I think it's fair to say that the option I've added is a pretty standard usage of sudo. It's how it works in Ubuntu and Debian. So I consider it a very important option of this package that would definitely add a very common sudo use case and therefore something useful to Buildroot.

I agree with that. If there is a sudo group, the only reason to have it is to
make it sudo-able. In the unlikely case that it needs to be different, it can still be overridden in overlay.

I believe our principle should be: allow any user customisation, but make sure
that the out-of-the-box experience is as smooth as possible.

Obviously the out-of-the-box experience will still not be completely smooth
since there is no user in the sudo group, but it is still better than not having a sudoers entry at all.

So the only question is: should the addition of the sudo group be optional or
not? I see little reason to make it optional. Yes, it is yet another group, but that just costs a few bytes in /etc/groups (which in practice doesn't cost anything as long as the file stays under 4K).

Regards,
Arnout

#6 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

Quoted 7 lines · On Fri, 25 Oct 2019 10:10:51 +0200 Arnout Vandecappelle <[email protected]> wrote:

I agree with that. If there is a sudo group, the only reason to have it is to
make it sudo-able. In the unlikely case that it needs to be different, it can still be overridden in overlay.

I believe our principle should be: allow any user customisation, but make sure
that the out-of-the-box experience is as smooth as possible.

Quoted 8 lines

Obviously the out-of-the-box experience will still not be completely smooth
since there is no user in the sudo group, but it is still better than not having a sudoers entry at all.

So the only question is: should the addition of the sudo group be optional or
not? I see little reason to make it optional. Yes, it is yet another group, but that just costs a few bytes in /etc/groups (which in practice doesn't cost anything as long as the file stays under 4K).

I'd say let's make it non-optional.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#7 lore raw

PATCH 1/1 package/sudo: removed template config, added convenient 'sudo' group config options.

fre. 25. okt. 2019 10.15 skrev Thomas Petazzoni <
[email protected]>:

Quoted 20 lines
Quoted 1 line · On Fri, 25 Oct 2019 10:10:51 +0200 Arnout Vandecappelle <[email protected]> wrote:

I agree with that. If there is a sudo group, the only reason to have it

is to

Quoted 1 line

make it sudo-able. In the unlikely case that it needs to be different,

it can

Quoted 3 lines

still be overridden in overlay.

I believe our principle should be: allow any user customisation, but

make sure

Quoted 3 lines

that the out-of-the-box experience is as smooth as possible.

Obviously the out-of-the-box experience will still not be completely

smooth

Quoted 1 line

since there is no user in the sudo group, but it is still better than

not having

Quoted 3 lines

a sudoers entry at all.

So the only question is: should the addition of the sudo group be

Quoted 9 lines

optional or

Quoted 1 line

not? I see little reason to make it optional. Yes, it is yet another

group, but

Quoted 1 line

that just costs a few bytes in /etc/groups (which in practice doesn't

cost

Quoted 1 line

anything as long as the file stays under 4K).

I'd say let's make it non-optional.

Me too. The two go hand in hand. I don't know why I made the separation to begin with.

I'll return with at revised patch when I return from vacation and to a computer.

Signature · 1 line
Stephan
Quoted 2 lines

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20191025/97b4ce25/attachment.html>