From patchwork Thu Dec 14 10:41:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "S. Lockwood-Childs" X-Patchwork-Id: 848463 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4001:c0b::23d; helo=mail-it0-x23d.google.com; envelope-from=swupdate+bncbdgpj5oqwyebbsnjzhiqkgqelwqgoja@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="GhRPOeL7"; dkim-atps=neutral Received: from mail-it0-x23d.google.com (mail-it0-x23d.google.com [IPv6:2607:f8b0:4001:c0b::23d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yy9646hX7z9sRg for ; Thu, 14 Dec 2017 21:39:08 +1100 (AEDT) Received: by mail-it0-x23d.google.com with SMTP id a3sf7653855itg.7 for ; Thu, 14 Dec 2017 02:39:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1513247946; cv=pass; d=google.com; s=arc-20160816; b=IhqhhUCPu7MoxKY/ImBvsmtX/7y+kNvxykF51RYsJlsm2+p9KDP/Y+Ndl/8WUBMWnJ o0/eSF0LcWcA8ryHKOpsEUgQN/KRTNjx/Yqerj46XLsKqvJlfCSpcFbido7AqsXZAYZo LfisNKtBM//9sOzUaSfVF966mkLJpqShTBso7KEgOzDZ6RSEsqpuG2/7p73lr9gILiV5 6ic7JvhNq0sYUkDCVWnqfVyZI18Z2WekcidHxPKgvSYJwFMOjblbXJIcAW+Lh7VpoO/M HAfvzl5vJvg6ojljqWV7qDi1q80I0fxMQ+knHyMuQT2smrxFDwWgSZ3QvfvUZFvC/Bap t78w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:user-agent:content-disposition :mime-version:message-id:subject:to:from:date :arc-authentication-results:arc-message-signature:sender :dkim-signature:arc-authentication-results; bh=bo9lSW4pvbpfsqkzW2xO9O/MJ/+bUFPnJo3Cj2xiCNM=; b=NYykmM21gUf9Rdmhz8h+u8868LKrBLqP1fHuJPS/Of1u6Ai5K9N9Ag7g99kqsDWrSk Q0WaY+WvpuqsbdbZ/uyrLoSf2PX6XElTtabIjpuO7yX3aQJKyUJx7CSE2F8jPtxkxZd1 QMdF1Q3W/iQ4a81Da/dyrlxeoZDUQUUA1r9EnE0K9T4j+DX1vf5cwtF4mbI4E2A+1uZa CN+o/ZwHbDe0Ncs4LwFTDpu4fsv13kcTVbFVyMxn4c3bxV9MGJKuRUM4v6PRfpOIeYCj Hwy9Sa6WdNoonOhOQbSgeBfpqCinJs6r9Ypld8QctYbGJGe35FE6/yTOLRzU7WcR2+L0 VtiQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 207.154.65.135 is neither permitted nor denied by best guess record for domain of sjl@vctlabs.com) smtp.mailfrom=sjl@vctlabs.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:date:from:to:subject:message-id:mime-version :content-disposition:user-agent:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=bo9lSW4pvbpfsqkzW2xO9O/MJ/+bUFPnJo3Cj2xiCNM=; b=GhRPOeL7aohoFsIdtOC6BzER4x/DSfJ0PIXaDO4lAOdvP08OXNBbnIe1Ac6vF7VoNb uLycqALpDQuX8Lfx2DH5rj1LaFv3HOz48hDPiyl9lZBIGLaIx3rCNbtLlEI+4gNPTkI6 dy/HC5L4JtWQuDl4w7WfQq9xGl7FiPmofp9yGWYxog403K7e+KKL2eAYzoTyz+z8IKZr gNmT4NoSHVzNi7d65ncB693zJDvE9vuHWrsBuAzu6cwvGIVk11PfsxNDR7/oCGZY9LnD NFcXSZuo/+f/hFenzGwKiVF72nCvFN5YUWeTRXrLp2Uw1DPbI3K+vcZu/u4qRgeMaM2E nQIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:date:from:to:subject:message-id :mime-version:content-disposition:user-agent:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=bo9lSW4pvbpfsqkzW2xO9O/MJ/+bUFPnJo3Cj2xiCNM=; b=Rg8W23PgPTCDILJjnW0r2g4pkGYU4I4z9a60iIvFpIWLcJ8Czi22N/HR7W0glBPM05 HiKXEorAleOnBpBk0G0parhWxVo4PZ8Tuj1sA03/G5AQXxDWFhdIE/58cc0VSlNbusWl OXH+JGjyf22DkT/LfPxr/bIlIQqZXO/rbuQ0vm5qhgGHs0IFb5QkkntO6ho+085FAx5N FhasJHLG+WxzD8y05/1b/+WdHbLVTEhxP+1lNt9se+yaDXd6KeAhd3uv4NaAeDoOKHoh f4fbBAl4fQGsWzEqyGgRqXiZopix+n4oK59/TCtcabHr+muRkKTPg8zSi/CY5+arLums 08Uw== Sender: swupdate@googlegroups.com X-Gm-Message-State: AKGB3mI0+g7fgv+a9lYaObUY3oUW71b/f3IFhz9BsVKa+RAED9PeIwOa JtoWQ8B9qyfYRydSkJLgroI= X-Google-Smtp-Source: ACJfBovo8/hcuwdDM6Xof/iXK8xp+mTcvwZl4QFzdPCdzBu9gLVBQXvF36q/11IXJDe+iYV2+V+Qpw== X-Received: by 10.36.9.208 with SMTP id 199mr36356itm.0.1513247946012; Thu, 14 Dec 2017 02:39:06 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 10.99.54.65 with SMTP id d62ls1084254pga.30.gmail; Thu, 14 Dec 2017 02:39:05 -0800 (PST) X-Received: by 10.84.242.129 with SMTP id d1mr2691155pll.54.1513247945397; Thu, 14 Dec 2017 02:39:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513247945; cv=none; d=google.com; s=arc-20160816; b=0BN41XR5+kIicOYHtk+jq0BH+FfgLtx7B81So92sTqGk1UQGOvG/aWQK7xiYVZ8vOP UirqejB5vS33dQ438rY4nu9JvFKm9dB2NOe3V+7hokz0pBOCrIExb4+8EU0HjI/IcgLM 7+4SXdDeLfOopEPRo0BZgsK3SjsLwlcHM9+RPBWLQMPuQeEfPMdSz4L8dfM9ss0cLwap 5bhA5FDjcmKZqFxyiBJOrYmejrIdRDeclA6nBIfjzgWICyREbpHWlvCSF7lXWyjH5Y/k pYD1Y3mN87pjk5nVgjhYNz6X8zr5YgT29fHePFh9vNfn+n2w1yVgyPrC7Pmkz7vCnHJO UCmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:to :from:date:arc-authentication-results; bh=96BAptKog/pkH8xTST3SkghXpsKJ5TD0KKftkDa5Vww=; b=Hmmgdxsn8nBXRjxS26Hgdd+ERhQVxYL02iNcUUes6neIW9A9A+MQHmZyWnUi+uDnQe v3d/eGaokazhuzpuodQhHRBLhp6tssH6MOR1t/0Khz5eD71ce5/YvCmjYrSkKT++Yg6i V3iNhzuh7jMvecvwUV6Ji6e73Se30JieRAiQS0B8gBlbdUaeufPWsYaNBOH8fVUlTYtl bYzd/p5KmsBEJ66kZNm70i6QKR9eYQjs8mEaRgXA+BPF5wh5XPYHlgJ6QaSnIasNt1Cg 1YLekKf9QMD7ncuyKWQtMKcAzuhcW2c+Ojc7KOTelk4KeBrdDLnvAhBYFj9jZUfay+Re qoqQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 207.154.65.135 is neither permitted nor denied by best guess record for domain of sjl@vctlabs.com) smtp.mailfrom=sjl@vctlabs.com Received: from dent.vctlabs.com (net-cf9a4187.iis.impulse.net. [207.154.65.135]) by gmr-mx.google.com with ESMTPS id m9si277378plt.2.2017.12.14.02.39.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Dec 2017 02:39:05 -0800 (PST) Received-SPF: neutral (google.com: 207.154.65.135 is neither permitted nor denied by best guess record for domain of sjl@vctlabs.com) client-ip=207.154.65.135; Received: by dent.vctlabs.com (Postfix, from userid 1000) id 7AA74280339; Thu, 14 Dec 2017 02:41:36 -0800 (PST) Date: Thu, 14 Dec 2017 02:41:36 -0800 From: "S. Lockwood-Childs" To: swupdate@googlegroups.com Subject: [swupdate] [PATCH] archive handler: add preserve-attributes option Message-ID: <20171214104136.GJ27580@vctlabs.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Original-Sender: sjl@vctlabs.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 207.154.65.135 is neither permitted nor denied by best guess record for domain of sjl@vctlabs.com) smtp.mailfrom=sjl@vctlabs.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Previously extracted files did not keep attributes stored in the archive file, e.g. all files and dirs come out root:root ownership and with current timestamps. The new preserve-attributes option asks libarchive to preserve timestamps, uid/gid, file perm bits, acls, file attributes (immutable, etc), and extended attributes. /* sw-description snippet */ files: ( { filename = "some.tar.gz"; path = "/opt"; preserve-attributes = true; } ); Note that uid/gid preserves numeric values in a tarball, i.e. same as tar with --numeric-owner flag. At this time libarchive doesn't support keeping names instead. Signed-off-by: S. Lockwood-Childs --- doc/source/sw-description.rst | 9 +++++++++ handlers/archive_handler.c | 11 +++++++++-- include/swupdate.h | 1 + parser/parser.c | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index 4a798ee..71bdeff 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -742,6 +742,7 @@ attribute. For example: type = "archive"; path = "/tmp/test"; hook = "set_version"; + preserve-attributes = true; } ); @@ -847,6 +848,14 @@ There are 4 main sections inside sw-description: | | | | "filesystem" type. (path is always | | | | | relative to the mount point.) | +-------------+----------+------------+---------------------------------------+ + | preserve- | bool | files | flag to control whether the following | + | attributes | | | attributes will be preserved when | + | | | | files are unpacked from an archive | + | | | | (assuming destination filesystem | + | | | | supports them, of course): | + | | | | timestamp, uid/gid (numeric), perms, | + | | | | file attributes, extended attributes | + +-------------+----------+------------+---------------------------------------+ | type | string | images | string identifier for the handler, | | | | files | as it is set by the handler when it | | | | scripts | regitsters itself. | diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c index 0568a41..b4895f0 100644 --- a/handlers/archive_handler.c +++ b/handlers/archive_handler.c @@ -200,11 +200,18 @@ static int install_archive_image(struct img_type *img, return -EFAULT; } - TRACE("Installing file %s on %s\n", - img->fname, path); + TRACE("Installing file %s on %s, %s attributes\n", + img->fname, path, + img->preserve_attributes ? "preserving" : "ignoring"); tf.flags = 0; + if (img->preserve_attributes) { + tf.flags |= ARCHIVE_EXTRACT_OWNER | ARCHIVE_EXTRACT_PERM | + ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_ACL | + ARCHIVE_EXTRACT_FFLAGS | ARCHIVE_EXTRACT_XATTR; + } + ret = pthread_create(&extract_thread, &attr, extract, &tf); if (ret) { ERROR("Code from pthread_create() is %d\n", diff --git a/include/swupdate.h b/include/swupdate.h index 09e81d5..6424fc7 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -73,6 +73,7 @@ struct img_type { int required; int provided; int compressed; + int preserve_attributes; /* whether to preserve attributes in archives */ int is_encrypted; int install_directly; int is_script; index c8a51e2..1adce54 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -517,6 +517,7 @@ static int parse_files(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua_ strcpy(file->type, "rawfile"); } get_field(p, elem, "compressed", &file->compressed); + get_field(p, elem, "preserve-attributes", &file->preserve_attributes); get_field(p, elem, "installed-directly", &file->install_directly); get_field(p, elem, "install-if-different", &file->id.install_if_different); get_field(p, elem, "encrypted", &file->is_encrypted);