Changeset 1364 for trunk/engine

Show
Ignore:
Timestamp:
10/04/08 14:00:18 (2 months ago)
Author:
scitech
Message:

Fixed #1229: On domain creation groupadd / useradd fails when pre-existent accounts are found leaving the domain in error state

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/engine/ispcp_common_methods.pl

    r1361 r1364  
    20412041} 
    20422042 
     2043sub check_uid_gid_available { 
     2044 
     2045    my ($sys_uid, $sys_gid) = @_; 
     2046 
     2047    push_el(\@main::el, 'check_uid_gid_available()', 'Starting...'); 
     2048 
     2049    my $name = undef; 
     2050 
     2051    my $max_uid = $main::cfg{'APACHE_SUEXEC_MAX_UID'}; 
     2052 
     2053    my $max_gid = $main::cfg{'APACHE_SUEXEC_MAX_GID'}; 
     2054 
     2055    if($sys_uid > $max_uid){ 
     2056        push_el(\@main::el, 'check_uid_gid_available()', "ERROR: Maximum user id for this system is reached!"); 
     2057        return (2, $sys_uid, $sys_gid); 
     2058    } 
     2059 
     2060    if($sys_gid > $max_gid){ 
     2061        push_el(\@main::el, 'check_uid_gid_available()', "ERROR: Maximum group id for this system is reached!"); 
     2062        return (2, $sys_uid, $sys_gid); 
     2063    } 
     2064 
     2065    $name = getgrgid($sys_gid); 
     2066 
     2067    if( defined($name) ) { 
     2068        push_el(\@main::el, 'check_uid_gid_available()', "INFO: Group id $sys_gid already in use!"); 
     2069        return (1, $sys_uid, $sys_gid); 
     2070    } 
     2071 
     2072    $name = getpwuid($sys_uid); 
     2073 
     2074    if ( defined($name) ) { 
     2075        push_el(\@main::el, 'check_uid_gid_available()', "INFO: User id $sys_uid already in use!"); 
     2076        return (1, $sys_uid, $sys_gid); 
     2077    } 
     2078 
     2079    push_el(\@main::el, 'check_uid_gid_available()', 'Ending...'); 
     2080 
     2081    return (0, $sys_uid, $sys_gid); 
     2082 
     2083} 
     2084 
    20432085sub add_dmn_suexec_user { 
    20442086 
     
    20552097    my ($rs, $rdata, $sql) = (undef, undef, undef); 
    20562098 
     2099    my ($num, $sys_uid, $sys_gid) = (undef, undef, undef); 
     2100 
    20572101    if ($dmn_uid == 0 && $dmn_gid == 0) { 
    2058             my $num = get_auto_num(); 
    2059  
    2060             my ($sys_uid, $sys_gid) = ($suexec_min_uid + $num, $suexec_min_gid + $num); 
     2102 
     2103        do{ 
     2104            $num = get_auto_num(); 
     2105            ($sys_uid, $sys_gid) = ($suexec_min_uid + $num, $suexec_min_gid + $num); 
     2106            ($rs, $sys_uid, $sys_gid) = check_uid_gid_available($sys_uid, $sys_gid); 
     2107        }while ($rs == 1); 
     2108 
     2109        return $rs if ($rs != 0); 
    20612110 
    20622111            my $suexec_user_pref = $main::cfg{'APACHE_SUEXEC_USER_PREF'}; 
     
    20652114                my $cmd = undef; 
    20662115 
    2067                # group data - BSD has another format: 
     2116        # group data - BSD has another format: 
    20682117                # BSD/NUX Command 
    20692118                if ($main::cfg{'ROOT_GROUP'} eq "wheel") {