From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1S7AZ4-0005Bx-VY for garchives@archives.gentoo.org; Mon, 12 Mar 2012 19:05:51 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 366CAE0D9C; Mon, 12 Mar 2012 19:05:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id EB449E0D9C for ; Mon, 12 Mar 2012 19:05:42 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 36B471B4057 for ; Mon, 12 Mar 2012 19:05:42 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id F3B8FE5402 for ; Mon, 12 Mar 2012 19:05:40 +0000 (UTC) From: "Robin H. Johnson" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" Message-ID: <1331579070.65be94a34a60c5c09e40aa85b65820a1b792f91f.robbat2@gentoo> Subject: [gentoo-commits] proj/openrc:master commit in: sh/ X-VCS-Repository: proj/openrc X-VCS-Files: sh/tmpfiles.sh.in X-VCS-Directories: sh/ X-VCS-Committer: robbat2 X-VCS-Committer-Name: Robin H. Johnson X-VCS-Revision: 65be94a34a60c5c09e40aa85b65820a1b792f91f X-VCS-Branch: master Date: Mon, 12 Mar 2012 19:05:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: f1328483-09da-4d7b-bc9a-ed102a0c4aa0 X-Archives-Hash: ae2fe315d4214ffcf1344a9e6e6dd43b commit: 65be94a34a60c5c09e40aa85b65820a1b792f91f Author: Robin H. Johnson gentoo org> AuthorDate: Mon Mar 12 18:59:53 2012 +0000 Commit: Robin H. Johnson gentoo org> CommitDate: Mon Mar 12 19:04:30 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/openrc.git;a=3D= commit;h=3D65be94a3 sh/tmpfiles: Upstream clarifications & quoting fixes. Upstream has clarified via IRC: - hardcoding /usr/lib/ is an explicit choice. It should NOT consider $libdir at all. - The z/Z relabel types should call restorecon, not chcon. - Whitespace is not allowed in tmpfiles.d/*.conf path entries, but is allowed in globs results. Fixed quoting of path arguments for this. Signed-off-by: Robin H. Johnson gentoo.org> --- sh/tmpfiles.sh.in | 34 ++++++++++++++++++---------------- 1 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sh/tmpfiles.sh.in b/sh/tmpfiles.sh.in index 9c73897..de81964 100755 --- a/sh/tmpfiles.sh.in +++ b/sh/tmpfiles.sh.in @@ -19,17 +19,19 @@ warninvalid() { } >&2 =20 relabel() { + local path local paths=3D$1 mode=3D$2 uid=3D$3 gid=3D$4 =20 for path in ${paths}; do - if [ -e $path ]; then + if [ -e "$path" ]; then [ $uid !=3D '-' ] && chown $CHOPTS "$uid" "$path" [ $gid !=3D '-' ] && chgrp $CHOPTS "$gid" "$path" [ $mode !=3D '-' ] && chmod $CHOPTS "$mode" "$path" - # TODO: SELinux relabel + [ -x /sbin/restorecon ] && restorecon $CHOPTS "$path" fi done } + _b() { # Create a block device node if it doesn't exist yet local path=3D$1 mode=3D$2 uid=3D$3 gid=3D$4 age=3D$5 arg=3D$6 @@ -49,7 +51,7 @@ _f() { =20 [ $CREATE -gt 0 ] || return 0 =20 - if [ ! -e $path ]; then + if [ ! -e "$path" ]; then install -m"$mode" -o"$uid" -g"$gid" /dev/null "$path" [ -n "$arg" ] && _w "$@" fi @@ -80,7 +82,7 @@ _D() { # Create or empty a directory local path=3D$1 mode=3D$2 uid=3D$3 gid=3D$4 =20 - if [ -d $path ] && [ $REMOVE -gt 0 ]; then + if [ -d "$path" ] && [ $REMOVE -gt 0 ]; then find "$path" -mindepth 1 -maxdepth 1 -xdev -exec rm -rf {} + fi =20 @@ -125,10 +127,10 @@ _r() { =20 [ $REMOVE -gt 0 ] || return 0 =20 - for path in "${paths}"; do - if [ -f $path ]; then + for path in ${paths}; do + if [ -f "$path" ]; then rm -f "$path" - elif [ -d $path ]; then + elif [ -d "$path" ]; then rmdir "$path" fi done @@ -142,8 +144,8 @@ _R() { =20 [ $REMOVE -gt 0 ] || return 0 =20 - for path in "${paths}"; do - [ -d $path ] && rm -rf --one-file-system "$path" + for path in ${paths}; do + [ -d "$path" ] && rm -rf --one-file-system "$path" done } =20 @@ -174,9 +176,8 @@ _Z() { CREATE=3D0 REMOVE=3D0 CLEAN=3D0 VERBOSE=3D0 DRYRUN=3D0 error=3D0 LINENO=3D= 0 FILE=3D fragments=3D -# TODO: The systemd spec explicitly says /usr/lib/, but it should probab= ly be -# OUTSIDE of lib entirely, or at the very least handle multilib systems = better. -tmpfiles_dirs=3D'/usr/lib64/tmpfiles.d/ /usr/lib/tmpfiles.d/ /etc/tmpfil= es.d/ /run/tmpfiles.d/' +# XXX: The harcoding of /usr/lib/ is an explicit choice by upstream +tmpfiles_dirs=3D'/usr/lib/tmpfiles.d/ /etc/tmpfiles.d/ /run/tmpfiles.d/' tmpfiles_basenames=3D'' tmpfiles_d=3D'' # Build a list of sorted unique basenames @@ -212,7 +213,7 @@ while [ $# -gt 0 ]; do done =20 if [ $(( CREATE + REMOVE )) -ne 1 ] ; then - printf 'usage: %s [--create] [--remove]\n' "${0##*/}" + printf 'usage: %s [--create] [--remove] [--clean] [--verbose] [--dry-ru= n]\n' "${0##*/}" exit 1 fi =20 @@ -230,14 +231,15 @@ for FILE in $tmpfiles_d ; do # d /run/user 0755 root root 10d - # Mode, UID, GID, Age, Argument may be omitted! =20 - # TODO: Sorry, we don't handle whitespace in paths. + # XXX: Upstream says whitespace is NOT permitted in the Path argument. + # But IS allowed when globs are expanded for the x/r/R/z/Z types. while read line; do LINENUM=3D$(( LINENUM+1 )) =20 - # This will fix up whitespace and comment lines - # skip over comments and empty lines + # This will skip over comments and empty lines set -- $line =20 + # Unless we have both command and path, skip this line. if [ -z "$1" -o -z "$2" ]; then continue fi