Bug 162976

Summary: [libc] cron fails unnecessarily via setlogin(2) with sufficiently long usernames
Product: Base System Reporter: Enji Cooper <ngie>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me CC: erin.clark.ix
Priority: Normal    
Version: 8.2-RELEASE   
Hardware: Any   
OS: Any   

Description Enji Cooper freebsd_committer freebsd_triage 2011-11-30 20:40:11 UTC
One can use active directory usernames in crontab like so and most of
the system is happy working with these long usernames:

*       *       *       *       *       STOUT\administrator     PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin true >/dev/null 2>&1

The problem is that cron gets unhappy when trying to run setlogin(2),
which ends up spewing out errors in syslog and cron exits:

Nov 30 07:44:00 truenas cron[25967]: setlogin(STOUT\administrator): Invalid argument

This limitation appears to still be present in 10-CURRENT though.

Fix: 

The only fix (which would be invasive) would be to honor (and exceed)
the limits set by other operating systems so that setlogin(2) wouldn't
fail. According to this KB article via MS, the username limit is 104
characters (although the recommend not going over 64 characters).

Other infrastructure pieces might need to be taught to honor this limit
(like utmp*).
How-To-Repeat: 1. Hook machine into AD/LDAP realm (the above example uses the STOUT AD
   realm).
2. Create something like the following entry:

*       *       *       *       *       STOUT\administrator     PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin true >/dev/null 2>&1
Comment 1 Erin Clark 2016-03-30 00:19:32 UTC
This appears to not be a problem anymore in 10.3 rc3
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:49:56 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"