Summary:ASTERISK-06463: [patch] build_tools/make_build_h uses whoami, a command that doesn't exist in Solaris
Reporter:drach (drach)Labels:
Date Opened:2006-03-02 16:12:55.000-0600Date Closed:2006-03-03 11:16:25.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 20060303__bug6638.diff.txt
( 1) make_build_h.patch
Description:Subject says it all.  Fix is to replace whoami with "who am i | cut -d' ' -f1"
Comments:By: Mark Monnin (wrmem) 2006-03-02 16:28:21.000-0600

"who am i" would include hostname (at least under Solaris 2.9) so it's not identical.  

What OS doesn't have /bin/sh define USER correctly in the first place?  I thought that was fairly standard?


if [ "$USER" = "" ] ; then USER=`whoami` ; fi

be better?

By: Tilghman Lesher (tilghman) 2006-03-02 16:33:18.000-0600

Would 'whoami' perhaps be included in /usr/ucb/bin and that's simply not in your path?

By: drach (drach) 2006-03-02 17:54:21.000-0600

WRT the first note, "who am i" does include other fields, that's why it's piped into cut.  Also I think checking for $USER first is the "right" way to do things.

WRT the second note, yes whoami is in /usr/ucb but that path is deprecated and will eventually be deleted from standard Solaris so we shouldn't depend on it.
Is there a concern doing it the way my patch does it?  It's a very minor performance hit and uses standard Solaris commands.

By: Tilghman Lesher (tilghman) 2006-03-02 18:31:01.000-0600

How about the output of 'id -un'?  Both Linux and FreeBSD return the same output as 'whoami' as with 'id -un'.

In response to your query, I'd much rather use a standard command that works in all instances than have to piecemeal a command for each platform.  Yes, it's minor here, but nickels and dimes add up to a very fragile file.

By: Tilghman Lesher (tilghman) 2006-03-02 18:42:21.000-0600

Given that I just checked and the id command is POSIX.2, I'm going ahead and committing this.  Committed to 1.2, merged to trunk.

By: drach (drach) 2006-03-03 09:39:36.000-0600

Unfortunately id -un doesn't work in Solaris.

$ id -un
id: illegal option -- u
Usage: id [-ap] [user]

By: Tilghman Lesher (tilghman) 2006-03-03 10:27:29.000-0600

Wow, Solaris is not POSIX-compliant?


By: drach (drach) 2006-03-03 10:44:14.000-0600

Apparently, by default, it's not.  In order to get the compliant id, one needs to use /usr/xpg4/bin/id.  So
how about doing it this way:

OS=`uname -s`
if [ $OS = SunOS ]
 USER=`/usr/xpg4/bin/id -un`
 USER=`id -un`
DATE=`date -u "+%Y-%m-%d %H:%M:%S"`

By: Tilghman Lesher (tilghman) 2006-03-03 10:45:34.000-0600

Apparently, it is, but it uses another non-standard path (sigh).  Solaris is starting to remind me of Red Hat, only without the advantages.

By: drach (drach) 2006-03-03 10:49:36.000-0600

Apparently Solaris is doing what other distributions do (type xpg4 into Google) or look at the XPG4 man page in Solaris.

By: Tilghman Lesher (tilghman) 2006-03-03 11:16:24.000-0600

Fixed once again.