Skip to contentSkip to conversation

sudo: Add ldap support for sudoers rules

PATCH New Chris Frederick 4 participants 10 messages Oct 24, 2016 – Mar 2, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Added Config.in options to enable/disable the option, and check options in sudo.mk to add openldap as a dependancy and compile with --with-ldap.

When sudo is built with ldap, /etc/sudoers is only read in for defaults, all rules need to be provided via ldap which is configured by the user in /etc/ldap.conf.

Since the user explicitly has to provide /etc/ldap.conf, we use 'depends on' so that the user is obliged to explicitly enable openldap before the option becomes visible.

---
 package/sudo/Config.in | 13 +++++++++++++
 package/sudo/sudo.mk   |  7 +++++++
 2 files changed, 20 insertions(+)
package/sudo/Config.in +13 -0
index cbef15d..72bb5d7 100644
@@ -9,3 +9,16 @@ 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_LDAP
+	bool "ldap integration"
+	depends on BR2_PACKAGE_OPENLDAP
+	help
+	  Allows you to manage sudoers rules in a centralized ldap
+	  directory. This restricts the /etc/sudoers file from
+	  defining rules, only defaults will be read. All rules will
+	  need to be provided via ldap configured in /etc/ldap.conf
+
+	  http://www.sudo.ws/man/1.8.15/sudoers.ldap.man.html
+endif
package/sudo/sudo.mk +7 -0
index f28312a..45273bb 100644
@@ -30,6 +30,13 @@ else
 SUDO_CONF_OPTS += --without-pam
 endif
 
+ifeq ($(BR2_PACKAGE_SUDO_LDAP),y)
+SUDO_DEPENDENCIES += openldap
+SUDO_CONF_OPTS += --with-ldap
+else
+SUDO_CONF_OPTS += --without-ldap
+endif
+
 # mksigname/mksiglist needs to run on build host to generate source files
 define SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST
 	$(MAKE) $(HOST_CONFIGURE_OPTS) \
Signature · 1 line
2.7.3
#1 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Hi Chris,

Le 24/10/2016 ? 17:34, Chris Frederick a ?crit :

Quoted 27 lines

Added Config.in options to enable/disable the option, and check options in sudo.mk to add openldap as a dependancy and compile with --with-ldap.

When sudo is built with ldap, /etc/sudoers is only read in for defaults, all rules need to be provided via ldap which is configured by the user in /etc/ldap.conf.

Since the user explicitly has to provide /etc/ldap.conf, we use 'depends on' so that the user is obliged to explicitly enable openldap before the option becomes visible.

---
 package/sudo/Config.in | 13 +++++++++++++
 package/sudo/sudo.mk   |  7 +++++++
 2 files changed, 20 insertions(+)
package/sudo/Config.in +2 -0
index cbef15d..72bb5d7 100644
@@ -9,3 +9,16 @@ config BR2_PACKAGE_SUDO
 	  but still allow people to get their work done.
 
 	  http://www.sudo.ws/sudo/
+
+if BR2_PACKAGE_SUDO

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

Quoted 10 lines
package/sudo/Config.in +10 -0
+config BR2_PACKAGE_SUDO_LDAP
+	bool "ldap integration"
+	depends on BR2_PACKAGE_OPENLDAP
+	help
+	  Allows you to manage sudoers rules in a centralized ldap
+	  directory. This restricts the /etc/sudoers file from
+	  defining rules, only defaults will be read. All rules will
+	  need to be provided via ldap configured in /etc/ldap.conf
+
+	  http://www.sudo.ws/man/1.8.15/sudoers.ldap.man.html

Maybe add a comment here

comment "ldap integration needs openldap"
depends on !BR2_PACKAGE_OPENLDAP

Otherwise:

Best regards,
Romain

