From patchwork Tue Nov 21 14:09:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gris Ge X-Patchwork-Id: 10068235 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 384AF602B7 for ; Tue, 21 Nov 2017 14:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26D9429670 for ; Tue, 21 Nov 2017 14:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BAB229673; Tue, 21 Nov 2017 14:10:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9A172962F for ; Tue, 21 Nov 2017 14:10:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8038D19D222; Tue, 21 Nov 2017 14:10:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65E1560015; Tue, 21 Nov 2017 14:10:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3F7114A46A; Tue, 21 Nov 2017 14:10:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id vALE9YRh002106 for ; Tue, 21 Nov 2017 09:09:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 831CC17A66; Tue, 21 Nov 2017 14:09:34 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from localhost.localdomain (ovpn-12-124.pek2.redhat.com [10.72.12.124]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5FA3660634; Tue, 21 Nov 2017 14:09:32 +0000 (UTC) From: Gris Ge To: dm-devel@redhat.com Date: Tue, 21 Nov 2017 22:09:17 +0800 Message-Id: <20171121140917.18298-5-fge@redhat.com> In-Reply-To: <20171121140917.18298-1-fge@redhat.com> References: <20171121140917.18298-1-fge@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: dm-devel@redhat.com Cc: Gris Ge Subject: [dm-devel] [PATCH 4/4] multipath-tools: libdmmp: Add new error DMMP_ERR_PERMISSION_DENY X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 21 Nov 2017 14:10:32 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP * Indicate user does not have privilege to flush mpath or invoke reconfig. * Bump API version to 0.2.0 for this API addition. Signed-off-by: Gris Ge --- libdmmp/Makefile | 2 +- libdmmp/libdmmp.c | 8 ++++++++ libdmmp/libdmmp/libdmmp.h | 5 +++++ libdmmp/libdmmp_misc.c | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libdmmp/Makefile b/libdmmp/Makefile index 6645a1a4..bf231ace 100644 --- a/libdmmp/Makefile +++ b/libdmmp/Makefile @@ -5,7 +5,7 @@ # include ../Makefile.inc -LIBDMMP_VERSION=0.1.0 +LIBDMMP_VERSION=0.2.0 SONAME=$(LIBDMMP_VERSION) DEVLIB = libdmmp.so LIBS = $(DEVLIB).$(SONAME) diff --git a/libdmmp/libdmmp.c b/libdmmp/libdmmp.c index 95f65b88..944cecd6 100644 --- a/libdmmp/libdmmp.c +++ b/libdmmp/libdmmp.c @@ -364,6 +364,14 @@ invoke: } } + if ((*output != NULL) && + strncmp(*output, "permission deny", + strlen("permission deny")) == 0) { + _error(ctx, "Permission deny, need to be root"); + rc = DMMP_ERR_PERMISSION_DENY; + goto out; + } + out: if (rc != DMMP_OK) { free(*output); diff --git a/libdmmp/libdmmp/libdmmp.h b/libdmmp/libdmmp/libdmmp.h index 33b5d743..e157982e 100644 --- a/libdmmp/libdmmp/libdmmp.h +++ b/libdmmp/libdmmp/libdmmp.h @@ -42,6 +42,7 @@ extern "C" { #define DMMP_ERR_MPATH_BUSY 7 #define DMMP_ERR_MPATH_NOT_FOUND 8 #define DMMP_ERR_INVALID_ARGUMENT 9 +#define DMMP_ERR_PERMISSION_DENY 10 /* * Use the syslog severity level as log priority @@ -679,6 +680,8 @@ DMMP_DLL_EXPORT const char *dmmp_path_status_str(uint32_t path_status); * * * DMMP_ERR_INVALID_ARGUMENT * + * * DMMP_ERR_PERMISSION_DENY + * * Error number could be converted to string by dmmp_strerror(). */ DMMP_DLL_EXPORT int dmmp_flush_mpath(struct dmmp_context *ctx, @@ -704,6 +707,8 @@ DMMP_DLL_EXPORT int dmmp_flush_mpath(struct dmmp_context *ctx, * * * DMMP_ERR_NO_DAEMON * + * * DMMP_ERR_PERMISSION_DENY + * * Error number could be converted to string by dmmp_strerror(). */ DMMP_DLL_EXPORT int dmmp_reconfig(struct dmmp_context *ctx); diff --git a/libdmmp/libdmmp_misc.c b/libdmmp/libdmmp_misc.c index 435ddfa5..69b5a202 100644 --- a/libdmmp/libdmmp_misc.c +++ b/libdmmp/libdmmp_misc.c @@ -49,6 +49,7 @@ static const struct _num_str_conv _DMMP_RC_MSG_CONV[] = { {DMMP_ERR_MPATH_BUSY, "Specified multipath device map is in use"}, {DMMP_ERR_MPATH_NOT_FOUND, "Specified multipath not found"}, {DMMP_ERR_INVALID_ARGUMENT, "Invalid argument"}, + {DMMP_ERR_PERMISSION_DENY, "Permission deny"}, }; _dmmp_str_func_gen(dmmp_strerror, int, rc, _DMMP_RC_MSG_CONV);