From: Yann E. MORIN <yann.morin.1998@free.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] mkusers: make it work with mksh
Date: Tue, 5 Jul 2016 10:28:34 +0200 [thread overview]
Message-ID: <20160705082834.GG6533@free.fr> (raw)
In-Reply-To: <20160530063747.GD31737@airbook.vandijck-laurijssen.be>
Kurt, All,
On 2016-05-30 08:37 +0200, Kurt Van Dijck spake thusly:
> I use mksh as my /bin/sh.
mkuser does not use /bin/sh, it explicitly uses bash. See the first line
of that script:
#!/usr/bin/env bash
> I found that mkusers does not work.
> This patch alters the script so that it works with mksh also.
>
> Signed-off-by: Kurt Van Dijck <dev.kurt@vandijck-laurijssen.be>
> ---
> support/scripts/mkusers | 43 +++++++++++++++++++++++++++----------------
> 1 file changed, 27 insertions(+), 16 deletions(-)
>
> diff --git a/support/scripts/mkusers b/support/scripts/mkusers
> index e2c24c7..68fda99 100755
> --- a/support/scripts/mkusers
> +++ b/support/scripts/mkusers
> @@ -370,9 +370,9 @@ main() {
> fi
>
> # Read in all the file in memory, exclude empty lines and comments
> - while read line; do
> - LINES+=( "${line}" )
> - done < <( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" )
> + #while read line; do
> + # LINES+=( "${line}" )
> + #done < < ( sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" )
>
> # We first create groups whose gid is not -1, and then we create groups
> # whose gid is -1 (automatic), so that, if a group is defined both with
> @@ -380,24 +380,30 @@ main() {
> # used, rather than a different automatic gid is computed.
>
> # First, create all the main groups which gid is *not* automatic
> - for line in "${LINES[@]}"; do
> - read username uid group gid passwd home shell groups comment <<<"${line}"
> - [ ${gid} -ge 0 ] || continue # Automatic gid
> + sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" | while
> + read username uid group gid passwd home shell groups comment; do
> + #for line in "${LINES[@]}"; do
> + #read username uid group gid passwd home shell groups comment <<<"${line}"
> + [ "${gid}" -ge 0 ] || continue # Automatic gid
> add_one_group "${group}" "${gid}"
This does not work in case of error: the add_one_group function will
call "exit 1" in case of error, causing the shell to exit, but since you
are now using a pipe command, the script itself will not exit.
This is wrong.
But anyway, because the script is explcitly calling to bash, I'd like to
understand why it would fail with mksh, since mksh is not used at all...
Regards,
Yann E. MORIN.
> done
>
> # Then, create all the main groups which gid *is* automatic
> - for line in "${LINES[@]}"; do
> - read username uid group gid passwd home shell groups comment <<<"${line}"
> - [ ${gid} -eq -1 ] || continue # Non-automatic gid
> + sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" | while
> + read username uid group gid passwd home shell groups comment; do
> + #for line in "${LINES[@]}"; do
> + #read username uid group gid passwd home shell groups comment <<<"${line}"
> + [ "${gid}" -eq -1 ] || continue # Non-automatic gid
> add_one_group "${group}" "${gid}"
> done
>
> # Then, create all the additional groups
> # If any additional group is already a main group, we should use
> # the gid of that main group; otherwise, we can use any gid
> - for line in "${LINES[@]}"; do
> - read username uid group gid passwd home shell groups comment <<<"${line}"
> + sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" | while
> + read username uid group gid passwd home shell groups comment; do
> + #for line in "${LINES[@]}"; do
> + #read username uid group gid passwd home shell groups comment <<<"${line}"
> if [ "${groups}" != "-" ]; then
> for g in ${groups//,/ }; do
> add_one_group "${g}" -1
> @@ -411,17 +417,22 @@ main() {
> # uid be generated.
>
> # Now, add users whose uid is *not* automatic
> - for line in "${LINES[@]}"; do
> - read username uid group gid passwd home shell groups comment <<<"${line}"
> + sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" | while
> + read username uid group gid passwd home shell groups comment; do
> +
> + #for line in "${LINES[@]}"; do
> + #read username uid group gid passwd home shell groups comment <<<"${line}"
> [ "${username}" != "-" ] || continue # Magic string to skip user creation
> - [ ${uid} -ge 0 ] || continue # Automatic uid
> + [ "${uid}" -ge 0 ] || continue # Automatic uid
> add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \
> "${home}" "${shell}" "${groups}" "${comment}"
> done
>
> # Finally, add users whose uid *is* automatic
> - for line in "${LINES[@]}"; do
> - read username uid group gid passwd home shell groups comment <<<"${line}"
> + sed -r -e 's/#.*//; /^[[:space:]]*$/d;' "${USERS_TABLE}" | while
> + read username uid group gid passwd home shell groups comment; do
> + #for line in "${LINES[@]}"; do
> + #read username uid group gid passwd home shell groups comment <<<"${line}"
> [ "${username}" != "-" ] || continue # Magic string to skip user creation
> [ ${uid} -eq -1 ] || continue # Non-automatic uid
> add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \
> --
> 1.8.5.rc3
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
prev parent reply other threads:[~2016-07-05 8:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-30 6:37 [Buildroot] [PATCH] mkusers: make it work with mksh Kurt Van Dijck
2016-07-05 8:28 ` Yann E. MORIN [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160705082834.GG6533@free.fr \
--to=yann.morin.1998@free.fr \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox