From ruben at mrbrklyn.com Wed Jan 1 18:49:58 2020 From: ruben at mrbrklyn.com (Ruben Safir) Date: Wed, 1 Jan 2020 12:49:58 -0500 Subject: [artix-general] Pacman Upgrade strangeness Message-ID: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> It seems that the pacman upgrade path has reached a dead end and I'm at a loss to solve this [ruben at flatbush ~]$ sudo pacman -Syyu :: Synchronizing package databases... system 222.9 KiB 3.25 MiB/s 00:00 [######################] 100% world 938.7 KiB 10.5 MiB/s 00:00 [######################] 100% galaxy 834.0 KiB 11.6 MiB/s 00:00 [######################] 100% extra 1641.2 KiB 10.5 MiB/s 00:00 [######################] 100% community 4.8 MiB 10.6 MiB/s 00:00 [######################] 100% :: Starting full system upgrade... resolving dependencies... looking for conflicting packages... :: python-pyqt5 and pyqt5-common are in conflict. Remove pyqt5-common? [y/N] Answering y or N both fail the same way: error: failed to prepare transaction (could not satisfy dependencies) :: installing xorgproto (2019.2-2) breaks dependency 'dmxproto' required by libdmx :: installing xorgproto (2019.2-2) breaks dependency 'xf86dgaproto' required by libxxf86dga -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From pierrot.labastie at gmail.com Wed Jan 1 19:09:21 2020 From: pierrot.labastie at gmail.com (Pierre Labastie) Date: Wed, 1 Jan 2020 19:09:21 +0100 Subject: [artix-general] Pacman Upgrade strangeness In-Reply-To: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> References: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> Message-ID: <29c26c91-6dbf-3c2d-9ba1-e722f4410931@gmail.com> Le 01/01/2020 ? 18:49, Ruben Safir via artix-general a ?crit?: > It seems that the pacman upgrade path has reached a dead end and I'm at > a loss to solve this > > > > [ruben at flatbush ~]$ sudo pacman -Syyu > :: Synchronizing package databases... > system 222.9 KiB 3.25 MiB/s 00:00 > [######################] 100% > world 938.7 KiB 10.5 MiB/s 00:00 > [######################] 100% > galaxy 834.0 KiB 11.6 MiB/s 00:00 > [######################] 100% > extra 1641.2 KiB 10.5 MiB/s 00:00 > [######################] 100% > community 4.8 MiB 10.6 MiB/s 00:00 > [######################] 100% > :: Starting full system upgrade... > resolving dependencies... > looking for conflicting packages... > :: python-pyqt5 and pyqt5-common are in conflict. Remove pyqt5-common? > [y/N] > > Answering y or N both fail the same way: > > > error: failed to prepare transaction (could not satisfy dependencies) > :: installing xorgproto (2019.2-2) breaks dependency 'dmxproto' required > by libdmx > :: installing xorgproto (2019.2-2) breaks dependency 'xf86dgaproto' > required by libxxf86dga I think this has been answered here [1], but I am not sure since I do not have the issue Pierre [1] https://artixlinux.org/news.php#Xorg_cleanup_requires_manual_intervention From sgorava at artixlinux.org Wed Jan 1 19:13:56 2020 From: sgorava at artixlinux.org (Juraj Oravec) Date: Wed, 01 Jan 2020 19:13:56 +0100 Subject: [artix-general] Pacman Upgrade strangeness In-Reply-To: <29c26c91-6dbf-3c2d-9ba1-e722f4410931@gmail.com> References: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> <29c26c91-6dbf-3c2d-9ba1-e722f4410931@gmail.com> Message-ID: <5331760.DvuYhMxLoT@void> > python-pyqt5 and pyqt5-common are in conflict. Remove pyqt5-common? Maybe we should truly make an announcement for this. $ pacman -Rdd pyqt5-common $ pacman -Syu Should do the job (well, did for me). -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part. URL: From ruben at mrbrklyn.com Thu Jan 2 09:18:19 2020 From: ruben at mrbrklyn.com (Ruben Safir) Date: Thu, 2 Jan 2020 03:18:19 -0500 Subject: [artix-general] Pacman Upgrade strangeness In-Reply-To: <5331760.DvuYhMxLoT@void> References: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> <29c26c91-6dbf-3c2d-9ba1-e722f4410931@gmail.com> <5331760.DvuYhMxLoT@void> Message-ID: <20200102081819.GA18915@www2.mrbrklyn.com> On Wed, Jan 01, 2020 at 07:13:56PM +0100, Juraj Oravec via artix-general wrote: > > python-pyqt5 and pyqt5-common are in conflict. Remove pyqt5-common? > > Maybe we should truly make an announcement for this. > > $ pacman -Rdd pyqt5-common > $ pacman -Syu > > Should do the job (well, did for me). That seems to have solved half of this - seems like xorgproto still is causing trouble looking for conflicting packages... error: failed to prepare transaction (could not satisfy dependencies) :: installing xorgproto (2019.2-2) breaks dependency 'dmxproto' required by libdmx :: installing xorgproto (2019.2-2) breaks dependency 'xf86dgaproto Is there a reason why python broke? I'm just curious and I will probably learn something if I understood why. > -- > artix-general mailing list > artix-general at artixlinux.org > https://lists.artixlinux.org/listinfo/artix-general -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From sgorava at artixlinux.org Thu Jan 2 12:38:48 2020 From: sgorava at artixlinux.org (Juraj Oravec) Date: Thu, 02 Jan 2020 12:38:48 +0100 Subject: [artix-general] Pacman Upgrade strangeness In-Reply-To: <20200102081819.GA18915@www2.mrbrklyn.com> References: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> <5331760.DvuYhMxLoT@void> <20200102081819.GA18915@www2.mrbrklyn.com> Message-ID: <2716334.e9J7NaK4W3@void> On ?tvrtok 2. janu?ra 2020 9:18:19 CET Ruben Safir wrote: > Is there a reason why python broke? I'm just curious and I will > probably learn something if I understood why. I believe upstream changes within pyqt5. Which were reflected in Arch packages. https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/ pyqt5&id=bd544723e6262bc978d4a7680eedeef90186dc41 https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/ pyqt5&id=314215fd73f4d6b296393712e885eca102343a70 You can see the list of all changes at: https://git.archlinux.org/svntogit/packages.git/log/trunk?h=packages/ pyqt5 That is all I know about this problem, if you have more question about it please go and and ask Mr. Antonio Rojas at who made these changes in Archlinux, or ask the pyqt5 developers. And why pacman did not manage to perform update, well lets ask some pacman guru because I see it as failure. Best regards. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part. URL: From ruben at mrbrklyn.com Thu Jan 2 14:07:30 2020 From: ruben at mrbrklyn.com (Ruben Safir) Date: Thu, 2 Jan 2020 08:07:30 -0500 Subject: [artix-general] Public Archive Message-ID: <20200102130730.GA20864@www2.mrbrklyn.com> Would anyone object if I made a public archive of this mailing list on the NYLXS.org website? Ruben -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From ruben at mrbrklyn.com Thu Jan 2 14:08:09 2020 From: ruben at mrbrklyn.com (Ruben Safir) Date: Thu, 2 Jan 2020 08:08:09 -0500 Subject: [artix-general] Pacman Upgrade strangeness In-Reply-To: <2716334.e9J7NaK4W3@void> References: <6e9f7ed7-c619-9d44-b834-ebbf6b14b38a@mrbrklyn.com> <5331760.DvuYhMxLoT@void> <20200102081819.GA18915@www2.mrbrklyn.com> <2716334.e9J7NaK4W3@void> Message-ID: <20200102130809.GB20864@www2.mrbrklyn.com> On Thu, Jan 02, 2020 at 12:38:48PM +0100, Juraj Oravec wrote: > On ?tvrtok 2. janu?ra 2020 9:18:19 CET Ruben Safir wrote: > > Is there a reason why python broke? I'm just curious and I will > > probably learn something if I understood why. > > I believe upstream changes within pyqt5. > > Which were reflected in Arch packages. > https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/ > pyqt5&id=bd544723e6262bc978d4a7680eedeef90186dc41 > > https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/ > pyqt5&id=314215fd73f4d6b296393712e885eca102343a70 > > You can see the list of all changes at: > https://git.archlinux.org/svntogit/packages.git/log/trunk?h=packages/ > pyqt5 > > That is all I know about this problem, if you have more question about > it please go and and ask Mr. Antonio Rojas at who > made these changes in Archlinux, or ask the pyqt5 developers. > > And why pacman did not manage to perform update, well lets ask some > pacman guru because I see it as failure. > > Best regards. Thank you most graciously! Reuvain -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From nous at artixlinux.org Thu Jan 2 21:54:53 2020 From: nous at artixlinux.org (Christos Nouskas) Date: Thu, 2 Jan 2020 22:54:53 +0200 Subject: [artix-general] Public Archive In-Reply-To: <20200102130730.GA20864@www2.mrbrklyn.com> References: <20200102130730.GA20864@www2.mrbrklyn.com> Message-ID: <20200102225453.3cec28ce@artixlinux.org> On Thu, 2 Jan 2020 08:07:30 -0500 Ruben Safir via artix-general wrote: > Would anyone object if I made a public archive of this mailing list on > the NYLXS.org website? Personally, I wouldn't. -- https://systemd-free.artixlinux.org From ruben at mrbrklyn.com Sat Jan 4 03:59:03 2020 From: ruben at mrbrklyn.com (Ruben Safir) Date: Fri, 3 Jan 2020 21:59:03 -0500 Subject: [artix-general] X is now very sluggish Message-ID: <20200104025903.GA4936@www2.mrbrklyn.com> whatever they changed with X in this last upgrade, they have dragging the response from the server to a trick. The vidoe playback has been aweful -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From ruben at mrbrklyn.com Sat Jan 4 10:14:52 2020 From: ruben at mrbrklyn.com (Ruben Safir) Date: Sat, 4 Jan 2020 04:14:52 -0500 Subject: [artix-general] X is now very sluggish In-Reply-To: <20200104025903.GA4936@www2.mrbrklyn.com> References: <20200104025903.GA4936@www2.mrbrklyn.com> Message-ID: <20200104091452.GA6624@www2.mrbrklyn.com> whatever they changed with X in this last upgrade, they have dragging the response from the server to a trickle. The video playback has been aweful, as has been mouse response, etc. My workstation suddenly feels very underpowered. I know there is not much artix developers can do about this, but it is what it is. -- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com Being so tracked is for FARM ANIMALS and extermination camps, but incompatible with living as a free human being. -RI Safir 2013 From e5ten.arch at gmail.com Mon Jan 6 20:31:03 2020 From: e5ten.arch at gmail.com (Ethan Sommer) Date: Mon, 6 Jan 2020 14:31:03 -0500 Subject: [artix-general] [PATCH] various shell improvements Message-ID: <20200106193103.19952-1-e5ten.arch@gmail.com> make POSIX sh compatible remove array usage remove "local" builtin usage remove herestring usage remove string indexing usage use shellcheck directive to specify source file locations use manual shell option processing instead of getopt use : to delimit file names in list instead of space like PATH check command results directly instead of checking $? make sed usage POSIX compatible and more concise use case to check variables against multiple strings instead of a series of ifs --- bin/opensysusers.in | 10 +-- bin/sysusers.in | 125 ++++++++++++++----------------- lib/common.sh | 177 ++++++++++++++++++++------------------------ 3 files changed, 143 insertions(+), 169 deletions(-) diff --git a/bin/opensysusers.in b/bin/opensysusers.in index bc7834c..f8b8a43 100755 --- a/bin/opensysusers.in +++ b/bin/opensysusers.in @@ -4,15 +4,15 @@ # # This is an implementation of sysusers.d spec without systemd command -sysusersver=@VERSION@ - -source @LIBDIR@/opensysusers/common.sh +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh get_conf_files get_conf_paths +IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done -exit ${error} +exit "${error}" diff --git a/bin/sysusers.in b/bin/sysusers.in index 2d5b7aa..cb96a17 100755 --- a/bin/sysusers.in +++ b/bin/sysusers.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Released under the 2-clause BSD license. # @@ -7,118 +7,107 @@ sysusersver=@VERSION@ usage() { - printf "@BINNAME@\n\n" - - printf "@BINNAME@ creates system users and groups, based on the file\n" - printf "format and location specified in sysusers.d(5).\n\n" - - printf "Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]\n\n" - - printf "Options:\n" - printf " --root=root All paths will be prefixed with the\n" - printf " given alternate root path, including\n" - printf " config search paths.\n" - printf " --replace=PATH Don't run check in the package\n" - printf " --inline Treat each positional argument as a\n" - printf " separate configuration line instead of a\n" - printf " file name.\n" - printf " -h, --help Print a short help text and exit.\n" - printf " --version Print a short version string and exit.\n" + printf '%s\n' \ + '@BINNAME@' '' \ + '@BINNAME@ creates system users and groups, based on the file' \ + 'format and location specified in sysusers.d(5).' '' \ + 'Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]' '' \ + 'Options:' \ + ' --root=root All paths will be prefixed with the' \ + ' given alternate root path, including' \ + ' config search paths.' \ + " --replace=PATH Don't run check in the package" \ + ' --inline Treat each positional argument as a' \ + ' separate configuration line instead of a' + ' file name.' \ + ' -h, --help Print a short help text and exit.' \ + ' --version Print a short version string and exit.' + exit "$1" } -TEMP=$(getopt -o "h" -l "root:,replace:,inline,help,version" -n "@BINNAME@" -- "$@") -if [ $? -ne 0 ]; then - usage - exit 1; -fi - -arguments=() replace='' -version=0 inline=0 -error=0 root='' replace='' -eval set -- "${TEMP}" -unset TEMP -while true; do - case "${1}" in - -h|--help) - usage - exit 0; - shift; - ;; +while :; do + case "$1" in + -h|--help) usage 0 ;; + --root=*) root="${1#--root=}" ;; --root) - root="${2}" - shift 2; + root="$2" + shift ;; + --replace=*) replace="${1#--replace=}" ;; --replace) - replace="${2}" - shift 2; - ;; - --inline) - inline=1 - shift; + replace="$2" + shift ;; + --inline) inline=1 ;; --version) - version=1 - shift; + printf '%s\n' "${sysusersver}" + exit 0 ;; - --) shift; args=("${@}"); break;; - *) break;; + --) shift; break ;; + -*) usage 1 ;; + *) break ;; esac + shift done -source @LIBDIR@/opensysusers/common.sh - -if [ ${version} -eq 1 ]; then - echo "${sysusersver}" - exit ${error}; -fi +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh -if [ ${#args[@]} -eq 0 ]; then +if [ "$#" -eq 0 ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done - exit ${error}; + IFS="${_IFS}" + exit "${error}" fi -if [ ${inline} -eq 0 ]; then - for file in "${args[@]}"; do - [ ${file} == '--' ] && continue +if [ "${inline}" -eq 0 ]; then + for file in "$@"; do + [ "${file}" = '--' ] && continue + IFS=':' for dir in ${sysusers_dirs}; do if [ -f "${dir}/${file}" ]; then parse_file "${dir}/${file}" break fi done + IFS="${_IFS}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" else - for string in "${args[@]}"; do + for string in "$@"; do parse_string "${string}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" fi -exit ${error}; +exit "${error}" diff --git a/lib/common.sh b/lib/common.sh index 0e84054..fa7b09b 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Copyright (c) 2012 Gentoo Foundation # Released under the 2-clause BSD license. @@ -6,142 +6,122 @@ # Common functions and variables needed by opensysusers die() { - echo ${@} 1>&2; - exit 1; + printf '%s\n' "$*" >&2 + exit 1 } warninvalid() { - local msg=$1 - [ -z "${msg}" ] && msg='ignoring invalid entry' - printf "sysusers: ${msg} on line %d of \`%s'\n" "${line}" "${file}" - error=$(( error+1 )) + [ -z "$1" ] && set -- 'ignoring invalid entry' + printf "sysusers: %s on line %d of \`%s'\n" "$1" "${line}" "${file}" + : "$((error += 1))" } >&2 in_array() { - local element - for element in "${@:2}"; do - [[ "${element}" == "${1}" ]] && return 0; + needle="$1" + shift + for element in "$@"; do + [ "${element}" = "${needle}" ] && return 0 done return 1 } add_group() { - local name=${1} id=${2} - getent group "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - groupadd -r "${name}" - else - if ! grep -qiw "${id}" /etc/group; then - groupadd -g "${id}" "${name}" - fi + # add_group + if ! getent group "$1" >/dev/null; then + if [ "$2" = '-' ]; then + groupadd -r "$1" + elif ! grep -qiw "$2" /etc/group; then + groupadd -g "$2" "$1" fi fi } add_user() { - local name=${1} id=${2} gecos=${3} home=${4} - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - useradd -rc "${gecos}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + # add_user + if getent passwd "$1" >/dev/null; then + if [ "$2" = '-' ]; then + useradd -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1" else - useradd -rc "${gecos}" -u "${id}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + useradd -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1" fi - passwd -l "${name}" &>/dev/null + passwd -l "$1" >/dev/null 2>&1 fi } update_login_defs() { - local name=${1} id=${2} - [ ! "${name}" == '-' ] && warninvalid && return - i=1; - IFS='-' read -ra temp <<< "${id}" - for part in "${temp[@]}"; do - if [ "${i}" -eq 1 ]; then - min=${part} - fi - if [ "${i}" -eq 2 ]; then - max=${part} - fi - if [ "${i}" -eq 3 ]; then - warninvalid && continue - fi - i=$(( i+1 )) + # update_login_defs + [ "$1" != '-' ] && warninvalid && return + i=1 + _IFS="${IFS}" IFS='-' + for part in $2; do + case "${i}" in + 1) min="${part}" ;; + 2) max="${part}" ;; + 3) warninvalid && continue ;; + esac + : "$((i += 1))" done - [ ${min} -ge ${max} ] && warninvalid "invalid range" && return + IFS="${_IFS}" + [ "${min}" -ge "${max}" ] && warninvalid "invalid range" && return while read -r NAME VALUE; do - [ "${NAME}" == 'SYS_UID_MAX' ] && suid_max=${VALUE} - [ "${NAME}" == 'SYS_GID_MAX' ] && sgid_max=${VALUE} + [ "${NAME}" = 'SYS_UID_MAX' ] && suid_max=${VALUE} + [ "${NAME}" = 'SYS_GID_MAX' ] && sgid_max=${VALUE} done < /etc/login.defs - [[ $min -lt $suid_max ]] && warninvalid "invalid range" && return - [[ $min -lt $sgid_max ]] && warninvalid "invalid range" && return + [ "${min}" -lt "${suid_max}" ] && warninvalid "invalid range" && return + [ "${min}" -lt "${sgid_max}" ] && warninvalid "invalid range" && return - sed -re "s/^(UID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(UID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs - sed -re "s/^(GID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(GID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs + sed -e "s/^\([GU]ID_MIN\)\([[:space:]]\+\)\(.*\)/\1\2${min}/" \ + -e "s/^\([GU]ID_MAX\)\([[:space:]]\+\)\(.*\)/\1\2${max}/" \ + -i /etc/login.defs } parse_file() { - local file="${1}" - if [ -f ${file} ]; then - while read cline; do - [[ "${cline}" =~ ^#.*$ ]] && continue + if [ -f "$1" ]; then + while read -r cline; do + [ "${cline#\#}" = "${cline}" ] || continue parse_string "${cline}" - done < ${file} + done < "$1" fi } parse_string() { - local line=0 cline="${1}" - [ "${cline:0:1}" == "#" ] && continue - eval "set args ${cline}; shift" + line=0 + [ "${1#\#}" = "$1" ] || continue + set -f + set -- $1 + set +f i=0 - for part in "${@}"; do - if [ $i -eq 0 ]; then - type="${part}" - fi - if [ $i -eq 1 ]; then - name="${part}" - fi - if [ $i -eq 2 ]; then - id="${part}" - fi - if [ $i -eq 3 ]; then - gecos="${part}" - fi - if [ $i -eq 4 ]; then - home="${part}" - fi - i=$(( i+1 )) + for part in "$@"; do + case "${i}" in + 0) type="${part}" ;; + 1) name="${part}" ;; + 2) id="${part}" ;; + 3) gecos="${part}" ;; + 4) home="${part}" ;; + esac + : "$((i += 1))" done - line=$(( line+1 )) + : "$((line += 1))" case "${type}" in u) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; continue ;; esac + [ "${home:--}" = - ] && home='/' add_group "${name}" "${id}" - [ "${id}" == '-' ] && id=$(getent group "${name}" | cut -d: -f3) + [ "${id}" = '-' ] && id="$(getent group "${name}")" id="${id#*:*:}" id="${id%%:*}" add_user "${name}" "${id}" "${gecos}" "${home}" ;; g) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; continue ;; esac + [ "${home:--}" = '-' ] && home='/' add_group "${name}" "${id}" ;; m) add_group "${name}" '-' - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then + if ! getent passwd "${name}" >/dev/null; then useradd -r -g "${id}" -s '/sbin/nologin' "${name}" - passwd -l "${name}" &>/dev/null + passwd -l "${name}" >/dev/null 2>&1 else usermod -a -G "${id}" "${name}" fi @@ -163,22 +143,27 @@ parse_string() { get_conf_files() { for dir in ${sysusers_dirs}; do [ -d "${dir}" ] && for file in "${dir}"/*.conf; do - [ "${replace}" != '' ] && [ "${dir}" == "$(dirname ${replace})" ] && [ "${file##*/}" == "${replace##*/}" ] && continue - [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames}\n${file##*/}" + [ -n "${replace}" ] && + [ "${dir}" = "$(dirname ${replace})" ] && + [ "${file##*/}" = "${replace##*/}" ] && + continue + [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames} +${file##*/}" done done - FILES="$(printf "${sysusers_basenames}\n" | sort -u )" + FILES="$(printf '%s\n' "${sysusers_basenames}" | sort -u)" } get_conf_paths() { for b in ${FILES}; do real_f='' for d in ${sysusers_dirs}; do - [ "${replace}" != '' ] && [ "${d}" == "$(dirname ${replace})" ] && [ "${b}" == "${replace##*/}" ] && continue - f=${d}/${b} - [ -f "${f}" ] && real_f="${f}" + [ -n "${replace}" ] && + [ "${d}" = "$(dirname ${replace})" ] && + [ "${b}" = "${replace##*/}" ] && continue + [ -f "${d}/${b}" ] && real_f="${d}/${b}" done - [ -f "${real_f}" ] && sysusers_d="${sysusers_d} ${real_f}" + [ -f "${real_f}" ] && sysusers_d="${sysusers_d}:${real_f}" done } @@ -188,4 +173,4 @@ sysusers_basenames='' sysusers_d='' replace='' -sysusers_dirs="${root}/usr/lib/sysusers.d ${root}/run/sysusers.d ${root}/etc/sysusers.d" +sysusers_dirs="${root}/usr/lib/sysusers.d:${root}/run/sysusers.d:${root}/etc/sysusers.d" -- 2.24.1 From e5ten.arch at gmail.com Mon Jan 6 20:51:41 2020 From: e5ten.arch at gmail.com (Ethan Sommer) Date: Mon, 6 Jan 2020 14:51:41 -0500 Subject: [artix-general] [PATCH v2] various shell improvements Message-ID: <20200106195141.4802-1-e5ten.arch@gmail.com> make POSIX sh compatible remove array usage remove local builtin usage remove herestring usage remove string indexing usage use shellcheck directive to specify source file locations use manual shell option processing instead of getopt use : to delimit file names in list instead of space like PATH check command results directly instead of checking $? make sed usage POSIX compatible and more concise use case to check variables against multiple strings instead of a series of ifs --- bin/opensysusers.in | 10 +-- bin/sysusers.in | 125 ++++++++++++++---------------- lib/common.sh | 182 +++++++++++++++++++++----------------------- 3 files changed, 147 insertions(+), 170 deletions(-) diff --git a/bin/opensysusers.in b/bin/opensysusers.in index bc7834c..f8b8a43 100755 --- a/bin/opensysusers.in +++ b/bin/opensysusers.in @@ -4,15 +4,15 @@ # # This is an implementation of sysusers.d spec without systemd command -sysusersver=@VERSION@ - -source @LIBDIR@/opensysusers/common.sh +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh get_conf_files get_conf_paths +IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done -exit ${error} +exit "${error}" diff --git a/bin/sysusers.in b/bin/sysusers.in index 2d5b7aa..4ac2ca0 100755 --- a/bin/sysusers.in +++ b/bin/sysusers.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Released under the 2-clause BSD license. # @@ -7,118 +7,107 @@ sysusersver=@VERSION@ usage() { - printf "@BINNAME@\n\n" - - printf "@BINNAME@ creates system users and groups, based on the file\n" - printf "format and location specified in sysusers.d(5).\n\n" - - printf "Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]\n\n" - - printf "Options:\n" - printf " --root=root All paths will be prefixed with the\n" - printf " given alternate root path, including\n" - printf " config search paths.\n" - printf " --replace=PATH Don't run check in the package\n" - printf " --inline Treat each positional argument as a\n" - printf " separate configuration line instead of a\n" - printf " file name.\n" - printf " -h, --help Print a short help text and exit.\n" - printf " --version Print a short version string and exit.\n" + printf '%s\n' \ + '@BINNAME@' '' \ + '@BINNAME@ creates system users and groups, based on the file' \ + 'format and location specified in sysusers.d(5).' '' \ + 'Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]' '' \ + 'Options:' \ + ' --root=root All paths will be prefixed with the' \ + ' given alternate root path, including' \ + ' config search paths.' \ + " --replace=PATH Don't run check in the package" \ + ' --inline Treat each positional argument as a' \ + ' separate configuration line instead of a' \ + ' file name.' \ + ' -h, --help Print a short help text and exit.' \ + ' --version Print a short version string and exit.' + exit "$1" } -TEMP=$(getopt -o "h" -l "root:,replace:,inline,help,version" -n "@BINNAME@" -- "$@") -if [ $? -ne 0 ]; then - usage - exit 1; -fi - -arguments=() replace='' -version=0 inline=0 -error=0 root='' replace='' -eval set -- "${TEMP}" -unset TEMP -while true; do - case "${1}" in - -h|--help) - usage - exit 0; - shift; - ;; +while :; do + case "$1" in + -h|--help) usage 0 ;; + --root=*) root="${1#--root=}" ;; --root) - root="${2}" - shift 2; + root="$2" + shift ;; + --replace=*) replace="${1#--replace=}" ;; --replace) - replace="${2}" - shift 2; - ;; - --inline) - inline=1 - shift; + replace="$2" + shift ;; + --inline) inline=1 ;; --version) - version=1 - shift; + printf '%s\n' "${sysusersver}" + exit 0 ;; - --) shift; args=("${@}"); break;; - *) break;; + --) shift; break ;; + -*) usage 1 ;; + *) break ;; esac + shift done -source @LIBDIR@/opensysusers/common.sh - -if [ ${version} -eq 1 ]; then - echo "${sysusersver}" - exit ${error}; -fi +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh -if [ ${#args[@]} -eq 0 ]; then +if [ "$#" -eq 0 ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done - exit ${error}; + IFS="${_IFS}" + exit "${error}" fi -if [ ${inline} -eq 0 ]; then - for file in "${args[@]}"; do - [ ${file} == '--' ] && continue +if [ "${inline}" -eq 0 ]; then + for file in "$@"; do + [ "${file}" = '--' ] && continue + IFS=':' for dir in ${sysusers_dirs}; do if [ -f "${dir}/${file}" ]; then parse_file "${dir}/${file}" break fi done + IFS="${_IFS}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" else - for string in "${args[@]}"; do + for string in "$@"; do parse_string "${string}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" fi -exit ${error}; +exit "${error}" diff --git a/lib/common.sh b/lib/common.sh index 0e84054..1d38900 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Copyright (c) 2012 Gentoo Foundation # Released under the 2-clause BSD license. @@ -6,142 +6,121 @@ # Common functions and variables needed by opensysusers die() { - echo ${@} 1>&2; - exit 1; + printf '%s\n' "$*" >&2 + exit 1 } warninvalid() { - local msg=$1 - [ -z "${msg}" ] && msg='ignoring invalid entry' - printf "sysusers: ${msg} on line %d of \`%s'\n" "${line}" "${file}" - error=$(( error+1 )) + [ -z "$1" ] && set -- 'ignoring invalid entry' + printf "sysusers: %s on line %d of \`%s'\n" "$1" "${line}" "${file}" + : "$((error += 1))" } >&2 in_array() { - local element - for element in "${@:2}"; do - [[ "${element}" == "${1}" ]] && return 0; + needle="$1" + shift + for element in "$@"; do + [ "${element}" = "${needle}" ] && return 0 done return 1 } add_group() { - local name=${1} id=${2} - getent group "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - groupadd -r "${name}" - else - if ! grep -qiw "${id}" /etc/group; then - groupadd -g "${id}" "${name}" - fi + # add_group + if ! getent group "$1" >/dev/null; then + if [ "$2" = '-' ]; then + groupadd -r "$1" + elif ! grep -qiw "$2" /etc/group; then + groupadd -g "$2" "$1" fi fi } add_user() { - local name=${1} id=${2} gecos=${3} home=${4} - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - useradd -rc "${gecos}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + # add_user + if getent passwd "$1" >/dev/null; then + if [ "$2" = '-' ]; then + useradd -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1" else - useradd -rc "${gecos}" -u "${id}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + useradd -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1" fi - passwd -l "${name}" &>/dev/null + passwd -l "$1" >/dev/null 2>&1 fi } update_login_defs() { - local name=${1} id=${2} - [ ! "${name}" == '-' ] && warninvalid && return - i=1; - IFS='-' read -ra temp <<< "${id}" - for part in "${temp[@]}"; do - if [ "${i}" -eq 1 ]; then - min=${part} - fi - if [ "${i}" -eq 2 ]; then - max=${part} - fi - if [ "${i}" -eq 3 ]; then - warninvalid && continue - fi - i=$(( i+1 )) + # update_login_defs + [ "$1" != '-' ] && warninvalid && return + i=1 + IFS='-' + for part in $2; do + case "${i}" in + 1) min="${part}" ;; + 2) max="${part}" ;; + 3) warninvalid && continue ;; + esac + : "$((i += 1))" done - [ ${min} -ge ${max} ] && warninvalid "invalid range" && return + IFS="${_IFS}" + [ "${min}" -ge "${max}" ] && warninvalid "invalid range" && return while read -r NAME VALUE; do - [ "${NAME}" == 'SYS_UID_MAX' ] && suid_max=${VALUE} - [ "${NAME}" == 'SYS_GID_MAX' ] && sgid_max=${VALUE} + [ "${NAME}" = 'SYS_UID_MAX' ] && suid_max=${VALUE} + [ "${NAME}" = 'SYS_GID_MAX' ] && sgid_max=${VALUE} done < /etc/login.defs - [[ $min -lt $suid_max ]] && warninvalid "invalid range" && return - [[ $min -lt $sgid_max ]] && warninvalid "invalid range" && return + [ "${min}" -lt "${suid_max}" ] && warninvalid "invalid range" && return + [ "${min}" -lt "${sgid_max}" ] && warninvalid "invalid range" && return - sed -re "s/^(UID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(UID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs - sed -re "s/^(GID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(GID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs + sed -e "s/^\([GU]ID_MIN\)\([[:space:]]\+\)\(.*\)/\1\2${min}/" \ + -e "s/^\([GU]ID_MAX\)\([[:space:]]\+\)\(.*\)/\1\2${max}/" \ + -i /etc/login.defs } parse_file() { - local file="${1}" - if [ -f ${file} ]; then - while read cline; do - [[ "${cline}" =~ ^#.*$ ]] && continue + if [ -f "$1" ]; then + while read -r cline; do + [ "${cline#\#}" = "${cline}" ] || continue parse_string "${cline}" - done < ${file} + done < "$1" fi } parse_string() { - local line=0 cline="${1}" - [ "${cline:0:1}" == "#" ] && continue - eval "set args ${cline}; shift" + line=0 + [ "${1#\#}" = "$1" ] || continue + IFS="${_IFS}" + eval "set -- $1" i=0 - for part in "${@}"; do - if [ $i -eq 0 ]; then - type="${part}" - fi - if [ $i -eq 1 ]; then - name="${part}" - fi - if [ $i -eq 2 ]; then - id="${part}" - fi - if [ $i -eq 3 ]; then - gecos="${part}" - fi - if [ $i -eq 4 ]; then - home="${part}" - fi - i=$(( i+1 )) + for part in "$@"; do + case "${i}" in + 0) type="${part}" ;; + 1) name="${part}" ;; + 2) id="${part}" ;; + 3) gecos="${part}" ;; + 4) home="${part}" ;; + esac + : "$((i += 1))" done - line=$(( line+1 )) + : "$((line += 1))" case "${type}" in u) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; continue ;; esac + [ "${home:--}" = - ] && home='/' add_group "${name}" "${id}" - [ "${id}" == '-' ] && id=$(getent group "${name}" | cut -d: -f3) + [ "${id}" = '-' ] && id="$(getent group "${name}")" id="${id#*:*:}" id="${id%%:*}" add_user "${name}" "${id}" "${gecos}" "${home}" ;; g) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; continue ;; esac + [ "${home:--}" = '-' ] && home='/' add_group "${name}" "${id}" ;; m) add_group "${name}" '-' - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then + if ! getent passwd "${name}" >/dev/null; then useradd -r -g "${id}" -s '/sbin/nologin' "${name}" - passwd -l "${name}" &>/dev/null + passwd -l "${name}" >/dev/null 2>&1 else usermod -a -G "${id}" "${name}" fi @@ -161,31 +140,40 @@ parse_string() { # `/run/sysusers.d/foo.conf' will always be read after `/etc/sysusers.d/bar.conf' get_conf_files() { + IFS=':' for dir in ${sysusers_dirs}; do + IFS="${_IFS}" [ -d "${dir}" ] && for file in "${dir}"/*.conf; do - [ "${replace}" != '' ] && [ "${dir}" == "$(dirname ${replace})" ] && [ "${file##*/}" == "${replace##*/}" ] && continue - [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames}\n${file##*/}" + [ -n "${replace}" ] && + [ "${dir}" = "$(dirname "${replace}")" ] && + [ "${file##*/}" = "${replace##*/}" ] && + continue + [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames} +${file##*/}" done done - FILES="$(printf "${sysusers_basenames}\n" | sort -u )" + FILES="$(printf '%s\n' "${sysusers_basenames}" | sort -u)" } get_conf_paths() { + IFS="${_IFS}" for b in ${FILES}; do - real_f='' + real_f='' IFS=':' for d in ${sysusers_dirs}; do - [ "${replace}" != '' ] && [ "${d}" == "$(dirname ${replace})" ] && [ "${b}" == "${replace##*/}" ] && continue - f=${d}/${b} - [ -f "${f}" ] && real_f="${f}" + [ -n "${replace}" ] && + [ "${d}" = "$(dirname "${replace}")" ] && + [ "${b}" = "${replace##*/}" ] && continue + [ -f "${d}/${b}" ] && real_f="${d}/${b}" done - [ -f "${real_f}" ] && sysusers_d="${sysusers_d} ${real_f}" + [ -f "${real_f}" ] && sysusers_d="${sysusers_d}:${real_f}" done } +_IFS="${IFS}" error=0 FILES='' sysusers_basenames='' sysusers_d='' replace='' -sysusers_dirs="${root}/usr/lib/sysusers.d ${root}/run/sysusers.d ${root}/etc/sysusers.d" +sysusers_dirs="${root}/usr/lib/sysusers.d:${root}/run/sysusers.d:${root}/etc/sysusers.d" -- 2.24.1 From e5ten.arch at gmail.com Mon Jan 6 21:08:41 2020 From: e5ten.arch at gmail.com (Ethan Sommer) Date: Mon, 6 Jan 2020 15:08:41 -0500 Subject: [artix-general] [PATCH v3] various shell improvements Message-ID: <20200106200841.5602-1-e5ten.arch@gmail.com> make POSIX sh compatible remove array usage remove local builtin usage remove herestring usage remove string indexing usage use shellcheck directive to specify source file locations use manual shell option processing instead of getopt use : to delimit file names in list instead of space like PATH check command results directly instead of checking $? make sed usage POSIX compatible and more concise use case to check variables against multiple strings instead of a series of ifs replace incorrect usages of continue with return where appropriate Signed-off-by: Ethan Sommer --- bin/opensysusers.in | 11 +-- bin/sysusers.in | 125 ++++++++++++++---------------- lib/common.sh | 185 ++++++++++++++++++++------------------------ 3 files changed, 149 insertions(+), 172 deletions(-) diff --git a/bin/opensysusers.in b/bin/opensysusers.in index bc7834c..7bb2ce5 100755 --- a/bin/opensysusers.in +++ b/bin/opensysusers.in @@ -4,15 +4,16 @@ # # This is an implementation of sysusers.d spec without systemd command -sysusersver=@VERSION@ - -source @LIBDIR@/opensysusers/common.sh +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh get_conf_files get_conf_paths +IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + IFS="${_IFS}" + parse_file "${file}" done -exit ${error} +exit "${error}" diff --git a/bin/sysusers.in b/bin/sysusers.in index 2d5b7aa..3900d48 100755 --- a/bin/sysusers.in +++ b/bin/sysusers.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Released under the 2-clause BSD license. # @@ -7,118 +7,107 @@ sysusersver=@VERSION@ usage() { - printf "@BINNAME@\n\n" - - printf "@BINNAME@ creates system users and groups, based on the file\n" - printf "format and location specified in sysusers.d(5).\n\n" - - printf "Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]\n\n" - - printf "Options:\n" - printf " --root=root All paths will be prefixed with the\n" - printf " given alternate root path, including\n" - printf " config search paths.\n" - printf " --replace=PATH Don't run check in the package\n" - printf " --inline Treat each positional argument as a\n" - printf " separate configuration line instead of a\n" - printf " file name.\n" - printf " -h, --help Print a short help text and exit.\n" - printf " --version Print a short version string and exit.\n" + printf '%s\n' \ + '@BINNAME@' '' \ + '@BINNAME@ creates system users and groups, based on the file' \ + 'format and location specified in sysusers.d(5).' '' \ + 'Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]' '' \ + 'Options:' \ + ' --root=root All paths will be prefixed with the' \ + ' given alternate root path, including' \ + ' config search paths.' \ + " --replace=PATH Don't run check in the package" \ + ' --inline Treat each positional argument as a' \ + ' separate configuration line instead of a' \ + ' file name.' \ + ' -h, --help Print a short help text and exit.' \ + ' --version Print a short version string and exit.' + exit "$1" } -TEMP=$(getopt -o "h" -l "root:,replace:,inline,help,version" -n "@BINNAME@" -- "$@") -if [ $? -ne 0 ]; then - usage - exit 1; -fi - -arguments=() replace='' -version=0 inline=0 -error=0 root='' replace='' -eval set -- "${TEMP}" -unset TEMP -while true; do - case "${1}" in - -h|--help) - usage - exit 0; - shift; - ;; +while :; do + case "$1" in + -h|--help) usage 0 ;; + --root=*) root="${1#--root=}" ;; --root) - root="${2}" - shift 2; + root="$2" + shift ;; + --replace=*) replace="${1#--replace=}" ;; --replace) - replace="${2}" - shift 2; - ;; - --inline) - inline=1 - shift; + replace="$2" + shift ;; + --inline) inline=1 ;; --version) - version=1 - shift; + printf '%s\n' "${sysusersver}" + exit 0 ;; - --) shift; args=("${@}"); break;; - *) break;; + --) shift; break ;; + -*) usage 1 ;; + *) break ;; esac + shift done -source @LIBDIR@/opensysusers/common.sh - -if [ ${version} -eq 1 ]; then - echo "${sysusersver}" - exit ${error}; -fi +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh -if [ ${#args[@]} -eq 0 ]; then +if [ "$#" -eq 0 ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + IFS="${_IFS}" + parse_file "${file}" done - exit ${error}; + exit "${error}" fi -if [ ${inline} -eq 0 ]; then - for file in "${args[@]}"; do - [ ${file} == '--' ] && continue +if [ "${inline}" -eq 0 ]; then + for file in "$@"; do + [ "${file}" = '--' ] && continue + IFS=':' for dir in ${sysusers_dirs}; do if [ -f "${dir}/${file}" ]; then parse_file "${dir}/${file}" break fi done + IFS="${_IFS}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" else - for string in "${args[@]}"; do + for string in "$@"; do parse_string "${string}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" fi -exit ${error}; +exit "${error}" diff --git a/lib/common.sh b/lib/common.sh index 0e84054..0522ac9 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Copyright (c) 2012 Gentoo Foundation # Released under the 2-clause BSD license. @@ -6,142 +6,121 @@ # Common functions and variables needed by opensysusers die() { - echo ${@} 1>&2; - exit 1; + printf '%s\n' "$*" >&2 + exit 1 } warninvalid() { - local msg=$1 - [ -z "${msg}" ] && msg='ignoring invalid entry' - printf "sysusers: ${msg} on line %d of \`%s'\n" "${line}" "${file}" - error=$(( error+1 )) + [ -z "$1" ] && set -- 'ignoring invalid entry' + printf "sysusers: %s on line %d of \`%s'\n" "$1" "${line}" "${file}" + : "$((error += 1))" } >&2 in_array() { - local element - for element in "${@:2}"; do - [[ "${element}" == "${1}" ]] && return 0; + needle="$1" + shift + for element in "$@"; do + [ "${element}" = "${needle}" ] && return 0 done return 1 } add_group() { - local name=${1} id=${2} - getent group "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - groupadd -r "${name}" - else - if ! grep -qiw "${id}" /etc/group; then - groupadd -g "${id}" "${name}" - fi + # add_group + if ! getent group "$1" >/dev/null; then + if [ "$2" = '-' ]; then + groupadd -r "$1" + elif ! grep -qiw "$2" /etc/group; then + groupadd -g "$2" "$1" fi fi } add_user() { - local name=${1} id=${2} gecos=${3} home=${4} - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - useradd -rc "${gecos}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + # add_user + if getent passwd "$1" >/dev/null; then + if [ "$2" = '-' ]; then + useradd -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1" else - useradd -rc "${gecos}" -u "${id}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + useradd -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1" fi - passwd -l "${name}" &>/dev/null + passwd -l "$1" >/dev/null 2>&1 fi } update_login_defs() { - local name=${1} id=${2} - [ ! "${name}" == '-' ] && warninvalid && return - i=1; - IFS='-' read -ra temp <<< "${id}" - for part in "${temp[@]}"; do - if [ "${i}" -eq 1 ]; then - min=${part} - fi - if [ "${i}" -eq 2 ]; then - max=${part} - fi - if [ "${i}" -eq 3 ]; then - warninvalid && continue - fi - i=$(( i+1 )) + # update_login_defs + [ "$1" != '-' ] && warninvalid && return + i=0 + IFS='-' + for part in $2; do + case "$((i += 1))" in + 1) min="${part}" ;; + 2) max="${part}" ;; + 3) warninvalid && return ;; + esac done - [ ${min} -ge ${max} ] && warninvalid "invalid range" && return + IFS="${_IFS}" + [ "${min}" -ge "${max}" ] && warninvalid "invalid range" && return while read -r NAME VALUE; do - [ "${NAME}" == 'SYS_UID_MAX' ] && suid_max=${VALUE} - [ "${NAME}" == 'SYS_GID_MAX' ] && sgid_max=${VALUE} + case "${NAME}" in + SYS_UID_MAX) suid_max="${VALUE}" ;; + SYS_GID_MAX) sgid_max="${VALUE}" ;; + esac done < /etc/login.defs - [[ $min -lt $suid_max ]] && warninvalid "invalid range" && return - [[ $min -lt $sgid_max ]] && warninvalid "invalid range" && return + [ "${min}" -lt "${suid_max}" ] && warninvalid "invalid range" && return + [ "${min}" -lt "${sgid_max}" ] && warninvalid "invalid range" && return - sed -re "s/^(UID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(UID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs - sed -re "s/^(GID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(GID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs + sed -e "s/^\([GU]ID_MIN\)\([[:space:]]\+\)\(.*\)/\1\2${min}/" \ + -e "s/^\([GU]ID_MAX\)\([[:space:]]\+\)\(.*\)/\1\2${max}/" \ + -i /etc/login.defs } parse_file() { - local file="${1}" - if [ -f ${file} ]; then - while read cline; do - [[ "${cline}" =~ ^#.*$ ]] && continue - parse_string "${cline}" - done < ${file} + if [ -f "$1" ]; then + line=0 + while read -r cline; do + : "$((line += 1))" + case "${cline}" in [!#]*) parse_string "${cline}"; esac + done < "$1" fi } parse_string() { - local line=0 cline="${1}" - [ "${cline:0:1}" == "#" ] && continue - eval "set args ${cline}; shift" + case "$1" in '#'*) return; esac + eval "set -- $1" i=0 - for part in "${@}"; do - if [ $i -eq 0 ]; then - type="${part}" - fi - if [ $i -eq 1 ]; then - name="${part}" - fi - if [ $i -eq 2 ]; then - id="${part}" - fi - if [ $i -eq 3 ]; then - gecos="${part}" - fi - if [ $i -eq 4 ]; then - home="${part}" - fi - i=$(( i+1 )) + for part in "$@"; do + case "${i}" in + 0) type="${part}" ;; + 1) name="${part}" ;; + 2) id="${part}" ;; + 3) gecos="${part}" ;; + 4) home="${part}" ;; + esac + : "$((i += 1))" done - line=$(( line+1 )) + : "$((line += 1))" case "${type}" in u) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; return; esac + [ "${home:--}" = - ] && home='/' add_group "${name}" "${id}" - [ "${id}" == '-' ] && id=$(getent group "${name}" | cut -d: -f3) + [ "${id}" = '-' ] && id="$(getent group "${name}")" id="${id#*:*:}" id="${id%%:*}" add_user "${name}" "${id}" "${gecos}" "${home}" ;; g) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; return; esac + [ "${home:--}" = '-' ] && home='/' add_group "${name}" "${id}" ;; m) add_group "${name}" '-' - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then + if ! getent passwd "${name}" >/dev/null; then useradd -r -g "${id}" -s '/sbin/nologin' "${name}" - passwd -l "${name}" &>/dev/null + passwd -l "${name}" >/dev/null 2>&1 else usermod -a -G "${id}" "${name}" fi @@ -149,7 +128,7 @@ parse_string() { r) update_login_defs "${name}" "${id}" ;; - *) warninvalid; continue;; + *) warninvalid; return ;; esac } @@ -161,31 +140,39 @@ parse_string() { # `/run/sysusers.d/foo.conf' will always be read after `/etc/sysusers.d/bar.conf' get_conf_files() { + IFS=':' for dir in ${sysusers_dirs}; do [ -d "${dir}" ] && for file in "${dir}"/*.conf; do - [ "${replace}" != '' ] && [ "${dir}" == "$(dirname ${replace})" ] && [ "${file##*/}" == "${replace##*/}" ] && continue - [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames}\n${file##*/}" + [ -n "${replace}" ] && + [ "${dir}" = "$(dirname "${replace}")" ] && + [ "${file##*/}" = "${replace##*/}" ] && + continue + [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames} +${file##*/}" done done - FILES="$(printf "${sysusers_basenames}\n" | sort -u )" + FILES="$(printf '%s\n' "${sysusers_basenames}" | sort -u)" } get_conf_paths() { + IFS="${_IFS}" for b in ${FILES}; do - real_f='' + real_f='' IFS=':' for d in ${sysusers_dirs}; do - [ "${replace}" != '' ] && [ "${d}" == "$(dirname ${replace})" ] && [ "${b}" == "${replace##*/}" ] && continue - f=${d}/${b} - [ -f "${f}" ] && real_f="${f}" + [ -n "${replace}" ] && + [ "${d}" = "$(dirname "${replace}")" ] && + [ "${b}" = "${replace##*/}" ] && continue + [ -f "${d}/${b}" ] && real_f="${d}/${b}" done - [ -f "${real_f}" ] && sysusers_d="${sysusers_d} ${real_f}" + [ -f "${real_f}" ] && sysusers_d="${sysusers_d}:${real_f}" done } +_IFS="${IFS}" error=0 FILES='' sysusers_basenames='' sysusers_d='' replace='' -sysusers_dirs="${root}/usr/lib/sysusers.d ${root}/run/sysusers.d ${root}/etc/sysusers.d" +sysusers_dirs="${root:=}/usr/lib/sysusers.d:${root}/run/sysusers.d:${root}/etc/sysusers.d" -- 2.24.1 From e5ten.arch at gmail.com Mon Jan 6 22:29:38 2020 From: e5ten.arch at gmail.com (Ethan Sommer) Date: Mon, 6 Jan 2020 16:29:38 -0500 Subject: [artix-general] [PATCH v4] various shell improvements Message-ID: <20200106212938.3059-1-e5ten.arch@gmail.com> make POSIX sh compatible remove array usage remove local builtin usage remove herestring usage remove string indexing usage use shellcheck directive to specify source file locations use manual shell option processing instead of getopt use : to delimit file names in list instead of space like PATH check command results directly instead of checking $? make sed usage POSIX compatible and more concise use case to check variables against multiple strings instead of a series of ifs replace incorrect usages of continue with return where appropriate remove unused library functions replace getent usage with more portable methods of checking for groups/users Signed-off-by: Ethan Sommer --- bin/opensysusers.in | 11 +-- bin/sysusers.in | 125 +++++++++++++---------------- lib/common.sh | 189 +++++++++++++++++++------------------------- 3 files changed, 143 insertions(+), 182 deletions(-) diff --git a/bin/opensysusers.in b/bin/opensysusers.in index bc7834c..7bb2ce5 100755 --- a/bin/opensysusers.in +++ b/bin/opensysusers.in @@ -4,15 +4,16 @@ # # This is an implementation of sysusers.d spec without systemd command -sysusersver=@VERSION@ - -source @LIBDIR@/opensysusers/common.sh +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh get_conf_files get_conf_paths +IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + IFS="${_IFS}" + parse_file "${file}" done -exit ${error} +exit "${error}" diff --git a/bin/sysusers.in b/bin/sysusers.in index 2d5b7aa..3900d48 100755 --- a/bin/sysusers.in +++ b/bin/sysusers.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Released under the 2-clause BSD license. # @@ -7,118 +7,107 @@ sysusersver=@VERSION@ usage() { - printf "@BINNAME@\n\n" - - printf "@BINNAME@ creates system users and groups, based on the file\n" - printf "format and location specified in sysusers.d(5).\n\n" - - printf "Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]\n\n" - - printf "Options:\n" - printf " --root=root All paths will be prefixed with the\n" - printf " given alternate root path, including\n" - printf " config search paths.\n" - printf " --replace=PATH Don't run check in the package\n" - printf " --inline Treat each positional argument as a\n" - printf " separate configuration line instead of a\n" - printf " file name.\n" - printf " -h, --help Print a short help text and exit.\n" - printf " --version Print a short version string and exit.\n" + printf '%s\n' \ + '@BINNAME@' '' \ + '@BINNAME@ creates system users and groups, based on the file' \ + 'format and location specified in sysusers.d(5).' '' \ + 'Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]' '' \ + 'Options:' \ + ' --root=root All paths will be prefixed with the' \ + ' given alternate root path, including' \ + ' config search paths.' \ + " --replace=PATH Don't run check in the package" \ + ' --inline Treat each positional argument as a' \ + ' separate configuration line instead of a' \ + ' file name.' \ + ' -h, --help Print a short help text and exit.' \ + ' --version Print a short version string and exit.' + exit "$1" } -TEMP=$(getopt -o "h" -l "root:,replace:,inline,help,version" -n "@BINNAME@" -- "$@") -if [ $? -ne 0 ]; then - usage - exit 1; -fi - -arguments=() replace='' -version=0 inline=0 -error=0 root='' replace='' -eval set -- "${TEMP}" -unset TEMP -while true; do - case "${1}" in - -h|--help) - usage - exit 0; - shift; - ;; +while :; do + case "$1" in + -h|--help) usage 0 ;; + --root=*) root="${1#--root=}" ;; --root) - root="${2}" - shift 2; + root="$2" + shift ;; + --replace=*) replace="${1#--replace=}" ;; --replace) - replace="${2}" - shift 2; - ;; - --inline) - inline=1 - shift; + replace="$2" + shift ;; + --inline) inline=1 ;; --version) - version=1 - shift; + printf '%s\n' "${sysusersver}" + exit 0 ;; - --) shift; args=("${@}"); break;; - *) break;; + --) shift; break ;; + -*) usage 1 ;; + *) break ;; esac + shift done -source @LIBDIR@/opensysusers/common.sh - -if [ ${version} -eq 1 ]; then - echo "${sysusersver}" - exit ${error}; -fi +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh -if [ ${#args[@]} -eq 0 ]; then +if [ "$#" -eq 0 ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + IFS="${_IFS}" + parse_file "${file}" done - exit ${error}; + exit "${error}" fi -if [ ${inline} -eq 0 ]; then - for file in "${args[@]}"; do - [ ${file} == '--' ] && continue +if [ "${inline}" -eq 0 ]; then + for file in "$@"; do + [ "${file}" = '--' ] && continue + IFS=':' for dir in ${sysusers_dirs}; do if [ -f "${dir}/${file}" ]; then parse_file "${dir}/${file}" break fi done + IFS="${_IFS}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" else - for string in "${args[@]}"; do + for string in "$@"; do parse_string "${string}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" fi -exit ${error}; +exit "${error}" diff --git a/lib/common.sh b/lib/common.sh index 0e84054..2c33f0c 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,155 +1,118 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Copyright (c) 2012 Gentoo Foundation # Released under the 2-clause BSD license. # # Common functions and variables needed by opensysusers -die() { - echo ${@} 1>&2; - exit 1; -} - warninvalid() { - local msg=$1 - [ -z "${msg}" ] && msg='ignoring invalid entry' - printf "sysusers: ${msg} on line %d of \`%s'\n" "${line}" "${file}" - error=$(( error+1 )) + printf "sysusers: %s on line %d of \`%s'\n" "${1:-ignoring invalid entry}" "${line}" "${file}" + : "$((error += 1))" } >&2 -in_array() { - local element - for element in "${@:2}"; do - [[ "${element}" == "${1}" ]] && return 0; - done - return 1 -} - add_group() { - local name=${1} id=${2} - getent group "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - groupadd -r "${name}" - else - if ! grep -qiw "${id}" /etc/group; then - groupadd -g "${id}" "${name}" - fi + # add_group + if ! grep -q "^$1:" /etc/group; then + if [ "$2" = '-' ]; then + groupadd -r "$1" + elif ! grep -q "^[^:]*:[^:]*:$2:[^:]*$" /etc/group; then + groupadd -g "$2" "$1" fi fi } add_user() { - local name=${1} id=${2} gecos=${3} home=${4} - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - useradd -rc "${gecos}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + # add_user + if id "$1" >/dev/null 2>&1; then + if [ "$2" = '-' ]; then + useradd -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1" else - useradd -rc "${gecos}" -u "${id}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + useradd -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1" fi - passwd -l "${name}" &>/dev/null + passwd -l "$1" >/dev/null 2>&1 fi } update_login_defs() { - local name=${1} id=${2} - [ ! "${name}" == '-' ] && warninvalid && return - i=1; - IFS='-' read -ra temp <<< "${id}" - for part in "${temp[@]}"; do - if [ "${i}" -eq 1 ]; then - min=${part} - fi - if [ "${i}" -eq 2 ]; then - max=${part} - fi - if [ "${i}" -eq 3 ]; then - warninvalid && continue - fi - i=$(( i+1 )) + # update_login_defs + [ "$1" != '-' ] && warninvalid && return + i=0 + IFS='-' + for part in $2; do + case "$((i += 1))" in + 1) min="${part}" ;; + 2) max="${part}" ;; + 3) warninvalid && return ;; + esac done - [ ${min} -ge ${max} ] && warninvalid "invalid range" && return + IFS="${_IFS}" + [ "${min}" -ge "${max}" ] && warninvalid "invalid range" && return while read -r NAME VALUE; do - [ "${NAME}" == 'SYS_UID_MAX' ] && suid_max=${VALUE} - [ "${NAME}" == 'SYS_GID_MAX' ] && sgid_max=${VALUE} + case "${NAME}" in + SYS_UID_MAX) suid_max="${VALUE}" ;; + SYS_GID_MAX) sgid_max="${VALUE}" ;; + esac done < /etc/login.defs - [[ $min -lt $suid_max ]] && warninvalid "invalid range" && return - [[ $min -lt $sgid_max ]] && warninvalid "invalid range" && return + [ "${min}" -lt "${suid_max}" ] && warninvalid "invalid range" && return + [ "${min}" -lt "${sgid_max}" ] && warninvalid "invalid range" && return - sed -re "s/^(UID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(UID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs - sed -re "s/^(GID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(GID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs + sed -e "s/^\([GU]ID_MIN\)\([[:space:]]\+\)\(.*\)/\1\2${min}/" \ + -e "s/^\([GU]ID_MAX\)\([[:space:]]\+\)\(.*\)/\1\2${max}/" \ + -i /etc/login.defs } parse_file() { - local file="${1}" - if [ -f ${file} ]; then - while read cline; do - [[ "${cline}" =~ ^#.*$ ]] && continue - parse_string "${cline}" - done < ${file} + if [ -f "$1" ]; then + line=0 + while read -r cline; do + : "$((line += 1))" + case "${cline}" in [!#]*) parse_string "${cline}"; esac + done < "$1" fi } parse_string() { - local line=0 cline="${1}" - [ "${cline:0:1}" == "#" ] && continue - eval "set args ${cline}; shift" + case "$1" in '#'*) return; esac + eval "set -- $1" i=0 - for part in "${@}"; do - if [ $i -eq 0 ]; then - type="${part}" - fi - if [ $i -eq 1 ]; then - name="${part}" - fi - if [ $i -eq 2 ]; then - id="${part}" - fi - if [ $i -eq 3 ]; then - gecos="${part}" - fi - if [ $i -eq 4 ]; then - home="${part}" - fi - i=$(( i+1 )) + for part in "$@"; do + case "$((i += 1))" in + 1) type="${part}" ;; + 2) name="${part}" ;; + 3) id="${part}" ;; + 4) gecos="${part}" ;; + 5) home="${part}" ;; + esac done - line=$(( line+1 )) + : "$((line += 1))" case "${type}" in u) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; return; esac + case "${home#-}" in '') home='/'; esac add_group "${name}" "${id}" - [ "${id}" == '-' ] && id=$(getent group "${name}" | cut -d: -f3) + [ "${id}" = '-' ] && id="$(id -g "${name}")" add_user "${name}" "${id}" "${gecos}" "${home}" ;; g) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; return; esac + [ "${home:--}" = '-' ] && home='/' add_group "${name}" "${id}" ;; m) add_group "${name}" '-' - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - useradd -r -g "${id}" -s '/sbin/nologin' "${name}" - passwd -l "${name}" &>/dev/null - else + if id "${name}" >/dev/null 2>&1; then usermod -a -G "${id}" "${name}" + else + useradd -r -g "${id}" -s '/sbin/nologin' "${name}" + passwd -l "${name}" >/dev/null 2>&1 fi ;; r) update_login_defs "${name}" "${id}" ;; - *) warninvalid; continue;; + *) warninvalid; return ;; esac } @@ -161,31 +124,39 @@ parse_string() { # `/run/sysusers.d/foo.conf' will always be read after `/etc/sysusers.d/bar.conf' get_conf_files() { + IFS=':' for dir in ${sysusers_dirs}; do [ -d "${dir}" ] && for file in "${dir}"/*.conf; do - [ "${replace}" != '' ] && [ "${dir}" == "$(dirname ${replace})" ] && [ "${file##*/}" == "${replace##*/}" ] && continue - [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames}\n${file##*/}" + [ -n "${replace}" ] && + [ "${dir}" = "$(dirname "${replace}")" ] && + [ "${file##*/}" = "${replace##*/}" ] && + continue + [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames} +${file##*/}" done done - FILES="$(printf "${sysusers_basenames}\n" | sort -u )" + FILES="$(printf '%s\n' "${sysusers_basenames}" | sort -u)" } get_conf_paths() { + IFS="${_IFS}" for b in ${FILES}; do - real_f='' + real_f='' IFS=':' for d in ${sysusers_dirs}; do - [ "${replace}" != '' ] && [ "${d}" == "$(dirname ${replace})" ] && [ "${b}" == "${replace##*/}" ] && continue - f=${d}/${b} - [ -f "${f}" ] && real_f="${f}" + [ -n "${replace}" ] && + [ "${d}" = "$(dirname "${replace}")" ] && + [ "${b}" = "${replace##*/}" ] && continue + [ -f "${d}/${b}" ] && real_f="${d}/${b}" done - [ -f "${real_f}" ] && sysusers_d="${sysusers_d} ${real_f}" + [ -f "${real_f}" ] && sysusers_d="${sysusers_d}:${real_f}" done } +_IFS="${IFS}" error=0 FILES='' sysusers_basenames='' sysusers_d='' replace='' -sysusers_dirs="${root}/usr/lib/sysusers.d ${root}/run/sysusers.d ${root}/etc/sysusers.d" +sysusers_dirs="${root:=}/usr/lib/sysusers.d:${root}/run/sysusers.d:${root}/etc/sysusers.d" -- 2.24.1 From nous at artixlinux.org Mon Jan 6 22:57:26 2020 From: nous at artixlinux.org (Christos Nouskas) Date: Mon, 6 Jan 2020 23:57:26 +0200 Subject: [artix-general] X is now very sluggish In-Reply-To: <20200104091452.GA6624@www2.mrbrklyn.com> References: <20200104025903.GA4936@www2.mrbrklyn.com> <20200104091452.GA6624@www2.mrbrklyn.com> Message-ID: <20200106235726.77b36a2f@hyperion.xyzzy.xyz> On Sat, 4 Jan 2020 04:14:52 -0500 Ruben Safir via artix-general wrote: > > whatever they changed with X in this last upgrade, they have dragging > the response from the server to a trickle. The video playback has been > aweful, as has been mouse response, etc. My workstation suddenly > feels very underpowered. > > I know there is not much artix developers can do about this, but it is > what it is. If you're certain it's the X server, you can try the downgrade tool. Also check the kernel. -- https://systemd-free.artixlinux.org From e5ten.arch at gmail.com Tue Jan 7 16:08:37 2020 From: e5ten.arch at gmail.com (Ethan Sommer) Date: Tue, 7 Jan 2020 10:08:37 -0500 Subject: [artix-general] [PATCH v5] various shell improvements Message-ID: <20200107150837.10437-1-e5ten.arch@gmail.com> make POSIX sh compatible remove array usage remove local builtin usage remove herestring usage remove string indexing usage use shellcheck directive to specify source file locations use manual shell option processing instead of getopt use : to delimit file names in list instead of space like PATH check command results directly instead of checking $? make sed usage POSIX compatible and more concise use case to check variables against multiple strings instead of a series of ifs replace incorrect usages of continue with return where appropriate remove unused library functions replace getent usage with more portable methods of checking for groups/users Signed-off-by: Ethan Sommer --- bin/opensysusers.in | 11 +-- bin/sysusers.in | 125 +++++++++++++---------------- lib/common.sh | 189 +++++++++++++++++++------------------------- 3 files changed, 143 insertions(+), 182 deletions(-) diff --git a/bin/opensysusers.in b/bin/opensysusers.in index bc7834c..7bb2ce5 100755 --- a/bin/opensysusers.in +++ b/bin/opensysusers.in @@ -4,15 +4,16 @@ # # This is an implementation of sysusers.d spec without systemd command -sysusersver=@VERSION@ - -source @LIBDIR@/opensysusers/common.sh +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh get_conf_files get_conf_paths +IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + IFS="${_IFS}" + parse_file "${file}" done -exit ${error} +exit "${error}" diff --git a/bin/sysusers.in b/bin/sysusers.in index 2d5b7aa..3900d48 100755 --- a/bin/sysusers.in +++ b/bin/sysusers.in @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Released under the 2-clause BSD license. # @@ -7,118 +7,107 @@ sysusersver=@VERSION@ usage() { - printf "@BINNAME@\n\n" - - printf "@BINNAME@ creates system users and groups, based on the file\n" - printf "format and location specified in sysusers.d(5).\n\n" - - printf "Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]\n\n" - - printf "Options:\n" - printf " --root=root All paths will be prefixed with the\n" - printf " given alternate root path, including\n" - printf " config search paths.\n" - printf " --replace=PATH Don't run check in the package\n" - printf " --inline Treat each positional argument as a\n" - printf " separate configuration line instead of a\n" - printf " file name.\n" - printf " -h, --help Print a short help text and exit.\n" - printf " --version Print a short version string and exit.\n" + printf '%s\n' \ + '@BINNAME@' '' \ + '@BINNAME@ creates system users and groups, based on the file' \ + 'format and location specified in sysusers.d(5).' '' \ + 'Usage: /usr/bin/@BINNAME@ [OPTIONS...] [CONFIGFILE...]' '' \ + 'Options:' \ + ' --root=root All paths will be prefixed with the' \ + ' given alternate root path, including' \ + ' config search paths.' \ + " --replace=PATH Don't run check in the package" \ + ' --inline Treat each positional argument as a' \ + ' separate configuration line instead of a' \ + ' file name.' \ + ' -h, --help Print a short help text and exit.' \ + ' --version Print a short version string and exit.' + exit "$1" } -TEMP=$(getopt -o "h" -l "root:,replace:,inline,help,version" -n "@BINNAME@" -- "$@") -if [ $? -ne 0 ]; then - usage - exit 1; -fi - -arguments=() replace='' -version=0 inline=0 -error=0 root='' replace='' -eval set -- "${TEMP}" -unset TEMP -while true; do - case "${1}" in - -h|--help) - usage - exit 0; - shift; - ;; +while :; do + case "$1" in + -h|--help) usage 0 ;; + --root=*) root="${1#--root=}" ;; --root) - root="${2}" - shift 2; + root="$2" + shift ;; + --replace=*) replace="${1#--replace=}" ;; --replace) - replace="${2}" - shift 2; - ;; - --inline) - inline=1 - shift; + replace="$2" + shift ;; + --inline) inline=1 ;; --version) - version=1 - shift; + printf '%s\n' "${sysusersver}" + exit 0 ;; - --) shift; args=("${@}"); break;; - *) break;; + --) shift; break ;; + -*) usage 1 ;; + *) break ;; esac + shift done -source @LIBDIR@/opensysusers/common.sh - -if [ ${version} -eq 1 ]; then - echo "${sysusersver}" - exit ${error}; -fi +# shellcheck source=lib/common.sh +. @LIBDIR@/opensysusers/common.sh -if [ ${#args[@]} -eq 0 ]; then +if [ "$#" -eq 0 ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + IFS="${_IFS}" + parse_file "${file}" done - exit ${error}; + exit "${error}" fi -if [ ${inline} -eq 0 ]; then - for file in "${args[@]}"; do - [ ${file} == '--' ] && continue +if [ "${inline}" -eq 0 ]; then + for file in "$@"; do + [ "${file}" = '--' ] && continue + IFS=':' for dir in ${sysusers_dirs}; do if [ -f "${dir}/${file}" ]; then parse_file "${dir}/${file}" break fi done + IFS="${_IFS}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" else - for string in "${args[@]}"; do + for string in "$@"; do parse_string "${string}" done - if [ "${replace}" != '' ]; then + if [ -n "${replace}" ]; then get_conf_files get_conf_paths + IFS=':' for file in ${sysusers_d}; do - parse_file ${file} + parse_file "${file}" done + IFS="${_IFS}" fi - exit ${error}; + exit "${error}" fi -exit ${error}; +exit "${error}" diff --git a/lib/common.sh b/lib/common.sh index 0e84054..2b263f8 100755 --- a/lib/common.sh +++ b/lib/common.sh @@ -1,155 +1,118 @@ -#!/bin/bash +#!/bin/sh # Copyright (c) 2018 Chris Cromer # Copyright (c) 2012 Gentoo Foundation # Released under the 2-clause BSD license. # # Common functions and variables needed by opensysusers -die() { - echo ${@} 1>&2; - exit 1; -} - warninvalid() { - local msg=$1 - [ -z "${msg}" ] && msg='ignoring invalid entry' - printf "sysusers: ${msg} on line %d of \`%s'\n" "${line}" "${file}" - error=$(( error+1 )) + printf "sysusers: %s on line %d of \`%s'\n" "${1:-ignoring invalid entry}" "${line}" "${file}" + : "$((error += 1))" } >&2 -in_array() { - local element - for element in "${@:2}"; do - [[ "${element}" == "${1}" ]] && return 0; - done - return 1 -} - add_group() { - local name=${1} id=${2} - getent group "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - groupadd -r "${name}" - else - if ! grep -qiw "${id}" /etc/group; then - groupadd -g "${id}" "${name}" - fi + # add_group + if ! grep -q "^$1:" /etc/group; then + if [ "$2" = '-' ]; then + groupadd -r "$1" + elif ! grep -q "^[^:]*:[^:]*:$2:[^:]*$" /etc/group; then + groupadd -g "$2" "$1" fi fi } add_user() { - local name=${1} id=${2} gecos=${3} home=${4} - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - if [ "${id}" == '-' ]; then - useradd -rc "${gecos}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + # add_user + if ! id "$1" >/dev/null 2>&1; then + if [ "$2" = '-' ]; then + useradd -rc "$3" -g "$1" -d "$4" -s '/sbin/nologin' "$1" else - useradd -rc "${gecos}" -u "${id}" -g "${name}" -d "${home}" -s '/sbin/nologin' "${name}" + useradd -rc "$3" -u "$2" -g "$1" -d "$4" -s '/sbin/nologin' "$1" fi - passwd -l "${name}" &>/dev/null + passwd -l "$1" >/dev/null 2>&1 fi } update_login_defs() { - local name=${1} id=${2} - [ ! "${name}" == '-' ] && warninvalid && return - i=1; - IFS='-' read -ra temp <<< "${id}" - for part in "${temp[@]}"; do - if [ "${i}" -eq 1 ]; then - min=${part} - fi - if [ "${i}" -eq 2 ]; then - max=${part} - fi - if [ "${i}" -eq 3 ]; then - warninvalid && continue - fi - i=$(( i+1 )) + # update_login_defs + [ "$1" != '-' ] && warninvalid && return + i=0 + IFS='-' + for part in $2; do + case "$((i += 1))" in + 1) min="${part}" ;; + 2) max="${part}" ;; + 3) warninvalid && return ;; + esac done - [ ${min} -ge ${max} ] && warninvalid "invalid range" && return + IFS="${_IFS}" + [ "${min}" -ge "${max}" ] && warninvalid "invalid range" && return while read -r NAME VALUE; do - [ "${NAME}" == 'SYS_UID_MAX' ] && suid_max=${VALUE} - [ "${NAME}" == 'SYS_GID_MAX' ] && sgid_max=${VALUE} + case "${NAME}" in + SYS_UID_MAX) suid_max="${VALUE}" ;; + SYS_GID_MAX) sgid_max="${VALUE}" ;; + esac done < /etc/login.defs - [[ $min -lt $suid_max ]] && warninvalid "invalid range" && return - [[ $min -lt $sgid_max ]] && warninvalid "invalid range" && return + [ "${min}" -lt "${suid_max}" ] && warninvalid "invalid range" && return + [ "${min}" -lt "${sgid_max}" ] && warninvalid "invalid range" && return - sed -re "s/^(UID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(UID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs - sed -re "s/^(GID_MIN)([[:space:]]+)(.*)/\1\2${min}/" -i /etc/login.defs - sed -re "s/^(GID_MAX)([[:space:]]+)(.*)/\1\2${max}/" -i /etc/login.defs + sed -e "s/^\([GU]ID_MIN\)\([[:space:]]\+\)\(.*\)/\1\2${min}/" \ + -e "s/^\([GU]ID_MAX\)\([[:space:]]\+\)\(.*\)/\1\2${max}/" \ + -i /etc/login.defs } parse_file() { - local file="${1}" - if [ -f ${file} ]; then - while read cline; do - [[ "${cline}" =~ ^#.*$ ]] && continue - parse_string "${cline}" - done < ${file} + if [ -f "$1" ]; then + line=0 + while read -r cline; do + : "$((line += 1))" + case "${cline}" in [!#]*) parse_string "${cline}"; esac + done < "$1" fi } parse_string() { - local line=0 cline="${1}" - [ "${cline:0:1}" == "#" ] && continue - eval "set args ${cline}; shift" + case "$1" in '#'*) return; esac + eval "set -- $1" i=0 - for part in "${@}"; do - if [ $i -eq 0 ]; then - type="${part}" - fi - if [ $i -eq 1 ]; then - name="${part}" - fi - if [ $i -eq 2 ]; then - id="${part}" - fi - if [ $i -eq 3 ]; then - gecos="${part}" - fi - if [ $i -eq 4 ]; then - home="${part}" - fi - i=$(( i+1 )) + for part in "$@"; do + case "$((i += 1))" in + 1) type="${part}" ;; + 2) name="${part}" ;; + 3) id="${part}" ;; + 4) gecos="${part}" ;; + 5) home="${part}" ;; + esac done - line=$(( line+1 )) + : "$((line += 1))" case "${type}" in u) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; return; esac + case "${home#-}" in '') home='/'; esac add_group "${name}" "${id}" - [ "${id}" == '-' ] && id=$(getent group "${name}" | cut -d: -f3) + [ "${id}" = '-' ] && id="$(id -g "${name}")" add_user "${name}" "${id}" "${gecos}" "${home}" ;; g) - [ "${id}" == '65535' ] && warninvalid && continue - [ "${id}" == '4294967295' ] && warninvalid && continue - [ "${home}" == '-' ] && home="/" - [ -z "${home}" ] && home="/" + case "${id}" in 65535|4294967295) warninvalid; return; esac + [ "${home:--}" = '-' ] && home='/' add_group "${name}" "${id}" ;; m) add_group "${name}" '-' - getent passwd "${name}" >/dev/null - if [ "$?" -ne 0 ]; then - useradd -r -g "${id}" -s '/sbin/nologin' "${name}" - passwd -l "${name}" &>/dev/null - else + if id "${name}" >/dev/null 2>&1; then usermod -a -G "${id}" "${name}" + else + useradd -r -g "${id}" -s '/sbin/nologin' "${name}" + passwd -l "${name}" >/dev/null 2>&1 fi ;; r) update_login_defs "${name}" "${id}" ;; - *) warninvalid; continue;; + *) warninvalid; return ;; esac } @@ -161,31 +124,39 @@ parse_string() { # `/run/sysusers.d/foo.conf' will always be read after `/etc/sysusers.d/bar.conf' get_conf_files() { + IFS=':' for dir in ${sysusers_dirs}; do [ -d "${dir}" ] && for file in "${dir}"/*.conf; do - [ "${replace}" != '' ] && [ "${dir}" == "$(dirname ${replace})" ] && [ "${file##*/}" == "${replace##*/}" ] && continue - [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames}\n${file##*/}" + [ -n "${replace}" ] && + [ "${dir}" = "$(dirname "${replace}")" ] && + [ "${file##*/}" = "${replace##*/}" ] && + continue + [ -f "${file}" ] && sysusers_basenames="${sysusers_basenames} +${file##*/}" done done - FILES="$(printf "${sysusers_basenames}\n" | sort -u )" + FILES="$(printf '%s\n' "${sysusers_basenames}" | sort -u)" } get_conf_paths() { + IFS="${_IFS}" for b in ${FILES}; do - real_f='' + real_f='' IFS=':' for d in ${sysusers_dirs}; do - [ "${replace}" != '' ] && [ "${d}" == "$(dirname ${replace})" ] && [ "${b}" == "${replace##*/}" ] && continue - f=${d}/${b} - [ -f "${f}" ] && real_f="${f}" + [ -n "${replace}" ] && + [ "${d}" = "$(dirname "${replace}")" ] && + [ "${b}" = "${replace##*/}" ] && continue + [ -f "${d}/${b}" ] && real_f="${d}/${b}" done - [ -f "${real_f}" ] && sysusers_d="${sysusers_d} ${real_f}" + [ -f "${real_f}" ] && sysusers_d="${sysusers_d}:${real_f}" done } +_IFS="${IFS}" error=0 FILES='' sysusers_basenames='' sysusers_d='' replace='' -sysusers_dirs="${root}/usr/lib/sysusers.d ${root}/run/sysusers.d ${root}/etc/sysusers.d" +sysusers_dirs="${root:=}/usr/lib/sysusers.d:${root}/run/sysusers.d:${root}/etc/sysusers.d" -- 2.24.1 From sgorava at artixlinux.org Sun Jan 12 18:57:00 2020 From: sgorava at artixlinux.org (Juraj Oravec) Date: Sun, 12 Jan 2020 18:57:00 +0100 Subject: [artix-general] artix archived package In-Reply-To: <72c3fe9e588b49508d16d3d14ba3f3b2@grupawp.pl> References: <72c3fe9e588b49508d16d3d14ba3f3b2@grupawp.pl> Message-ID: <1663132.VLH7GnMWUR@void> Hello, As of now Artix does not have package Archive. There are only latest versions of packages. > galaxy/virtualbox-host-modules-artix 6.1.0-10 If you do NEED exactly this version I recommend to use "virtualbox-host-dkms" package from ArchLinux archives. https://archive.archlinux.org/packages/v/virtualbox-host-dkms/[1] If you do not need this exact version I recommend to update $ pacman -Syu If you see the old version even after you tried to update, please tell us what repository you are using so we can contact the providers and fix the issue. Best regards. On nede?a 12. janu?ra 2020 18:40:00 CET gader at o2.pl wrote: Hi, I'm looking for last month archived package: virtualbox-host-modules-artix-6.0.14-12-x86_64.pkg.tar.xz No luck to find it on any updated repository. Michael. -------- [1] https://archive.archlinux.org/packages/v/virtualbox-host-dkms/ -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: This is a digitally signed message part. URL: From dudemanguy at artixlinux.org Sun Jan 19 20:32:50 2020 From: dudemanguy at artixlinux.org (Dudemanguy) Date: Sun, 19 Jan 2020 13:32:50 -0600 Subject: [artix-general] [s6] The next s6-linux-init requires manual intervention Message-ID: <2618a5c8-4223-9f00-10fb-7acca78da925@artixlinux.org> For s6 users, updating to s6-linux-init-1.0.3.1-5 will hit some file conflicts and require manual intervention. This will first be required for [gremlins] and then [system] later. If you want to save any changes made to s6-linux-init scripts first, # cp -r /etc/s6/current/scripts /tmp Then remove the current directory and reinstall s6-linux-init # rm -rf /etc/s6/current # pacman -Syu s6-linux-init If you backed up your s6-linux-init scripts, you can move them back. # cp -r /tmp/scripts /etc/s6/current Now, it is safe to boot and shutdown the system again. From je-vv at e.email Tue Jan 28 18:56:42 2020 From: je-vv at e.email (Javier) Date: Tue, 28 Jan 2020 11:56:42 -0600 Subject: [artix-general] Using keybase without systemd Message-ID: <9544eb3e-681d-3721-48ac-227cb03552b2@e.email> Hello, I found keybase being pretty tight to systemd, even though it's to start on user login, which doesn't make much sense to me, but that's the way it is... I'm wondering if any of you guys are using it on artix, and how. I would guess you include in ~/.bash_profile or ~/.profile a call for keybase, like: keybase ctl start | kebase service fusermount -uz "$(keybase config get -d -b mountdir)" kbfsfuse -debug -log-to-file KEYBASE_AUTOSTART=1 electron /usr/share/keybase-app (this on a WM or DE) Is that right? Thanks ! -- Javier -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: OpenPGP digital signature URL: From dudemanguy at artixlinux.org Tue Jan 28 21:06:57 2020 From: dudemanguy at artixlinux.org (Dudemanguy) Date: Tue, 28 Jan 2020 14:06:57 -0600 Subject: [artix-general] Using keybase without systemd In-Reply-To: <9544eb3e-681d-3721-48ac-227cb03552b2@e.email> References: <9544eb3e-681d-3721-48ac-227cb03552b2@e.email> Message-ID: <99899995-2268-e950-da04-7fda8485131f@artixlinux.org> On 1/28/20 11:56 AM, Javier via artix-general wrote: > Hello, > > I found keybase being pretty tight to systemd, even though it's to start on user login, which doesn't make much sense to me, but that's the way it is... I'm wondering if any of you guys are using it on artix, and how. I would guess you include in ~/.bash_profile or ~/.profile a call for keybase, like: > > keybase ctl start | kebase service > fusermount -uz "$(keybase config get -d -b mountdir)" > kbfsfuse -debug -log-to-file > KEYBASE_AUTOSTART=1 electron /usr/share/keybase-app (this on a WM or DE) > > Is that right? > > Thanks ! > I only looked at the program briefly, but it looks like it's a daemon to me and there's not any particular systemd dependencies or anything. On arch, it looks like it just comes with a systemd service file. For Artix, the proper way to do it would be to add it a service script (AKA an additional *-openrc/*-runit/*-s6 package). You could workaround it by just running it manually though. From je-vv at e.email Tue Jan 28 21:16:53 2020 From: je-vv at e.email (Javier) Date: Tue, 28 Jan 2020 14:16:53 -0600 Subject: [artix-general] Using keybase without systemd In-Reply-To: <99899995-2268-e950-da04-7fda8485131f@artixlinux.org> References: <9544eb3e-681d-3721-48ac-227cb03552b2@e.email> <99899995-2268-e950-da04-7fda8485131f@artixlinux.org> Message-ID: > On 1/28/20 11:56 AM, Javier via artix-general wrote: >> ... >> keybase ctl start | kebase service >> fusermount -uz "$(keybase config get -d -b mountdir)" >> kbfsfuse -debug -log-to-file >> KEYBASE_AUTOSTART=1 electron /usr/share/keybase-app (this on a WM or DE) >> ... On 1/28/20 2:06 PM, Dudemanguy via artix-general wrote: > I only looked at the program briefly, but it looks like it's a daemon to me and there's not any particular systemd dependencies or anything. On arch, it looks like it just comes with a systemd service file. For Artix, the proper way to do it would be to add it a service script (AKA an additional *-openrc/*-runit/*-s6 package). You could workaround it by just running it manually though. I was thinking manually, but calling the non gui stuff on bash_profile, if not already running, and then create a custom *.desktop for the gui with contents including commands like the ones I included. No need for a daemon, and besides, I want to have env vars like proxy available, and if in need configure keybase based on those env vars (daemons most probably won't catch what I set on env vars)... I was hoping someone might already be using keybase like that already, :) Greetings ! -- Javier -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: OpenPGP digital signature URL: From je-vv at e.email Wed Jan 29 18:35:40 2020 From: je-vv at e.email (Javier) Date: Wed, 29 Jan 2020 11:35:40 -0600 Subject: [artix-general] Using keybase without systemd In-Reply-To: References: <9544eb3e-681d-3721-48ac-227cb03552b2@e.email> <99899995-2268-e950-da04-7fda8485131f@artixlinux.org> Message-ID: <79ec11c4-f9bd-7184-3a7c-836f76dfbc2e@e.email> >> On 1/28/20 11:56 AM, Javier via artix-general wrote: >>> ... >>> keybase ctl start | kebase service >>> fusermount -uz "$(keybase config get -d -b mountdir)" >>> kbfsfuse -debug -log-to-file >>> KEYBASE_AUTOSTART=1 electron /usr/share/keybase-app (this on a WM or DE) >>> ... > > On 1/28/20 2:06 PM, Dudemanguy via artix-general wrote: >> I only looked at the program briefly, but it looks like it's a daemon to me and there's not any particular systemd dependencies or anything. On arch, it looks like it just comes with a systemd service file. For Artix, the proper way to do it would be to add it a service script (AKA an additional *-openrc/*-runit/*-s6 package). You could workaround it by just running it manually though. On 1/28/20 2:16 PM, Javier via artix-general wrote: > I was thinking manually, but calling the non gui stuff on bash_profile, if not already running, and then create a custom *.desktop for the gui with contents including commands like the ones I included. No need for a daemon, and besides, I want to have env vars like proxy available, and if in need configure keybase based on those env vars (daemons most probably won't catch what I set on env vars)... I was hoping someone might already be using keybase like that already, :) BTW, I has to be keybase service, since keybase ctl start triggers systemd stuff... -- Javier -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 228 bytes Desc: OpenPGP digital signature URL: