Skip to contentSkip to conversation

makedevs: only warn when xattr support disabled

RFC PATCH Superseded Petr Vorel 3 participants 8 messages Jul 30, 2019 – Aug 1, 2019

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

RFC PATCH v4 1/2 makedevs: only warn when xattr support disabled

Previously makedevs failed when xattr configuration defined while disabled BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES. Thus check for this configuration would be required in each use in packages. Changing makedevs to only print warning with number of ignored lines, so package configuration don't have to deal with BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES.

No package is using this feature so far (it's used only in tests), thus no need to change any package config.

---
Changes v3->v4 (Addressed Yann's issues):
* s/discharged/ignored/
* exit with EXIT_SUCCESS (no need to abort fakeroot script just due ignored xattr lines)

 package/makedevs/makedevs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/makedevs/makedevs.c +9 -3
index c57b964f5c..dbe5b13714 100644
@@ -493,6 +493,7 @@ int main(int argc, char **argv)
 		printf("table=<stdin>\n");
 	}
 
+	unsigned int xattr_warned = 0;
 	while ((line = bb_get_chomped_line_from_file(table))) {
 		char type;
 		unsigned int mode = 0755;
@@ -518,9 +519,7 @@ int main(int argc, char **argv)
 			if (bb_set_xattr(full_name, xattr) < 0)
 				bb_error_msg_and_die("can't set cap %s on file %s\n", xattr, full_name);
 #else
-			bb_error_msg_and_die("line %d not supported: '%s'\nDid you forget to enable "
-					     "BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES?\n",
-					     linenum, line);
+			xattr_warned++;
 #endif /* EXTENDED_ATTRIBUTES */
 			continue;
 		}
@@ -641,6 +640,13 @@ int main(int argc, char **argv)
 loop:
 		free(line);
 	}
+
+	if (xattr_warned)
+			bb_error_msg("%u lines with xattr configuration ignored, enable "
+					     "BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES "
+						 "to get xattr support\n",
+					     xattr_warned);
+
 	fclose(table);
 
 	return ret;
Signature · 1 line
2.22.0
author
#1 lore raw

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

Not setting for arping as it can be used for ARP Poisoning.

Use cap_net_raw+p (drop +e) as upstream sets that via cap_set_flag(), see https://github.com/iputils/iputils/issues/194

---
 package/iputils/iputils.mk | 3 +++
 1 file changed, 3 insertions(+)
package/iputils/iputils.mk +3 -0
index 8e6a3e2fc5..f1d3e1fc6a 100644
@@ -76,8 +76,11 @@ IPUTILS_CONF_OPTS += -DNO_SETCAP_OR_SUID=true
 define IPUTILS_PERMISSIONS
 	/usr/sbin/arping      f 4755 0 0 - - - - -
 	/usr/bin/clockdiff    f 4755 0 0 - - - - -
+	|xattr cap_net_raw+p
 	/bin/ping             f 4755 0 0 - - - - -
+	|xattr cap_net_raw+p
 	/usr/bin/traceroute6  f 4755 0 0 - - - - -
+	|xattr cap_net_raw+p
 endef
 
 $(eval $(meson-package))
Signature · 1 line
2.22.0
#2 lore raw

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

Petr, All,

On 2019-07-30 23:38 +0200, Petr Vorel spake thusly:

Quoted 4 lines

Not setting for arping as it can be used for ARP Poisoning.

Use cap_net_raw+p (drop +e) as upstream sets that via cap_set_flag(), see https://github.com/iputils/iputils/issues/194

So, now we set the capabilities to those exectuables, do they still need to be setuid?

But then, if one really does not want xattr, setuid is still required.

So, we have no way to express that a file should have either setuid or xattrs, except as a big if-block like:

    ifeq ($(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),y)
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 0755 0 0 - - - - -
        |xattr cap_net_raw+p
    endef
    else
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 4755 0 0 - - - - -
    endef
    endif

... which is what we were trying to avoid in the firstplace...

We could write something like:

    /usr/bin/clockdiff    f $(MAYBE_SUID)755 0 0 - - - - -
    |xattr cap_net_raw+p

Where MAYBE_SUID would be set as:

    MAYBE_SUID = $(if $(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),0,4)

But it is starting to be a bit more complex than what you initially envisionned, I guess.

Regards,
Yann E. MORIN.

Quoted 24 lines
---
 package/iputils/iputils.mk | 3 +++
 1 file changed, 3 insertions(+)
package/iputils/iputils.mk +3 -0
index 8e6a3e2fc5..f1d3e1fc6a 100644
@@ -76,8 +76,11 @@ IPUTILS_CONF_OPTS += -DNO_SETCAP_OR_SUID=true
 define IPUTILS_PERMISSIONS
 	/usr/sbin/arping      f 4755 0 0 - - - - -
 	/usr/bin/clockdiff    f 4755 0 0 - - - - -
+	|xattr cap_net_raw+p
 	/bin/ping             f 4755 0 0 - - - - -
+	|xattr cap_net_raw+p
 	/usr/bin/traceroute6  f 4755 0 0 - - - - -
+	|xattr cap_net_raw+p
 endef
 
 $(eval $(meson-package))
Signature · 1 line
2.22.0
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
author
#3 lore raw

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

Hi Yann,

Quoted 21 lines

So, now we set the capabilities to those exectuables, do they still need to be setuid?

But then, if one really does not want xattr, setuid is still required.

