You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Ralf S. Engelschall" <rs...@engelschall.com> on 1999/04/22 11:05:41 UTC

Re: cvs commit: apache-1.3/src/helpers getuid.sh

Thanks for your efforts, Jim. 
I've just a few remaining questions:

>   if AP_IDPATH=`./src/helpers/PrintPath id` ; then

Are you sure a construct "if var=val; then" really works on all Bourne shell
flavors? We've never used such a construct AFAIK, so I personally would write
it as:

    AP_RETVAL=`$AP_IDPATH -u 2>/dev/null`
    if [ $# -eq 0 ]; then

>       echo $AP_RETVAL
>       exit 0
>       else
>       AP_RETVAL=`$AP_IDPATH | \
>           sed -e 's/^.*uid=//' | \
>           sed -e 's/[     ]*(.*$//'`
>       echo $AP_RETVAL
>       exit 0
>       fi
>   fi

Here I would be more conservative: Check whether the resulting AP_REVAL is
actually [0-9]*. When not _continue_ and try to find out the UID with the
remaining approaches. Because currently when the output of id isn't
"uid=1234(xxx)" it just returns the complete id output which perhaps is not
what we want.

>[...]
>   if AP_WHOAMI=`./src/helpers/PrintPath whoami` ; then
>[...]

Here again I think we again should not use the nested construct.

>   AP_RETVAL=`egrep \^${AP_LOGNAME}: /etc/passwd | \
>       sed -e 's/[^:]*:[^:]*://' | \
>       sed -e 's/:.*$//'`

Here perhaps we can add another try with ypcat when AP_RETVAL is still the
empty string after this command, i.e. something like:

if [ "x$AP_RETVAL" = "x" ]; then
    AP_YPCAT=`src/helpers/PrintPath ypcat`
    if [ "x$AP_YPCAT" != "x" ]; then
        AP_RETVAL=`$AP_YPCAT passwd | egrep \^${AP_LOGNAME}: | \
            sed -e 's/[^:]*:[^:]*://' | \
            sed -e 's/:.*$//'`
    fi
fi

Except these subtle details the script already works fine.

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com