Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1860194ybh; Fri, 17 Jul 2020 03:11:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx33E9bfgG14l4mpSq8fMW/beevTm7RIigTBtMTItcTzn9fXtfLhod8a2OfkFeuAESZFLJ/ X-Received: by 2002:a50:cf43:: with SMTP id d3mr8897475edk.40.1594980715318; Fri, 17 Jul 2020 03:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594980715; cv=none; d=google.com; s=arc-20160816; b=p8w/IMF4byVE1RpUOkunp7In9XIm4C31JA4ezgrXL0DOBO69MaLUs+aGfJdRobxjYG FOH1uIx8s5sAMbTGNvlEZJM65lwdG+2WtG9Vs3nDsBXwk4MfNODZu0PoHKbGE3V1YYfv d3fC0DG7Ux8pcw2aoPamL6g1+IPn2LQTuRkX//uHioqs4M48r03mpnrRBvD1JP9nodIN RDADUmFtMgBB3WW31GP9JyOXR+wk7lYKMzk8Lck4m+udai9YncexNhLVtxfCcd3tU92H Vlzt6VsXjpXHwx8aGPLAmWoXYB/iHwTDlHKf0gbizWVhYaZ9nN/oyKkQdpMreVDUhjKW PPqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=h9OOb8z0V29FCf+aVWRBJqPnMNTlBEeRRpYQ/jsPS+0=; b=HIbtMrKDoJgcY/D5ZZ1YWHdEcoQaQpTlE0Pvy4VwenCrsdatOTjXwyYpziWSDBeliW QYYYEqE1M8DPBecNpqDJpr2wlrjk8qXVROi3pTqnzBK0a/jwL8/NhR+XEXv6ibt12SyO RVm8ymAdAYftNSW52y0rZyfp+tjgxqLoDzXlQw1USAdbMitiPOzqxHOGwCcaJ4v9N6zy kgW1byWO0Zxunsm+xniT1AnCYW9OTTLJtdsdZ52SOSRdRjJ0IFW/zJ27K5DY2lxhsBrO NGBu1Lx+aXNhW0ybwQULd3sSSO3YtoDyZvN1j5rtR/jqzBoEfgZ10Ze/MODFNTNa6hMG qmaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si4904131eds.105.2020.07.17.03.11.25; Fri, 17 Jul 2020 03:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725932AbgGQKLX (ORCPT + 99 others); Fri, 17 Jul 2020 06:11:23 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:60821 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725864AbgGQKLW (ORCPT ); Fri, 17 Jul 2020 06:11:22 -0400 Received: from localhost (lfbn-tou-1-1075-236.w90-76.abo.wanadoo.fr [90.76.143.236]) (Authenticated sender: antoine.tenart@bootlin.com) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 2BA6B24001F; Fri, 17 Jul 2020 10:10:02 +0000 (UTC) From: Antoine Tenart To: linux-ext4@vger.kernel.org Cc: Antoine Tenart , matthew.weber@rockwellcollins.com, thomas.petazzoni@bootlin.com, adilger@dilger.ca Subject: [PATCH v2] create_inode: set xattrs to the root directory as well Date: Fri, 17 Jul 2020 12:08:46 +0200 Message-Id: <20200717100846.497546-1-antoine.tenart@bootlin.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org populate_fs do copy the xattrs for all files and directories, but the root directory is skipped and as a result its extended attributes aren't set. This is an issue when using mkfs to build a full system image that can be used with SElinux in enforcing mode without making any runtime fix at first boot. This patch adds logic to set the root directory's extended attributes. Signed-off-by: Antoine Tenart --- Since v1: - Moved the set_inode_xattr logic for the root directory from __populate_fs to populate_fs2. misc/create_inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/misc/create_inode.c b/misc/create_inode.c index e8d1df6b55a5..fe66faf1b53d 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -1050,9 +1050,17 @@ errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino, file_info.path_max_len = 255; file_info.path = calloc(file_info.path_max_len, 1); + retval = set_inode_xattr(fs, root, source_dir); + if (retval) { + com_err(__func__, retval, + _("while copying xattrs on root directory")); + goto out; + } + retval = __populate_fs(fs, parent_ino, source_dir, root, &hdlinks, &file_info, fs_callbacks); +out: free(file_info.path); free(hdlinks.hdl); return retval; -- 2.26.2