[Pkg-acpi-devel] Bug#510619: acpi-support: Use who, instand of w, because w truncates long usernames

Witold Baryluk baryluk at smp.if.uj.edu.pl
Thu Apr 16 15:23:20 UTC 2009


On 04-16 15:40, Luca Niccoli wrote:
> 2009/4/16 Witold Baryluk <baryluk at smp.if.uj.edu.pl>:
> > Package: acpi-support
> > Version: 0.109-11
> > Followup-For: Bug #510619
> >
> > 'w' truncates longer than 8 char long loings. Mayby use 'who'?
> 
> Err, I don't see how this is related to #510619, the username was
> "torn" and, AFAICT, the problem was the his X session wasn't recorded
> (w reported just two xterms)
> Anyway, IIRC "who" had its problems as well, at one point I proposed a
> patch to use pinky instead (see #502141), but I don't know if the
> patch still applies.
> I checked and pinky keeps long user names, the layout gets a bit
> messed up but I that shouldn't disturb the script.
> Cheers,

pinky is in coreutils.

# pinky -fw
ganczarek  tty7            2009-04-16 15:08 :0
baryluk  *         02:28  2009-04-16 16:54 10.0.2.6:1
baryluk   pts/2    00:03  2009-04-16 16:55 10.0.2.6:1.0
baryluk   pts/3           2009-04-16 16:56 10.0.2.6:1.0
root     *pts/4           2009-04-16 16:57 tytus.smp.if.uj.edu.pl
#

Strange output

> 
> Luca
> 
> P.S.
> Is it to be considered a bug of w that it truncates user names, or is
> it supposed to?

/usr/include/bits/utmp.h #define UT_NAMESIZE     32

but in w.c : 196

 printf("%-9.8s%-9.8s", uname, u->ut_line);

which limits username (and terminal name)
to 8 chars, mayby I will ask procps maintainers.

This should be probably

 printf("%-8s %-8s ", uname, u->ut_line);

Similary in line 211.


# w -hs
ganczare tty7     :0                1.00s /usr/bin/lxsession -s LXDE
baryluk           10.0.2.6:1        2:44m /usr/bin/gnome-session
baryluk  pts/2    10.0.2.6:1.0     19:58  mutt
baryluk  pts/3    10.0.2.6:1.0      0.00s ssh tytus.smp.if.uj.edu.pl -X -l root
root     pts/4    tytus.smp.if.uj.  0.00s ./w -hs
baryluk  pts/9    10.0.2.6:1.0      9:27  -csh

procps-3.2.7# ./w -hs
ganczarek tty7      :0                1.00s /usr/bin/lxsession -s LXDE
baryluk            10.0.2.6:1        2:45m /usr/bin/gnome-session
baryluk  pts/2     10.0.2.6:1.0     20:47  mutt
baryluk  pts/3     10.0.2.6:1.0      0.00s ssh tytus.smp.if.uj.edu.pl -X -l root
root     pts/4     tytus.smp.if.uj.  0.00s ./w -hs
baryluk  pts/9     10.0.2.6:1.0     10:16  -csh


Not very pretty but there is no good way to do this prettier (mayby
first iterating over all entries and checking maximal widths, in second
use proper columns sizes).

BTW. Hostname is also truncated... which is also important for getXuser functionality.

-- 
Witold Baryluk
JID: witold.baryluk // jabster.pl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-acpi-devel/attachments/20090416/92098716/attachment-0001.pgp>


More information about the Pkg-acpi-devel mailing list