[lxc-devel] [PATCH] lxc-setuid: use POSIX shell instead of bash
Stéphane Graber
stgraber at ubuntu.com
Tue Nov 27 15:12:51 UTC 2012
On 11/26/2012 04:39 PM, Natanael Copa wrote:
> Avoid getop --longoptions.
>
> Signed-off-by: Natanael Copa <ncopa at alpinelinux.org>
Looks reasonable, though I'm not usually using that script so didn't
actually test the change.
Acked-by: Stéphane Graber <stgraber at ubuntu.com>
And pushed to staging. Thanks.
> ---
> src/lxc/lxc-setuid.in | 34 +++++++++++++++++++++-------------
> 1 file changed, 21 insertions(+), 13 deletions(-)
>
> diff --git a/src/lxc/lxc-setuid.in b/src/lxc/lxc-setuid.in
> index 84f18af..e6a7b96 100644
> --- a/src/lxc/lxc-setuid.in
> +++ b/src/lxc/lxc-setuid.in
> @@ -1,4 +1,4 @@
> -#!/bin/bash
> +#!/bin/sh
>
> #
> # lxc: linux Container library
> @@ -78,32 +78,40 @@ lxc_dropuid()
> chmod 0755 @LXCPATH@
> }
>
> -shortoptions='hd'
> -longoptions='help'
> -
> -getopt=$(getopt -o $shortoptions --longoptions $longoptions -- "$@")
> -if [ $? != 0 ]; then
> +usage_err() {
> + [ -n "$1" ] && echo "$1" >&2
> usage
> exit 1
> -fi
> +}
>
> -eval set -- "$getopt"
> +optarg_check() {
> + if [ -z "$2" ]; then
> + usage_err "option '$1' requires an argument"
> + fi
> +}
>
> -while true; do
> - case "$1" in
> +while [ $# -gt 0 ]; do
> + opt="$1"
> + shift
> + case "$opt" in
> -d)
> LXC_DROP_CAPS="yes"
> - shift
> ;;
> -h|--help)
> help
> exit 0
> ;;
> --)
> - shift
> break
> ;;
> - *)
> + -?)
> + usage_err "unknown option '$opt'"
> + ;;
> + -*)
> + # split opts -abc into -a -b -c
> + set -- $(echo "${opt#-}" | sed 's/\(.\)/ -\1/g') "$@"
> + ;;
> + *)
> usage
> exit 1
> ;;
>
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20121127/02e52465/attachment.pgp>
More information about the lxc-devel
mailing list