handle: return -EOPNOTSUPP instead of -EPERM if an operation is not supported
authorDjalal Harouni <tixxdz@opendz.org>
Tue, 5 Aug 2014 01:09:09 +0000 (02:09 +0100)
committerKay Sievers <kay@vrfy.org>
Tue, 5 Aug 2014 07:23:37 +0000 (09:23 +0200)
If userspace calls in with the wrong connection type, just return
-EOPNOTSUPP instead of -EPERM.

This will not confuse unprivileged and privileged processes, and permits
to identify legitimate -EPERM errors.

This just converts errors introduced in commit 7015a1e6746

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
handle.c

index 4b8376cf499f5d10c9ddf8edb60b963db87001af..2e6502b5356e47fdc406586f59d4367372fe5dfb 100644 (file)
--- a/handle.c
+++ b/handle.c
@@ -537,7 +537,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
        switch (cmd) {
        case KDBUS_CMD_BYEBYE:
                if (conn->type != KDBUS_CONN_CONNECTED) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -548,7 +548,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
                /* acquire a well-known name */
 
                if (conn->type != KDBUS_CONN_CONNECTED) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -573,7 +573,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
                /* release a well-known name */
 
                if (conn->type != KDBUS_CONN_CONNECTED) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -638,7 +638,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
                /* update the properties of a connection */
 
                if (conn->type != KDBUS_CONN_CONNECTED) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -657,7 +657,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
 
                if (conn->type != KDBUS_CONN_CONNECTED &&
                    conn->type != KDBUS_CONN_MONITOR) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -676,7 +676,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
 
                if (conn->type != KDBUS_CONN_CONNECTED &&
                    conn->type != KDBUS_CONN_MONITOR) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -694,7 +694,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
                struct kdbus_kmsg *kmsg = NULL;
 
                if (conn->type != KDBUS_CONN_CONNECTED) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -727,7 +727,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
 
                if (conn->type != KDBUS_CONN_CONNECTED &&
                    conn->type != KDBUS_CONN_MONITOR) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -754,7 +754,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
                u64 cookie;
 
                if (conn->type != KDBUS_CONN_CONNECTED) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }
 
@@ -775,7 +775,7 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd,
 
                if (conn->type != KDBUS_CONN_CONNECTED &&
                    conn->type != KDBUS_CONN_MONITOR) {
-                       ret = -EPERM;
+                       ret = -EOPNOTSUPP;
                        break;
                }