Loading ...
Sorry, an error occurred while loading the content.
 

Re: [redhat] problem regarding length of User login name

Expand Messages
  • J
    ... instead of grepping for the whole username, try grepping for the first few characters. For example, on my system, I created a user to test this called
    Message 1 of 14 , Dec 23, 2009
      On Wed, Dec 23, 2009 at 12:07, somnath laha <slahamail@...> wrote:

      > using
      > *last |grep <username>| wc -l* is not reporting the login of a user having
      > user login name of more than 8 characters.
      >
      > can anyone have any idea about this?

      instead of grepping for the whole username, try grepping for the first
      few characters.

      For example, on my system, I created a user to test this called
      jefftrustworthy, which is far more than 8 characters.

      So now I check last like this:
      bladernr@asuka:~$ last | grep jefftrustworthy |wc -l
      0

      Now if I change it to search only for the first few characters:
      bladernr@asuka:~$ last | grep jefft |wc -l
      2

      and now to show you why:
      bladernr@asuka:~$ last |grep jefft
      jefftrus pts/0 :0.0 Wed Dec 23 15:07 - 15:07 (00:00)
      jefftrus tty7 :0 Wed Dec 23 15:07 - 15:07 (00:00)

      The answer: last truncates the username column to 8 characters.

      cheers,

      Jeff

      --

      Ogden Nash  - "The trouble with a kitten is that when it grows up,
      it's always a cat."
    • Dominic P Geevarghese
      Hi, From your problem description what I understand is Box is not returning the username which is more than 8 characters . but it returns UID instead of
      Message 2 of 14 , Dec 23, 2009
        Hi,

        From your problem description what I understand is

        Box is not returning the username which is more than 8 characters . but it returns "UID" instead of that.  You can see the same behaviour when you grep a process from the output of "ps" for the user names having more than 8 character !

        Then, its expected behaviour :) . This is how that designed ! .

        The POSIX standards specify that in cases where there is insufficient
        width in a column to print a full username or group name, the
        corresponding user ID (or group ID) integer should be printed in its
        place. Truncating the names would, for example, lead to confusion
        between names like MichelleRichards and MichelleRichardson.

        -- Dominic


        --- On Wed, 23/12/09, somnath laha <slahamail@...> wrote:

        From: somnath laha <slahamail@...>
        Subject: [redhat] problem regarding length of User login name
        To: redhat@yahoogroups.com
        Date: Wednesday, 23 December, 2009, 10:37 PM







         









        Hello everybody

        I am a new to linux

        while exploring it I faced a problem

        It is as follows



        using

        *last |grep <username>| wc -l* is not reporting the login of a user having

        user login name of more than 8 characters.



        can anyone have any idea about this?



        Regards

        Somnath Laha



        [Non-text portions of this message have been removed]























        The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/

        [Non-text portions of this message have been removed]
      • J
        On Wed, Dec 23, 2009 at 21:24, Dominic P Geevarghese ... Not quite... He s doing this: last | grep LONGUSERNAME |wc -l Which will always return 0 because
        Message 3 of 14 , Dec 23, 2009
          On Wed, Dec 23, 2009 at 21:24, Dominic P Geevarghese
          <pgdominic@...> wrote:

          > From your problem description what I understand is
          >
          > Box is not returning the username which is more than 8 characters . but it returns "UID"
          > instead of that.  You can see the same behaviour when you grep a process from the output
          > of "ps" for the user names having more than 8 character !
          >
          > Then, its expected behaviour :) . This is how that designed ! .

          Not quite... He's doing this:

          last | grep LONGUSERNAME |wc -l

          Which will always return 0 because LONGUSERNAME does not appear in the
          last output whereas if he did what I suggested, he should get it...

          Granted, I am also testing this on Ubuntu and not Red Hat (I don't
          have a red hat system running at the moment, but I will tomorrow at
          work if this gets bounced and I see a reply in my e-mail tomorrow)

          But at least on my Ubuntu based system last DOES truncate the output
          from wtmp like so:
          bladernr tty7 :0 Wed Dec 23 15:08 still logged in
          jefftrus pts/0 :0.0 Wed Dec 23 15:07 - 15:07 (00:00)
          jefftrus tty7 :0 Wed Dec 23 15:07 - 15:07 (00:00)
          bladernr pts/1 :0.0 Wed Dec 23 15:03 - 15:06 (00:03)


          Whereas running strings on the wtmp file itself gives me this:
          tty7
          jefftrustworthy
          rx2K
          pts/0
          jefftrustworthy
          :0.0
          {x2K
          pts/0
          jefftrustworthy
          tty7

          So, wtmp contains full usernames where the program last does truncate.



          >
          > The POSIX standards specify that in cases where there is insufficient
          > width in a column to print a full username or group name, the
          > corresponding user ID (or group ID) integer should be printed in its
          > place. Truncating the names would, for example, lead to confusion
          > between names like MichelleRichards and MichelleRichardson.

          By the way, I'm not arguing that this is incorrect, because that
          certainly sounds reasonable to me... just pointing out that at least
          on Crunchbang, a Ubuntu derivative, last does seem to to truncate
          usernames... for example:

          bladernr@asuka:~$ last |grep jeff
          jefftrus tty2 Wed Dec 23 22:36 - 22:36 (00:00)
          jefftrus tty2 Wed Dec 23 22:36 - 22:36 (00:00)
          jefftrus pts/0 :0.0 Wed Dec 23 15:07 - 15:07 (00:00)
          jefftrus tty7 :0 Wed Dec 23 15:07 - 15:07 (00:00)

          The logins timestamped 15:07 are for user jefftrustworthy while the
          ones stamped 22:36 are for user jefftrustworthless

          This is curious... I'll check a RHEL 5.4 system in the morning and a
          SLES system if I can get one installed tomorrow and see what that
          does...

          FWIW, I can not see an option in the last manpage that lets us
          specifiy UID instead of username.

          Cheers,
          Jeff
          --

          Joan Crawford  - "I, Joan Crawford, I believe in the dollar.
          Everything I earn, I spend."
        • Scott
          ... Yup, same on CentOS 5.4 I just created a user jeffmistrusted (sorry, it just popped into my cynical excuse for a mind) and running last truncated it to
          Message 4 of 14 , Dec 23, 2009
            On Wed, Dec 23, 2009 at 10:38:50PM -0500, J wrote:
            >
            > But at least on my Ubuntu based system last DOES truncate the output
            > from wtmp like so:
            > bladernr tty7 :0 Wed Dec 23 15:08 still logged in
            > jefftrus pts/0 :0.0 Wed Dec 23 15:07 - 15:07 (00:00)
            > jefftrus tty7 :0 Wed Dec 23 15:07 - 15:07 (00:00)
            > bladernr pts/1 :0.0 Wed Dec 23 15:03 - 15:06 (00:03)

            Yup, same on CentOS 5.4 I just created a user jeffmistrusted (sorry, it
            just popped into my cynical excuse for a mind) and running last
            truncated it to jeffmist. Hrrm, if you ever design a fragrance and make
            millions from that name, send me some money.



            --
            Scott Robbins
            PGP keyID EB3467D6
            ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
            gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

            Cordelia: You're just a souless bloodsucking demon. They're
            LAWYERS
          • thad_floryan
            ... Hmmm, the docs for GNU last here: show a --wide option which purports to print out the
            Message 5 of 14 , Dec 24, 2009
              --- In redhat@yahoogroups.com, Scott <scottro@...> wrote:
              >
              > On Wed, Dec 23, 2009 at 10:38:50PM -0500, J wrote:
              > >
              > > But at least on my Ubuntu based system last DOES truncate the output
              > > from wtmp like so:
              > > bladernr tty7 :0 Wed Dec 23 15:08 still logged in
              > > jefftrus pts/0 :0.0 Wed Dec 23 15:07 - 15:07 (00:00)
              > > jefftrus tty7 :0 Wed Dec 23 15:07 - 15:07 (00:00)
              > > bladernr pts/1 :0.0 Wed Dec 23 15:03 - 15:06 (00:03)
              >
              > Yup, same on CentOS 5.4 I just created a user jeffmistrusted ...

              Hmmm, the docs for GNU "last" here:

              <http://www.gnu.org/software/acct/manual/html_node/last.html>

              show a "--wide" option which purports to print out the entirety of
              each field in its full width. If for some reason it doesn't, the
              source is available for fixing the bug for a local install as has been
              done for decades with other programs' source code.

              Regardless, the BUG is quite obvious in last's source code from here:

              <http://ftp.gnu.org/gnu/acct/acct-6.5.1.tar.gz>

              where we find this crapola in last.c (in the GNU accounting tarball):

              /* Some systems (like Linux with the newer glibc) have very long field
              lengths for usernames, ttys, and hostnames. While it's useful to
              print out the entire values from time to time, the casual browser
              doesn't care (and it screws up the 80-column formatting). Keep
              track of desired field widths with these variables. */

              #define my_min(x,y) ((x) < (y) ? (x) : (y))
              int print_name_len = my_min (NAME_LEN, 8);
              int print_tty_len = my_min (TTY_LEN, 12);
              int print_host_len = my_min (HOST_LEN, 16);
              #undef my_min


              Simply change those lengths, recompile, and voila, bug fixed. Who in
              their right mind is concerned with 80-column formatting TODAY?
            • thad_floryan
              ... Looking further in the source, the --wide option will do it; here s the actual code where the three items (username, ttyname, hostname) are set to print
              Message 6 of 14 , Dec 24, 2009
                --- In redhat@yahoogroups.com, "thad_floryan" <thad@...> wrote:
                > [...]
                > Hmmm, the docs for GNU "last" here:
                >
                > <http://www.gnu.org/software/acct/manual/html_node/last.html>
                >
                > show a "--wide" option which purports to print out the entirety of
                > each field in its full width.
                > [...]

                Looking further in the source, the "--wide" option will do it; here's
                the actual code where the three items (username, ttyname, hostname)
                are set to print to their maximum field widths:

                case 'w':
                case 16:
                /* Print the entire field widths, rather than our
                conservative, 80-column defaults */
                print_name_len = NAME_LEN;
                print_tty_len = TTY_LEN;
                print_host_len = HOST_LEN;
                break;

                Note also both "-w" and "--wide" should do the same thing.
              • thad_floryan
                ... Hmmmm. Just checked 3 different distros here and NONE of them are using the GNU last, so the appellation GNU/Linux by some is false. In any event, I just
                Message 7 of 14 , Dec 24, 2009
                  --- In redhat@yahoogroups.com, "thad_floryan" <thad@...> wrote:
                  > [...]
                  > Hmmm, the docs for GNU "last" here:
                  >
                  > <http://www.gnu.org/software/acct/manual/html_node/last.html>
                  >
                  > show a "--wide" option which purports to print out the entirety of
                  > [...]

                  Hmmmm. Just checked 3 different distros here and NONE of them are using
                  the GNU last, so the appellation "GNU/Linux" by some is false.

                  In any event, I just built the GNU last and the -w/--wide option does
                  work even though it's not shown in the program's help per the following
                  noting the system's (default) last is even more stripped-down:

                  thad@ubuntu:/usr/local/src/last/acct-6.5.1$ ./last -h
                  ./last: invalid option -- h
                  Usage: ./last [-aihsxyV] [-<lines>] [-n <lines>] [-f <file>] [people] [ttys] ...
                  [--lines <num>] [--file <file>] [--complain] [--debug]
                  [--version] [--tw-leniency <value>] [--tw-suspicious <value>]
                  [--no-truncate-ftp-entries] [--print-year] [--print-seconds]
                  [--more-records] [--all-records] [--ip-address] [--help]

                  The system's default login accounting file is /var/log/wtmp.

                  thad@ubuntu:/usr/local/src/last/acct-6.5.1$ /usr/bin/last -h
                  /usr/bin/last: invalid option -- h
                  Usage: last [-num | -n num] [-f file] [-t YYYYMMDDHHMMSS] [-R] [-x] [-o] [username..] [tty..]


                  You can see how the GNU last works (below) compared to the "standard"
                  last program:

                  thad@ubuntu:/usr/local/src/last/acct-6.5.1$ /usr/bin/last
                  thad pts/0 :0.0 Thu Dec 24 05:32 still logged in
                  thad tty7 :0 Thu Dec 24 05:32 still logged in
                  reboot system boot 2.6.24-26-generi Thu Dec 24 05:31 - 05:44 (00:12)
                  thad pts/0 :0.0 Thu Dec 10 02:27 - 02:38 (00:10)
                  thad pts/0 :0.0 Thu Dec 10 02:19 - 02:21 (00:02)
                  thad tty7 :0 Thu Dec 10 02:18 - 02:38 (00:19)
                  reboot system boot 2.6.24-26-generi Thu Dec 10 02:18 - 02:38 (00:19)

                  wtmp begins Wed Dec 9 23:56:49 2009
                  thad@ubuntu:/usr/local/src/last/acct-6.5.1$ ./last
                  thad pts/0 :0.0 Thu Dec 24 05:32 still logged in
                  thad tty7 :0 Thu Dec 24 05:32 still logged in
                  reboot system boot 2.6.24-26-generi Thu Dec 24 05:31
                  thad pts/0 :0.0 Thu Dec 10 02:27 - 02:38 (00:10)
                  thad pts/0 :0.0 Thu Dec 10 02:19 - 02:21 (00:02)
                  thad tty7 :0 Thu Dec 10 02:18 - 02:38 (00:19)
                  reboot system boot 2.6.24-26-generi Thu Dec 10 02:18

                  wtmp begins Wed Dec 9 23:56
                  thad@ubuntu:/usr/local/src/last/acct-6.5.1$ ./last -w
                  thad pts/0 :0.0 Thu Dec 24 05:32 still logged in
                  thad tty7 :0 Thu Dec 24 05:32 still logged in
                  reboot system boot 2.6.24-26-generic Thu Dec 24 05:31
                  thad pts/0 :0.0 Thu Dec 10 02:27 - 02:38 (00:10)
                  thad pts/0 :0.0 Thu Dec 10 02:19 - 02:21 (00:02)
                  thad tty7 :0 Thu Dec 10 02:18 - 02:38 (00:19)
                  reboot system boot 2.6.24-26-generic Thu Dec 10 02:18

                  wtmp begins Wed Dec 9 23:56
                • J
                  ... Wonder where the GNU last is going then... I d say Debian, but don t know if anyone has tried that... Hurd, maybe? Is Hurd even around anymore? I ve tried
                  Message 8 of 14 , Dec 24, 2009
                    On Thu, Dec 24, 2009 at 08:56, thad_floryan <thad@...> wrote:
                    > Hmmmm. Just checked 3 different distros here and NONE of them are using
                    > the GNU last, so the appellation "GNU/Linux" by some is false.
                    >
                    > In any event, I just built the GNU last and the -w/--wide option does
                    > work even though it's not shown in the program's help per the following
                    > noting the system's (default) last is even more stripped-down:

                    Wonder where the GNU last is going then... I'd say Debian, but don't
                    know if anyone has tried that... Hurd, maybe? Is Hurd even around
                    anymore?

                    I've tried on both a Crunchbang (Ubuntu based) and RHEL 5.2 system and
                    both are using a different version of last, apparently.

                    In fact, the -w or --wide options are not on either of them... I'm
                    feeling wonder about the latest Fedora. I can't go opening bugs
                    against RHEL, though I can against Crunchbang :-) What a gift a bug
                    report makes :-)



                    --

                    Samuel Goldwyn  - "I'm willing to admit that I may not always be
                    right, but I am never wrong."
                  • thad_floryan
                    ... Obviously Ubuntu doesn t have the GNU version, neither does any Fedora I just checked. Cannot boot CentOS since their live CDs won t boot on a SATA optical
                    Message 9 of 14 , Dec 24, 2009
                      --- In redhat@yahoogroups.com, J <dreadpiratejeff@...> wrote:
                      >
                      > On Thu, Dec 24, 2009 at 08:56, thad_floryan <thad@...> wrote:
                      > > Hmmmm. Just checked 3 different distros here and NONE of them are using
                      > > the GNU last, so the appellation "GNU/Linux" by some is false.
                      > >
                      > > In any event, I just built the GNU last and the -w/--wide option does
                      > > work even though it's not shown in the program's help per the following
                      > > noting the system's (default) last is even more stripped-down:
                      >
                      > Wonder where the GNU last is going then... I'd say Debian, but don't
                      > know if anyone has tried that... Hurd, maybe? Is Hurd even around
                      > anymore?
                      >
                      > I've tried on both a Crunchbang (Ubuntu based) and RHEL 5.2 system and
                      > both are using a different version of last, apparently.
                      >
                      > In fact, the -w or --wide options are not on either of them... I'm
                      > feeling wonder about the latest Fedora. I can't go opening bugs
                      > against RHEL, though I can against Crunchbang :-) What a gift a bug
                      > report makes :-)

                      Obviously Ubuntu doesn't have the GNU version, neither does any Fedora
                      I just checked. Cannot boot CentOS since their live CDs won't boot on
                      a SATA optical drive (Red Hat bug going back to mid-2000s for which I
                      filed a bugzilla last year), and I don't have time to check any other
                      distros.

                      I suppose I'm just going to have to resume what I used to do: build
                      system software only from original source code and forget all the
                      repositories. I have to do that now anyway to keep my astronomy and
                      science programs current, so no big deal, especially since I used to
                      do it since the 1970s.
                    • Scott
                      ... Not on F12 either. (Nor CentOS 5.4) -- Scott Robbins PGP keyID EB3467D6 ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 ) gpg --keyserver pgp.mit.edu
                      Message 10 of 14 , Dec 24, 2009
                        On Thu, Dec 24, 2009 at 09:20:45AM -0500, J wrote:

                        > On Thu, Dec 24, 2009 at 08:56, thad_floryan <thad@...> wrote:
                        > > Hmmmm. Just checked 3 different distros here and NONE of them are using
                        > > the GNU last, so the appellation "GNU/Linux" by some is false.
                        > >

                        > I've tried on both a Crunchbang (Ubuntu based) and RHEL 5.2 system and
                        > both are using a different version of last, apparently.
                        >
                        > In fact, the -w or --wide options are not on either of them... I'm
                        > feeling wonder about the latest Fedora. I can't go opening bugs
                        > against RHEL, though I can against Crunchbang :-) What a gift a bug
                        > report makes :-)
                        >

                        Not on F12 either.
                        (Nor CentOS 5.4)


                        --
                        Scott Robbins
                        PGP keyID EB3467D6
                        ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
                        gpg --keyserver pgp.mit.edu --recv-keys EB3467D6


                        Cordelia: What's going on? Oh god, is the world ending? I have to
                        research a paper on Bosnia for tomorrow, but if the world's ending,
                        I'm not gonna bother.
                      • J
                        Heh... ... BZ 550333 opened at Red Hat against Fedora 12 ;-) As I said over on linux@, I bet nothing changes...heh -- Ogden Nash  - The trouble with a
                        Message 11 of 14 , Dec 24, 2009
                          Heh...

                          On Thu, Dec 24, 2009 at 09:59, Scott <scottro@...> wrote:

                          > Not on F12 either.
                          > (Nor CentOS 5.4)

                          BZ 550333 opened at Red Hat against Fedora 12 ;-) As I said over on
                          linux@, I bet nothing changes...heh


                          --

                          Ogden Nash  - "The trouble with a kitten is that when it grows up,
                          it's always a cat."
                        • thad_floryan
                          ... Thank you for checking. It s not on Solaris either; I need to still check arch, SLED, and a few others to see how widespread the problem really is.
                          Message 12 of 14 , Dec 24, 2009
                            --- In redhat@yahoogroups.com, Scott <scottro@...> wrote:
                            >
                            > On Thu, Dec 24, 2009 at 09:20:45AM -0500, J wrote:
                            >
                            > > On Thu, Dec 24, 2009 at 08:56, thad_floryan <thad@...> wrote:
                            > > > Hmmmm. Just checked 3 different distros here and NONE of them are using
                            > > > the GNU last, so the appellation "GNU/Linux" by some is false.
                            > > >
                            >
                            > > I've tried on both a Crunchbang (Ubuntu based) and RHEL 5.2 system and
                            > > both are using a different version of last, apparently.
                            > >
                            > > In fact, the -w or --wide options are not on either of them... I'm
                            > > feeling wonder about the latest Fedora. I can't go opening bugs
                            > > against RHEL, though I can against Crunchbang :-) What a gift a bug
                            > > report makes :-)
                            > >
                            >
                            > Not on F12 either.
                            > (Nor CentOS 5.4)


                            Thank you for checking. It's not on Solaris either; I need to still
                            check arch, SLED, and a few others to see how widespread the problem
                            really is.
                          • Scott
                            ... Try BSD--as Jeff said in his post on linux@, they decided to do what Linux always does to BSD and make it less functional. :) Works fine on FreeBSD--an
                            Message 13 of 14 , Dec 24, 2009
                              On Thu, Dec 24, 2009 at 03:18:50PM -0000, thad_floryan wrote:
                              > --- In redhat@yahoogroups.com, Scott <scottro@...> wrote:
                              > >
                              >
                              >
                              > Thank you for checking. It's not on Solaris either; I need to still
                              > check arch, SLED, and a few others to see how widespread the problem
                              > really is.

                              Try BSD--as Jeff said in his post on linux@, they decided to do what
                              Linux always does to BSD and make it less functional. :)

                              Works fine on FreeBSD--an aged 8.0 CURRENT (8.0 is now stable, but it
                              hasn't been updated in a longggggggggggggggg time.)



                              --
                              Scott Robbins
                              PGP keyID EB3467D6
                              ( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
                              gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

                              Principal Snyder: There are some things I can just smell. It's
                              like a sixth sense.
                              Giles: No, actually, that would be one of the five.
                            Your message has been successfully submitted and would be delivered to recipients shortly.