From patchwork Fri Dec 13 12:14:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 3340051 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E1492C0D4A for ; Fri, 13 Dec 2013 12:19:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3FEE020570 for ; Fri, 13 Dec 2013 12:19:14 +0000 (UTC) Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mail.kernel.org (Postfix) with ESMTP id 026EA20426 for ; Fri, 13 Dec 2013 12:19:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBDCFQaE009267; Fri, 13 Dec 2013 07:15:26 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBDCEjDm027019 for ; Fri, 13 Dec 2013 07:14:45 -0500 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id rBDCEjHn000427 for ; Fri, 13 Dec 2013 07:14:45 -0500 Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBDCEiXA026931 for ; Fri, 13 Dec 2013 07:14:44 -0500 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4BB58ABCA for ; Fri, 13 Dec 2013 12:14:44 +0000 (UTC) From: Hannes Reinecke To: dm-devel@redhat.com Date: Fri, 13 Dec 2013 13:14:14 +0100 Message-Id: <1386936854-8399-12-git-send-email-hare@suse.de> In-Reply-To: <1386936854-8399-1-git-send-email-hare@suse.de> References: <1386936854-8399-1-git-send-email-hare@suse.de> X-RedHat-Spam-Score: -6.9 (BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, URIBL_BLOCKED) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Subject: [dm-devel] [PATCH 11/11] Make 'multipath -t' able to run as normal user X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development 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-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 'multipath -t' should be run as normal user, as we might be needing it to update the default configuration. Signed-off-by: Hannes Reinecke --- libmultipath/config.c | 1 - multipath/main.c | 22 +++++++++++++--------- multipathd/main.c | 2 ++ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/libmultipath/config.c b/libmultipath/config.c index 9b7adda..e13c307 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -543,7 +543,6 @@ load_config (char * file, struct udev *udev) conf->verbosity = DEFAULT_VERBOSITY; conf->udev = udev; - dm_drv_version(conf->version, TGT_MPATH); conf->dev_type = DEV_NONE; conf->minio = DEFAULT_MINIO; conf->minio_rq = DEFAULT_MINIO_RQ; diff --git a/multipath/main.c b/multipath/main.c index 842a787..c351507 100644 --- a/multipath/main.c +++ b/multipath/main.c @@ -447,16 +447,8 @@ main (int argc, char *argv[]) extern int optind; int r = 1; - if (getuid() != 0) { - fprintf(stderr, "need to be root\n"); - exit(1); - } - udev = udev_new(); - if (dm_prereq()) - exit(1); - if (load_config(DEFAULT_CONFIGFILE, udev)) exit(1); @@ -521,7 +513,7 @@ main (int argc, char *argv[]) break; case 't': r = dump_config(); - goto out; + goto out_free_config; case 'h': usage(argv[0]); exit(0); @@ -544,6 +536,16 @@ main (int argc, char *argv[]) exit(1); } } + + if (getuid() != 0) { + fprintf(stderr, "need to be root\n"); + exit(1); + } + + if (dm_prereq()) + exit(1); + dm_drv_version(conf->version, TGT_MPATH); + if (optind < argc) { conf->dev = MALLOC(FILE_NAME_SIZE); @@ -630,6 +632,8 @@ out: cleanup_prio(); cleanup_checkers(); + +out_free_config: /* * Freeing config must be done after dm_lib_exit(), because * the logging function (dm_write_log()), which is called there, diff --git a/multipathd/main.c b/multipathd/main.c index cc5cf67..7f59c6d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -1430,6 +1430,7 @@ reconfigure (struct vectors * vecs) tzset(); if (!load_config(DEFAULT_CONFIGFILE, udev)) { + dm_drv_version(conf->version, TGT_MPATH); conf->verbosity = old->verbosity; conf->daemon = 1; configure(vecs, 1); @@ -1634,6 +1635,7 @@ child (void * param) if (load_config(DEFAULT_CONFIGFILE, udev)) exit(1); + dm_drv_version(conf->version, TGT_MPATH); if (init_checkers()) { condlog(0, "failed to initialize checkers"); exit(1);