lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1382193559-12549-8-git-send-email-dominik.paulus@fau.de>
Date:	Sat, 19 Oct 2013 16:39:10 +0200
From:	Dominik Paulus <dominik.paulus@....de>
To:	Dan Carpenter <dan.carpenter@...cle.com>
Cc:	Dominik Paulus <dominik.paulus@....de>,
	Tobias Polzer <tobias.polzer@....de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Anthony Foiani <anthony.foiani@...il.com>,
	devel@...verdev.osuosl.org, linux-kernel@...cs.fau.de,
	Kurt Kanzenbach <ly80toro@....cs.fau.de>,
	linux-kernel@...r.kernel.org, tobias.polzer@....de,
	Ilija Hadzic <ihadzic@...earch.bell-labs.com>
Subject: [PATCHv4 07/16] staging: usbip: Handle usbip being started as user

usbip now prints an error message when started as user and requiring
root access. Also, some debug messages are changed to error messages so
the command line utilities now print less confusing (and more verbose)
error messages when not used correctly.

Signed-off-by: Dominik Paulus <dominik.paulus@....de>
Signed-off-by: Tobias Polzer <tobias.polzer@....de>
---
 drivers/staging/usbip/userspace/src/usbip_attach.c |  3 +++
 drivers/staging/usbip/userspace/src/usbip_bind.c   | 16 ++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_attach.c b/drivers/staging/usbip/userspace/src/usbip_attach.c
index 2a3f313..651e93a 100644
--- a/drivers/staging/usbip/userspace/src/usbip_attach.c
+++ b/drivers/staging/usbip/userspace/src/usbip_attach.c
@@ -210,6 +210,9 @@ int usbip_attach(int argc, char *argv[])
 	int opt;
 	int ret = -1;
 
+	if (geteuid() != 0)
+		err("not running as root?");
+
 	for (;;) {
 		opt = getopt_long(argc, argv, "r:b:", opts, NULL);
 
diff --git a/drivers/staging/usbip/userspace/src/usbip_bind.c b/drivers/staging/usbip/userspace/src/usbip_bind.c
index d2739fc..ab26b30f 100644
--- a/drivers/staging/usbip/userspace/src/usbip_bind.c
+++ b/drivers/staging/usbip/userspace/src/usbip_bind.c
@@ -158,7 +158,7 @@ static int unbind_other(char *busid)
 
 	busid_dev = sysfs_open_device(bus_type, busid);
 	if (!busid_dev) {
-		dbg("sysfs_open_device %s failed: %s", busid, strerror(errno));
+		err("sysfs_open_device %s failed: %s", busid, strerror(errno));
 		return -1;
 	}
 
@@ -166,7 +166,7 @@ static int unbind_other(char *busid)
 	bDevClass  = sysfs_get_device_attr(busid_dev, "bDeviceClass");
 	bNumIntfs  = sysfs_get_device_attr(busid_dev, "bNumInterfaces");
 	if (!bConfValue || !bDevClass || !bNumIntfs) {
-		dbg("problem getting device attributes: %s",
+		err("problem getting device attributes: %s",
 		    strerror(errno));
 		goto err_close_busid_dev;
 	}
@@ -181,7 +181,7 @@ static int unbind_other(char *busid)
 			 bConfValue->value, i);
 		intf_dev = sysfs_open_device(bus_type, intf_busid);
 		if (!intf_dev) {
-			dbg("could not open interface device: %s",
+			err("could not open interface device: %s",
 			    strerror(errno));
 			goto err_close_busid_dev;
 		}
@@ -202,14 +202,14 @@ static int unbind_other(char *busid)
 		/* unbinding */
 		intf_drv = sysfs_open_driver(bus_type, intf_dev->driver_name);
 		if (!intf_drv) {
-			dbg("could not open interface driver on %s: %s",
+			err("could not open interface driver on %s: %s",
 			    intf_dev->name, strerror(errno));
 			goto err_close_intf_dev;
 		}
 
 		unbind_attr = sysfs_get_driver_attr(intf_drv, "unbind");
 		if (!unbind_attr) {
-			dbg("problem getting interface driver attribute: %s",
+			err("problem getting interface driver attribute: %s",
 			    strerror(errno));
 			goto err_close_intf_drv;
 		}
@@ -218,7 +218,8 @@ static int unbind_other(char *busid)
 					   SYSFS_BUS_ID_SIZE);
 		if (rc < 0) {
 			/* NOTE: why keep unbinding other interfaces? */
-			dbg("unbind driver at %s failed", intf_dev->bus_id);
+			err("unbind driver at %s failed: %s", intf_dev->bus_id,
+					strerror(errno));
 			status = UNBIND_ST_FAILED;
 		}
 
@@ -287,6 +288,9 @@ int usbip_bind(int argc, char *argv[])
 
 	allow[0] = 0;
 
+	if (geteuid() != 0)
+		err("not running as root?");
+
 	for (;;) {
 		opt = getopt_long(argc, argv, "a:b:", opts, NULL);
 
-- 
1.8.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