Quoted 20 lines
package/sudo/Config.in +1 -0
+endif
package/sudo/sudo.mk +7 -0
index f28312a..45273bb 100644
@@ -30,6 +30,13 @@ else
 SUDO_CONF_OPTS += --without-pam
 endif
 
+ifeq ($(BR2_PACKAGE_SUDO_LDAP),y)
+SUDO_DEPENDENCIES += openldap
+SUDO_CONF_OPTS += --with-ldap
+else
+SUDO_CONF_OPTS += --without-ldap
+endif
+
 # mksigname/mksiglist needs to run on build host to generate source files
 define SUDO_BUILD_MKSIGNAME_MKSIGLIST_HOST
 	$(MAKE) $(HOST_CONFIGURE_OPTS) \
#2 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Hello,

Quoted 4 lines · Romain Naour

Maybe add a comment here

comment "ldap integration needs openldap"
depends on !BR2_PACKAGE_OPENLDAP

Well, I'm not against Config.in comments, but in that case, isn't it sufficiently obvious to the user? Surely if you think about using LDAP support in sudo, you know that you need to have some kind of LDAP implementation.

Which makes me think that perhaps a new sub-option is maybe not needed. Why not just enable LDAP support in sudo when BR2_PACKAGE_OPENLDAP=y ?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#3 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Hi Thomas, Chris, All,

Le 29/01/2017 ? 14:18, Thomas Petazzoni a ?crit :

Quoted 9 lines

Hello,

Quoted 4 lines · Romain Naour

Maybe add a comment here

comment "ldap integration needs openldap"
depends on !BR2_PACKAGE_OPENLDAP

Quoted 7 lines

Well, I'm not against Config.in comments, but in that case, isn't it sufficiently obvious to the user? Surely if you think about using LDAP support in sudo, you know that you need to have some kind of LDAP implementation.

Which makes me think that perhaps a new sub-option is maybe not needed. Why not just enable LDAP support in sudo when BR2_PACKAGE_OPENLDAP=y ?

Yes, It seems a better idea :)

Best regards,
Romain

Quoted 3 lines

Thomas

#4 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

In reply to Chris Frederick

Hello,

Quoted 11 lines · Chris Frederick

Added Config.in options to enable/disable the option, and check options in sudo.mk to add openldap as a dependancy and compile with --with-ldap.

When sudo is built with ldap, /etc/sudoers is only read in for defaults, all rules need to be provided via ldap which is configured by the user in /etc/ldap.conf.

Since the user explicitly has to provide /etc/ldap.conf, we use 'depends on' so that the user is obliged to explicitly enable openldap before the option becomes visible.

Quoted 5 lines
---
 package/sudo/Config.in | 13 +++++++++++++
 package/sudo/sudo.mk   |  7 +++++++
 2 files changed, 20 insertions(+)

I've applied, after removing the explicit Config.in option and instead relying on whether BR2_PACKAGE_OPENLDAP is enabled or not to decide if ldap support should be enabled or not in sudo.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Quoted 21 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hello,

Quoted 11 lines · Chris Frederick

Added Config.in options to enable/disable the option, and check options in sudo.mk to add openldap as a dependancy and compile with --with-ldap.

When sudo is built with ldap, /etc/sudoers is only read in for defaults, all rules need to be provided via ldap which is configured by the user in /etc/ldap.conf.

Since the user explicitly has to provide /etc/ldap.conf, we use 'depends on' so that the user is obliged to explicitly enable openldap before the option becomes visible.

Quoted 5 lines

---
package/sudo/Config.in | 13 +++++++++++++
package/sudo/sudo.mk | 7 +++++++

2 files changed, 20 insertions(+)
Quoted 3 lines

I've applied, after removing the explicit Config.in option and instead relying on whether BR2_PACKAGE_OPENLDAP is enabled or not to decide if ldap support should be enabled or not in sudo.

Notice that this was discussed during the first review:

http://lists.busybox.net/pipermail/buildroot/2016-October/175480.html

