Index | Thread | Search

From:
Denis Fondras <openbsd@ledeuns.net>
Subject:
Print error when ifconfig sff is NOPERM
To:
tech@openbsd.org
Date:
Sat, 13 Jan 2024 18:42:36 +0100

Download raw body.

Thread
  • Denis Fondras:

    Print error when ifconfig sff is NOPERM

When you do not have the right to query transceiver infos, `ifconfig sff` does
not print any error even though the command returns EPERM.

This diff enables the display of an error message to inform the user he lacks
the privilege to query transceiver infos (`ifconfig sffdump` already prints an
error message).

$ ifconfig ixl1 sff 
ixl1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        lladdr 3c:ec:ef:af:4a:25
        description: sw-63-1_1
        index 6 priority 0 llprio 3
        media: Ethernet autoselect (10GbaseLR full-duplex)
        status: active
ifconfig: ixl1 transceiver: Operation not permitted
        inet 10.255.163.2 netmask 0xfffffffe

Index: ifconfig.c
===================================================================
RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.464
diff -u -p -r1.464 ifconfig.c
--- ifconfig.c	16 May 2023 14:32:54 -0000	1.464
+++ ifconfig.c	13 Jan 2024 17:10:07 -0000
@@ -3446,7 +3446,7 @@ status(int link, struct sockaddr_dl *sdl
 
 	if (showtransceiver) {
 		if (if_sff_info(0) == -1)
-			if (!aflag && errno != EPERM && errno != ENOTTY)
+			if (!aflag && errno != ENOTTY)
 				warn("%s transceiver", ifname);
 	}
 #endif