[Rpm-maint] [rpm-software-management/rpm] Add sysusers.sh script to replace systemd-sysusers (PR #2573)

Zbigniew Jędrzejewski-Szmek notifications at github.com
Tue Jul 25 09:54:38 UTC 2023


@keszybz commented on this pull request.



> +	if [ "-" = "$fn" ]; then
+	   parse <&0
+	else
+		[ -r "$fn" ] || continue
+		parse <"$fn"

Indentation is strange, also in other places.

> +[ -e "$ROOT"/etc/passwd ] || touch "$ROOT"/etc/passwd
+[ -e "$ROOT"/etc/shadow ] || touch "$ROOT"/etc/shadow
+[ -e "$ROOT"/etc/group ] || touch "$ROOT"/etc/group

Why? Shouldn't things work even if those files are missing?


> @@ -0,0 +1,150 @@
+#!/bin/sh

Shellcheck says:

In sysusers.sh line 57:
		hasuser "$user" || \\
                                   ^-- SC2288 (warning): This is interpreted as a command name ending with '\'. Double check syntax.


In sysusers.sh line 92:
		{ [ "${line:0:1}" = '#' ] || [ "${line:0:1}" = ';' ]; } && continue
                     ^---------^ SC3057 (warning): In POSIX sh, string indexing is undefined.
                                                ^---------^ SC3057 (warning): In POSIX sh, string indexing is undefined.


In sysusers.sh line 96:
		case "${arr[0]}" in
                      ^-------^ SC2154 (warning): arr is referenced but not assigned.
                      ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 98:
				if [[ "${arr[2]}" == *":"* ]]; then
                                   ^------------------------^ SC3010 (warning): In POSIX sh, [[ ]] is undefined.
                                       ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 99:
					user "${arr[1]}" "${arr[2]%:*}" "${arr[3]}" "${arr[2]#*:}" "${arr[4]}" "${arr[5]}"
                                              ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                         ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                                                    ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                                                                ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 101:
					group "${arr[1]}" "${arr[2]}"
                                               ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                           ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 102:
					user "${arr[1]}" "${arr[2]}" "${arr[3]}" "${arr[1]}" "${arr[4]}" "${arr[5]}"
                                              ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                          ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                      ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                                  ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                                              ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                                                                          ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 106:
				group "${arr[1]}" "${arr[2]}"
                                       ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                   ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 109:
				group "${arr[2]}" "-"
                                       ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 110:
				user "${arr[1]}" "-" "" "${arr[1]}" "" ""
                                      ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                         ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 111:
				usermod "${arr[1]}" "${arr[2]}"
                                         ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.
                                                     ^-------^ SC3054 (warning): In POSIX sh, array references are undefined.


In sysusers.sh line 127:
	REPLACEDIR=`dirname "$REPLACE"`
                   ^------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
	REPLACEDIR=$(dirname "$REPLACE")


In sysusers.sh line 128:
	REPLACENAME=`basename "$REPLACE"`
                    ^-------------------^ SC2006 (style): Use $(...) notation instead of legacy backticks `...`.

Did you mean: 
	REPLACENAME=$(basename "$REPLACE")


In sysusers.sh line 129:
	if [[ "$REPLACEDIR" == "${SYSTEMDIR}" ]] ; then
           ^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.


In sysusers.sh line 138:
	if [[ "$REPLACEDIR" == "$RUNTIMEDIR" ]] ; then
           ^-- SC3010 (warning): In POSIX sh, [[ ]] is undefined.

For more information:
  https://www.shellcheck.net/wiki/SC2154 -- arr is referenced but not assigned.
  https://www.shellcheck.net/wiki/SC2288 -- This is interpreted as a command ...
  https://www.shellcheck.net/wiki/SC3010 -- In POSIX sh, [[ ]] is undefined.


> @@ -0,0 +1,150 @@
+#!/bin/sh

It's generally good practice to have (new) shell code shellcheck-clean.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/2573#pullrequestreview-1545070763
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/2573/review/1545070763 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20230725/338eb58c/attachment-0001.html>


More information about the Rpm-maint mailing list