Author Topic: How to change users id range for Zentyal users from 65534+ to other range?  (Read 336 times)

murz

  • Zen Apprentice
  • *
  • Posts: 37
  • Karma: +1/-0
    • View Profile
On Zentyal 6.1 setup, created Zentyal users got user ids, starting from 65534 (Guest) and increasing (user2 is 65535, user3 is 65536, etc).

Where can I configure starting id number for change this to lower (2000+) value, and to make user id's range differ from other Zentyal servers?

murz

  • Zen Apprentice
  • *
  • Posts: 37
  • Karma: +1/-0
    • View Profile
Seems this is because Zentyal (or samba?) lookups max uid, and see the nobody's user id 65534 (that is default in Ubuntu https://wiki.ubuntu.com/nobody ) and inrease this number?

So is there any way to manually set starting number for new LDAP users id's?
« Last Edit: January 10, 2020, 08:17:20 am by murz »

murz

  • Zen Apprentice
  • *
  • Posts: 37
  • Karma: +1/-0
    • View Profile
I have found in file /usr/share/perl5/EBox/Samba/User.pm code, that generates new user id:
Code: [Select]
# Method: lastUid
#
#       Returns the last uid used.
#
# Parameters:
#
#       system - boolean: if true, it returns the last uid for system users,
#                         otherwise the last uid for normal users
#       
# Returns:
#
#       string - last uid
#
sub lastUid
{
    my ($class, $system) = @_;

    my $lastUid = -1;
    my $sambaModule = EBox::Global->modInstance('samba');
    foreach my $user (@{$sambaModule->users($system)}) {
        my $uid = $user->get('uidNumber');
        if ($system) {
            last if ($uid >= MINUID);
        } else {
            next if ($uid < MINUID);
        }
        if ($uid > $lastUid) {
            $lastUid = $uid;
        }
    }
       
    my $ret;
    if ($system) {
        $ret = ($lastUid < SYSMINUID ? SYSMINUID : $lastUid);
    } else {
        $ret = ($lastUid < MINUID ? MINUID : $lastUid);
    }
    return $ret;
}

So yes, seems it lookups current system maximum user id (that is 65534 for all default Ubuntu setups) and increase it.

What is easier way to add configurable range for LDAP users id - hardcode it to this function in file?

murz

  • Zen Apprentice
  • *
  • Posts: 37
  • Karma: +1/-0
    • View Profile
And in /usr/share/perl5/EBox/Samba/SecurityPrincipal.pm I have found other place:

Code: [Select]
# Method: lastUid
#
#       Returns the last uid used.
#
# Parameters:
#
#       system - boolean: if true, it returns the last uid for system users,
#                         otherwise the last uid for normal users
#       
# Returns:
#
#       string - last uid
#
sub lastUid
{
    my ($class, $system) = @_;

    my $lastUid = -1;
    my $sambaModule = EBox::Global->modInstance('samba');
    foreach my $user (@{$sambaModule->users($system)}) {
        my $uid = $user->get('uidNumber');
        if ($system) {
            last if ($uid >= MINUID);
        } else {
            next if ($uid < MINUID);
        }
        if ($uid > $lastUid) {
            $lastUid = $uid;
        }
    }
       
    my $ret;
    if ($system) {
        $ret = ($lastUid < SYSMINUID ? SYSMINUID : $lastUid);
    } else {
        $ret = ($lastUid < MINUID ? MINUID : $lastUid);
    }
    return $ret;
}

where 65534 is hard-coded!

So after creating Guest user on Zentyal default install, all other users got guest uid+1!

Seems this is regression bug, so I create issue here: https://github.com/zentyal/zentyal/issues/1938
« Last Edit: January 10, 2020, 11:25:36 am by murz »