Apparently sudo with pam support really needs a configured /etc/ldap.conf, which might be confusing to people that (perhaps unrelated to eachother) enabled both sudo and ldap.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Hello,

Quoted 11 lines · Peter Korsgaard
Quoted 3 lines

I've applied, after removing the explicit Config.in option and instead relying on whether BR2_PACKAGE_OPENLDAP is enabled or not to decide if ldap support should be enabled or not in sudo.

Notice that this was discussed during the first review:

http://lists.busybox.net/pipermail/buildroot/2016-October/175480.html

Apparently sudo with pam support really needs a configured /etc/ldap.conf, which might be confusing to people that (perhaps unrelated to eachother) enabled both sudo and ldap.

So in other words we really want to have a sub-option for this situation?

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#7 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Quoted 11 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hello,

Quoted 6 lines · Peter Korsgaard
Quoted 3 lines

I've applied, after removing the explicit Config.in option and instead relying on whether BR2_PACKAGE_OPENLDAP is enabled or not to decide if ldap support should be enabled or not in sudo.

Notice that this was discussed during the first review:

Quoted 8 lines
Quoted 5 lines

http://lists.busybox.net/pipermail/buildroot/2016-October/175480.html

Apparently sudo with pam support really needs a configured /etc/ldap.conf, which might be confusing to people that (perhaps unrelated to eachother) enabled both sudo and ldap.

So in other words we really want to have a sub-option for this situation?

I don't personally know anything about it, but that was the conclusion of Arnout and Chris, yes.

Signature · 1 line
Bye, Peter Korsgaard
#8 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

Quoted 17 lines · Peter Korsgaard
Quoted 16 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Hello,

Quoted 11 lines · Peter Korsgaard
Quoted 3 lines

I've applied, after removing the explicit Config.in option and instead relying on whether BR2_PACKAGE_OPENLDAP is enabled or not to decide if ldap support should be enabled or not in sudo.

Notice that this was discussed during the first review:

http://lists.busybox.net/pipermail/buildroot/2016-October/175480.html

Apparently sudo with pam support really needs a configured /etc/ldap.conf, which might be confusing to people that (perhaps unrelated to eachother) enabled both sudo and ldap.

Quoted 6 lines
Quoted 2 lines

So in other words we really want to have a sub-option for this situation?

I don't personally know anything about it, but that was the conclusion of Arnout and Chris, yes.

It looks like you can configure sudoers access via /etc/nsswitch.conf:

See "Configuring nsswitch.conf" in the sudoers ldap manual:
https://www.sudo.ws/man/1.8.17/sudoers.ldap.man.html

So it could be left to the end user building the image to add their own nsswitch.conf entry to control it. It also mentions that sudo defaults to using /etc/sudoers exclusively, so it should be compatible with users not using ldap sudoers with no changes required of them.

Chris Frederick

#9 lore raw

PATCH 1/1 sudo: Add ldap support for sudoers rules

In reply to Chris Frederick

Hello,

Quoted 7 lines · Chris Frederick

Added Config.in options to enable/disable the option, and check options in sudo.mk to add openldap as a dependancy and compile with --with-ldap.

When sudo is built with ldap, /etc/sudoers is only read in for defaults, all rules need to be provided via ldap which is configured by the user in /etc/ldap.conf.

Quoted 5 lines

Since the user explicitly has to provide /etc/ldap.conf, we use 'depends on' so that the user is obliged to explicitly enable openldap before the option becomes visible.

The sudo/ldap support causes some build failures in static linking configurations. See:
http://autobuild.buildroot.net/results/483/4830c69cc6a62080e1516f0d9009c2ba619c23c1/build-end.log
for an example.

From a quick look, it seems like sudo doesn't use pkg-config to discover the ldap library, and therefore doesn't know that ldap needs to be linked with openssl. But that's really a 5 seconds look at the build error.

Could you have a closer look?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com