From owner-svn-src-stable@freebsd.org Thu May 18 01:42:56 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EEAC4D712ED; Thu, 18 May 2017 01:42:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE50819BD; Thu, 18 May 2017 01:42:56 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4I1gtXh047457; Thu, 18 May 2017 01:42:55 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4I1gtRN047456; Thu, 18 May 2017 01:42:55 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201705180142.v4I1gtRN047456@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Thu, 18 May 2017 01:42:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r318435 - stable/10/contrib/hyperv/tools X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 May 2017 01:42:57 -0000 Author: sephe Date: Thu May 18 01:42:55 2017 New Revision: 318435 URL: https://svnweb.freebsd.org/changeset/base/318435 Log: MFC 317783 hyperv/kvp: Fix pool direcrory and file permission PR: 209385 Sponsored by: Microsoft Modified: stable/10/contrib/hyperv/tools/hv_kvp_daemon.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/hyperv/tools/hv_kvp_daemon.c ============================================================================== --- stable/10/contrib/hyperv/tools/hv_kvp_daemon.c Thu May 18 01:35:07 2017 (r318434) +++ stable/10/contrib/hyperv/tools/hv_kvp_daemon.c Thu May 18 01:42:55 2017 (r318435) @@ -61,6 +61,10 @@ typedef uint16_t __u16; typedef uint32_t __u32; typedef uint64_t __u64; +#define POOL_FILE_MODE (S_IRUSR | S_IWUSR) +#define POOL_DIR_MODE (POOL_FILE_MODE | S_IXUSR) +#define POOL_DIR "/var/db/hyperv/pool" + /* * ENUM Data */ @@ -285,11 +289,12 @@ kvp_file_init(void) int i; int alloc_unit = sizeof(struct kvp_record) * ENTRIES_PER_BLOCK; - if (mkdir("/var/db/hyperv/pool", S_IRUSR | S_IWUSR | S_IROTH) < 0 && + if (mkdir(POOL_DIR, POOL_DIR_MODE) < 0 && (errno != EEXIST && errno != EISDIR)) { KVP_LOG(LOG_ERR, " Failed to create /var/db/hyperv/pool\n"); exit(EXIT_FAILURE); } + chmod(POOL_DIR, POOL_DIR_MODE); /* fix old mistake */ for (i = 0; i < HV_KVP_POOL_COUNT; i++) { @@ -297,11 +302,12 @@ kvp_file_init(void) records_read = 0; num_blocks = 1; snprintf(fname, MAX_FILE_NAME, "/var/db/hyperv/pool/.kvp_pool_%d", i); - fd = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR | S_IROTH); + fd = open(fname, O_RDWR | O_CREAT, POOL_FILE_MODE); if (fd == -1) { return (1); } + fchmod(fd, POOL_FILE_MODE); /* fix old mistake */ filep = fopen(fname, "r");