So, we have no way to express that a file should have either setuid or xattrs, except as a big if-block like:

    ifeq ($(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),y)
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 0755 0 0 - - - - -
        |xattr cap_net_raw+p
    endef
    else
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 4755 0 0 - - - - -
    endef
    endif

... which is what we were trying to avoid in the firstplace...

Quoted 8 lines

We could write something like:

    /usr/bin/clockdiff    f $(MAYBE_SUID)755 0 0 - - - - -
    |xattr cap_net_raw+p

Where MAYBE_SUID would be set as:

    MAYBE_SUID = $(if $(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),0,4)

Good point, I fixed it in v5 (with whitespace).

Quoted 2 lines

But it is starting to be a bit more complex than what you initially envisionned, I guess.

Yep :(. But your solution is good enough, thank you!

Kind regards,
Petr

#4 lore raw

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

In reply to Yann E. MORIN

Hello,

Quoted 7 lines · On Wed, 31 Jul 2019 18:00:59 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 2 lines

Use cap_net_raw+p (drop +e) as upstream sets that via cap_set_flag(), see https://github.com/iputils/iputils/issues/194

So, now we set the capabilities to those exectuables, do they still need to be setuid?

But then, if one really does not want xattr, setuid is still required.

Ah, yes, indeed.

Quoted 14 lines

So, we have no way to express that a file should have either setuid or xattrs, except as a big if-block like:

    ifeq ($(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),y)
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 0755 0 0 - - - - -
        |xattr cap_net_raw+p
    endef
    else
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 4755 0 0 - - - - -
    endef
    endif
Quoted 1 line

... which is what we were trying to avoid in the firstplace...

Yes, but I believe it's the best solution for now, let's keep a conditional like you're showing here. Which of course makes the change to makedevs no longer relevant.

I really hope Petr is not going to hate us for all the discussion, back and forth and change of mind/opinion about this topic :-/

Quoted 11 lines

We could write something like:

    /usr/bin/clockdiff    f $(MAYBE_SUID)755 0 0 - - - - -
    |xattr cap_net_raw+p

Where MAYBE_SUID would be set as:

    MAYBE_SUID = $(if $(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),0,4)

But it is starting to be a bit more complex than what you initially envisionned, I guess.

Meh, no, please not like this.

Best regards,

Thomas

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

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

Hi Thomas, Yann,

I've sent v5 before your mail, sorry for forgetting to Cc you.

Quoted 29 lines

Hello,

Quoted 7 lines · On Wed, 31 Jul 2019 18:00:59 +0200 "Yann E. MORIN" <[email protected]>…
Quoted 2 lines

Use cap_net_raw+p (drop +e) as upstream sets that via cap_set_flag(), see https://github.com/iputils/iputils/issues/194

So, now we set the capabilities to those exectuables, do they still need to be setuid?

But then, if one really does not want xattr, setuid is still required.

Ah, yes, indeed.

Quoted 13 lines

So, we have no way to express that a file should have either setuid or xattrs, except as a big if-block like:

    ifeq ($(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),y)
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 0755 0 0 - - - - -
        |xattr cap_net_raw+p
    endef
    else
    define IPUTILS_PERMISSIONS
        /usr/bin/clockdiff    f 4755 0 0 - - - - -
    endef
    endif
Quoted 5 lines
Quoted 1 line

... which is what we were trying to avoid in the firstplace...

Yes, but I believe it's the best solution for now, let's keep a conditional like you're showing here. Which of course makes the change to makedevs no longer relevant.

Sure :). So merge the original version [1], related only to iputils?

Quoted 2 lines

I really hope Petr is not going to hate us for all the discussion, back and forth and change of mind/opinion about this topic :-/

No, not at all :).

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/patch/1138055/

#6 lore raw

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

Petr, All,

On 2019-08-01 00:24 +0200, Petr Vorel spake thusly:

Quoted 2 lines
Quoted 2 lines

On Wed, 31 Jul 2019 18:00:59 +0200
"Yann E. MORIN" <[email protected]> wrote:

[--SNIP--]

Quoted 4 lines
Quoted 3 lines

Yes, but I believe it's the best solution for now, let's keep a conditional like you're showing here. Which of course makes the change to makedevs no longer relevant.

Sure :). So merge the original version [1], related only to iputils?

Not really, because your first iteration still kept the suid bit on the orograms.

I'm intrigued why you could not use the ifeq(...) construct, though...

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
author
#7 lore raw

RFC PATCH v4 2/2 iputils: add capability for clockdiff, ping, traceroute6

Hi Yann, Thomas,

Quoted 9 lines

Petr, All,

On 2019-08-01 00:24 +0200, Petr Vorel spake thusly:

Quoted 2 lines
Quoted 2 lines

On Wed, 31 Jul 2019 18:00:59 +0200
"Yann E. MORIN" <[email protected]> wrote:

[--SNIP--]

Quoted 3 lines
Quoted 3 lines

Yes, but I believe it's the best solution for now, let's keep a conditional like you're showing here. Which of course makes the change to makedevs no longer relevant.

Quoted 6 lines
Quoted 1 line

Sure :). So merge the original version [1], related only to iputils?

Not really, because your first iteration still kept the suid bit on the orograms.

I'm intrigued why you could not use the ifeq(...) construct, though...

Oh, sorry. I'll post v6.

Quoted 2 lines

Regards,
Yann E. MORIN.

Kind regards,
Petr