Usernames of only numbers can not login to OOD 4 (worked in 3.x)

In OpenOnDemand 4.0 usernames consisting of only numbers can no longer login. (this worked in 3.x) due to a new /opt/ood/mod_ood_proxy/lib/ood/user_map.lua those numeric usernames are presumed to be uid’s and the script tries to convert then to usernames which fails.
Solution was to comment out the following in the lua script:
– if tonumber(sys_user) then
– local pwd = require “posix.pwd”
– sys_user = pwd.getpwuid(tonumber(sys_user)).pw_name
– end

Alain van Hoof

:man_facepalming: sorry about that, I never considered usernames could be all numbers. I’ve created this bug ticket upstream for the same.

I’m having trouble replicating this. Mostly due to Linux systems not liking numeric only user ids. How’d you get this to work? I assume they’re all in LDAP, but is there any other PAM/nssswitch/etc configurations you provide to get numeric only ids to work?

We are using LDAP and an AD connection for our user(numbers) authorization/authentication and Rocky Linux 8 (and sssd) seems OK with it.

Can you run this program against a few of your users and see if the results are what you’d expect?

-- filename: delme.lua
-- to run issue 'lua delme.lua'

function actual_username(username)

  local num = tonumber(username)
  if num then
    local pwd = require "posix.pwd"
    local data = pwd.getpwnam(num)

    -- it's a numeric username
    if data then
      return data.pw_name

    -- not a numeric username, so must be a number
    else
      data = pwd.getpwuid(num)
      return data.pw_name
    end
  else
    return username
  end
end

--- edit these function calls with your own numeric usernames/string usernames and so on.
print(actual_username('johrstrom'))
print(actual_username(30961))
print(actual_username('30961'))

@alainvanhoof Can you run the program above against a few of your users and see if the results are what you’d expect? I’m looking to patch 4.0.1 with the same logic.

Sorry it took some time to check, looks good to me…

added to del_me.lua

print(actual_username('202247'))
print(actual_username(202247))
print(actual_username('1051'))
print(actual_username(1051))
print(actual_username('202326'))
print(actual_username(202326))
print(actual_username('1052'))
print(actual_username(1052))
print(actual_username('testacc'))
print(actual_username(testacc))
print(actual_username('1050'))
print(actual_username(1050))

output of lua del_me.lua:

202247
202247
202247
202247
202326
202326
202326
202326
testacc
nil
testacc
testacc

No issues on the timing, infact thank you for getting back to me quickly. The only nil here I believe is from this invocation where I believe testacc is a nil variable (i.e., not a string and not a number).

Thanks again for the report and the fix feedback. I’ll get this patched in 4.0.1 so you don’t have to continue to patch it.