Zentyal Forum, Linux Small Business Server

Zentyal Server => Directory and Authentication => Topic started by: murz on January 09, 2020, 04:20:41 pm

Title: How to change users id range for Zentyal users from 65534+ to other range?
Post by: murz on January 09, 2020, 04:20:41 pm
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?
Title: Re: How to change users id range for Zentyal users from 65534+ to other range?
Post by: murz on January 10, 2020, 08:15:04 am
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?
Title: Re: How to change users id range for Zentyal users from 65534+ to other range?
Post by: murz on January 10, 2020, 11:04:06 am
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?
Title: Re: How to change users id range for Zentyal users from 65534+ to other range?
Post by: murz on January 10, 2020, 11:19:42 am
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