Project

General

Profile

Bug #2989

LOGNAME_MAX should be increased to 32

Added by Albert Lee about 7 years ago. Updated almost 6 years ago.

Status:
Resolved
Priority:
Low
Assignee:
Category:
cmd - userland programs
Start date:
2012-07-11
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:

Description

The current username length limit of 8 is extremely restrictive and will hopefully change in the future. To ease a future transition, applications using the LOGNAME_MAX constant to determine buffer sizes should be migrated to the dynamic value returned by sysconf(_SC_LOGIN_NAME_MAX). A quick search shows there are still several such consumers in ON.

(See discussion on long user names for PSARC/2010/184 here: http://arc.opensolaris.org/caselog/PSARC/2010/184/mail or here http://mail.opensolaris.org/pipermail/opensolaris-arc/2010-May/thread.html#21475 )


Files

tests.txt (16.6 KB) tests.txt All Tests Gary Mills, 2013-05-31 07:35 PM
2989-5.patch.Z (44.5 KB) 2989-5.patch.Z Gary Mills, 2013-08-11 12:42 PM

History

#1

Updated by Gary Mills over 6 years ago

  • Assignee set to Gary Mills
  • % Done changed from 0 to 80
Many source files in illumos employ LOGNAME_MAX to size buffers that are located on the stack. Since login names are limited to 32 characters by the utmpx structure, I decided that the changes would be simplified by introducing two new symbols into the limits.h header:
#define LOGNAME_MAX_ILLUMOS 32 /* max # of characters in an */
/* illumos login name */
#define LOGIN_NAME_MAX (LOGNAME_MAX_ILLUMOS + 1) /* max buffer size */

Many of the commands affected display output from either the process table or the utmpx/wtmpx files. In modifying the source files, I followed these principles:
  • No change in output format if login names are limited to 8 characters
  • Display long names in full wherever possible
  • Retain 80-column format for curses output
  • Add a truncation indicator when long names are truncated
#2

Updated by Gary Mills about 6 years ago

I've now dropped the LOGNAME_MAX_ILLUMOS symbol and instead increased LOGNAME_MAX from 8 to 32. This change means that most applications can just be recompiled without need for a source change. Other changes are intended to accomodate legacy applications. I've added a `-W' flag to `prstat' and `ps' which forces truncation of long login names. Like `prstat', the `ps' command now has a trailing asterisk to indicate that a long name has been truncated. I've also added an adjustable action so that `useradd' can issue a warning or an error when the login name exceeds the legacy value of 8 characters. Finally, I've created a preload library for getlogin(3C) that will truncate long login names. This intended for old executables that cannot handle longer names.

#3

Updated by Gary Mills about 6 years ago

I've made a few more changes in the 4th revision. First of all, there are two versions of the getlogin functions. These are selected by the redefine_extname pragma in unistd.h . Old executables get the ones that truncate login names to 8 characters. Newly-built executables get the versions that return full 32-character login names.
The getlogin8.so.1 preload library has been removed, as it's no longer needed. A new preload library, getloginx.so.1, acts as a shim so that old executables can call getlogin() but get the full 32-character login name.
There's a new symbol, USE_LEGACY_LOGNAME, that does the opposite, permitting new executables to be built that get versions of the getlogin functions that truncate login names to 8 characters.
Man pages are updated to describe these changed features.
I've attached a file, tests.txt, that contains results of all of the tests that I've performed to verify that long login names actually worked as intended.

#4

Updated by Andrew Stormont about 6 years ago

Are you saying that _SC_LOGIN_NAME_MAX can never be more than 32 characters long because that's the max supported by utmpx? If that's true is _SC_LOGIN_NAME_MAX enforcing this?

#5

Updated by Gary Mills about 6 years ago

Yes, that's correct. It's a result of the changes to sysconf.c and limits.h . With the changes, the value of LOGNAME_MAX is defined to be 32. See the webrev at:

    http://cr.illumos.org/~webrev/jgmills/2989-4/

for details.

#6

Updated by Gary Mills almost 6 years ago

I've attached a git-style patch named 2989-5.patch.Z to this bug report. This patch is built against illumos-gate from 7 August 2013. I only had to relocate two copyright lines to build it.

#7

Updated by Gary Mills almost 6 years ago

  • Status changed from New to In Progress
  • % Done changed from 90 to 100
#8

Updated by Gary Mills almost 6 years ago

Those URLs for PSARC/2010/184 no longer work, but you can find the discussion here:

http://markmail.org/message/sktimegzgyge26ev

#9

Updated by Robert Mustacchi almost 6 years ago

  • Subject changed from Eliminate use of LOGNAME_MAX in ON to want support for more than 8 character logins
#10

Updated by Robert Mustacchi almost 6 years ago

  • Subject changed from want support for more than 8 character logins to LOGNAME_MAX should be increased to 32
#11

Updated by Robert Mustacchi almost 6 years ago

  • Status changed from In Progress to Resolved
  • Difficulty changed from Bite-size to Medium
  • Tags deleted (needs-triage)

Resolved in 0a1278f26ea4b7c8c0285d4f2d6c5b680904aa01.

Also available in: Atom PDF