Bug 91442 - 'who am i' and 'who -m' do not return results as expected
Summary: 'who am i' and 'who -m' do not return results as expected
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: gnome-terminal (Show other bugs)
(Show other bugs)
Version: 8.0
Hardware: i686 Linux
medium
medium
Target Milestone: ---
Assignee: Havoc Pennington
QA Contact: David Lawrence
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2003-05-22 17:15 UTC by J. Erik Hemdal
Modified: 2017-08-21 20:55 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2003-10-04 06:05:27 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Test script for 91442 (345 bytes, application/x-sh)
2003-05-22 17:17 UTC, J. Erik Hemdal
no flags Details

Description J. Erik Hemdal 2003-05-22 17:15:51 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20021003

Description of problem:
Problems with 'who' command.

who -m
who am i
who mom likes

do not return any results on my RHAT 8 system.  man and info pages say these
should return the session username.


Version-Release number of selected component (if applicable):
sh-utils-2.0.12-3

How reproducible:
Always

Steps to Reproduce:
#! /bin/bash

# Test the output of who, who -m, who am i, whoami, and who mom likes
# All of these are documented to work; not all do in RHAT 8.0.

echo "This is unadorned 'who'"

	who

echo "This is 'who -m':"

	who -m

echo "This is 'who mom likes':"

	who mom likes

echo "This is 'who am i':"

	who am i

echo "This is 'whoami':"

	whoami




Actual Results:  This is unadorned 'who'
erik     :0           May 22 11:55         
This is 'who -m':
This is 'who mom likes':
This is 'who am i':
This is 'whoami':
erik


Expected Results:  Should have seen the username 'erik' in all cases.

Additional info:

No error messages.  These options work as expected in previous versions of Red
Hat Linux that I have used (5.2, 7.1, 7.3).  Represents a regression of 
function (old scripts using who -m or who am i) would break.

Comment 1 J. Erik Hemdal 2003-05-22 17:18:00 UTC
Created attachment 91900 [details]
Test script for 91442

Test script attached.

Comment 2 Tim Waugh 2003-05-23 11:55:02 UTC
This is due to gnome-terminal not adding utmp entries.  For example, try running
who from inside an 'xterm -ls' window.

Comment 3 J. Erik Hemdal 2003-05-23 22:30:22 UTC
I confirmed that who works as expected in an xterm.  Also works in gnome-
terminal-2.2.1-3 (delivered in Red Hat 9).

Comment 4 ThomasBaeckeroot 2017-08-21 20:55:23 UTC
Possible replacement from `who am i | awk '{print $1}'` (what most are looking for):
ls -l `tty` | awk '{print $3}'


Explanation below…

On many systems "`who am i`" is equivalent to "`who -m`". 
The Problem here is that with some terminals, "who -m" returns nothing.

Example #1 run from a xfce4-terminal

    Pegasus ~ # whoami
    root
    Pegasus ~ # who am i
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    Pegasus ~ # who -m
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    Pegasus ~ # who
    thomas   tty8         2017-08-19 10:18 (:0)
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    thomas   pts/5        2017-08-19 16:16 (:0.0)
    Pegasus ~ # who am i | awk '{print $1}'
    thomasPossible replacement from `who am i | awk '{print $1}'` (what most are looking for):
ls -l `tty` | awk '{print $3}'


Explanation below…

On many systems "`who am i`" is equivalent to "`who -m`". 
The Problem here is that with some terminals, "who -m" returns nothing.

Example #1 run from a xfce4-terminal

    Pegasus ~ # whoami
    root
    Pegasus ~ # who am i
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    Pegasus ~ # who -m
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    Pegasus ~ # who
    thomas   tty8         2017-08-19 10:18 (:0)
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    thomas   pts/5        2017-08-19 16:16 (:0.0)
    Pegasus ~ # who am i | awk '{print $1}'
    thomas
    Pegasus ~ # 


but
Example #2 from a gnome-terminal (same computer, same commands)

    Pegasus ~ # whoami
    root
    Pegasus ~ # who am i
    Pegasus ~ # who -m
    Pegasus ~ # who
    thomas   tty8         2017-08-19 10:18 (:0)
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    thomas   pts/5        2017-08-19 16:16 (:0.0)
    Pegasus ~ # 

This seems to be a consequence of gnome-terminal not adding utmp entries…

    Pegasus ~ # 


but
Example #2 from a gnome-terminal (same computer, same commands)

    Pegasus ~ # whoami
    root
    Pegasus ~ # who am i
    Pegasus ~ # who -m
    Pegasus ~ # who
    thomas   tty8         2017-08-19 10:18 (:0)
    thomas   pts/1        2017-08-19 11:15 (:0.0)
    thomas   pts/5        2017-08-19 16:16 (:0.0)
    Pegasus ~ # 

This seems to be a consequence of gnome-terminal not adding utmp entries…


Note You need to log in before you can comment on or make changes to this bug.