httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf S. Engelschall" <...@engelschall.com>
Subject Re: cvs commit: apache-1.3/src/helpers getuid.sh
Date Thu, 22 Apr 1999 09:05:41 GMT

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

Mime
View raw message