Skip to contentSkip to conversation

makedevs: only warn when xattr support disabled

RFC PATCH New Petr Vorel 1 participant 2 messages Jul 31, 2019

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

RFC PATCH v5 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 v4->v5:
* Fix whitespace (reported by Yann)

 package/makedevs/makedevs.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
package/makedevs/makedevs.c +9 -3
index c57b964f5c..7a20ad30bf 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 v5 2/2 iputils: add capability for clockdiff, ping, traceroute6

and fallback to setuid if xattr not enabled.

Not setting xattr on 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

---
Changes v4->v5:
* fallback to setuid if xattr (suggested by Yann by Yann) BTW I wasn't able to use ifeq.. ,y.

Kind regards,
Petr

 package/iputils/iputils.mk | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
package/iputils/iputils.mk +9 -4
index 8e6a3e2fc5..e5a2690aac 100644
@@ -73,11 +73,16 @@ IPUTILS_POST_INSTALL_TARGET_HOOKS += IPUTILS_CREATE_PING6_SYMLINK
 
 # handle permissions ourselves
 IPUTILS_CONF_OPTS += -DNO_SETCAP_OR_SUID=true
+MAYBE_SUID = $(if $(BR2_ROOTFS_DEVICE_TABLE_SUPPORTS_EXTENDED_ATTRIBUTES),0,4)
+
 define IPUTILS_PERMISSIONS
-	/usr/sbin/arping      f 4755 0 0 - - - - -
-	/usr/bin/clockdiff    f 4755 0 0 - - - - -
-	/bin/ping             f 4755 0 0 - - - - -
-	/usr/bin/traceroute6  f 4755 0 0 - - - - -
+	/usr/sbin/arping      f $(MAYBE_SUID)755 0 0 - - - - -
+	/usr/bin/clockdiff    f $(MAYBE_SUID)755 0 0 - - - - -
+	|xattr cap_net_raw+p
+	/bin/ping             f $(MAYBE_SUID)755 0 0 - - - - -
+	|xattr cap_net_raw+p
+	/usr/bin/traceroute6  f $(MAYBE_SUID)755 0 0 - - - - -
+	|xattr cap_net_raw+p
 endef
 
 $(eval $(meson-package))
Signature · 1 line
2.22.0