Changeset 1031

Show
Ignore:
Timestamp:
03/03/08 14:40:53 (9 months ago)
Author:
rats
Message:

first BSD fixes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/CHANGELOG

    r1029 r1031  
    11ispCP ω 1.0.0 Changelog 
    22~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     3 
     42008-03-03 Benedikt Heintel 
     5        - ENGINE: 
     6                * Added: Engine support for BSB plattforms (different root group) 
    37 
    482008-03-02 Benedikt Heintel 
  • trunk/engine/ispcp_common_methods.pl

    r1028 r1031  
    365365} 
    366366 
     367## 
     368# setfmode 
     369# sets user, group and rights of a file. 
     370# If $fgroup set to 'null' this function will get the GID from /etc/passwd 
     371# 
     372# @author               VHCS/ispCP Team 
     373# @author               Benedikt Heintel 
     374# @copyright    2006-2008 by ispCP | http://isp-control.net 
     375# @version              1.1 
     376# 
     377# @access       public 
     378# @param        String  $fname  File Name 
     379# @param        Mixed   $fuser  Linux User or UserID 
     380# @param        Mixed   $fgroup Linux Group, GroupID or null 
     381# @param        int             $fperms Linux Permissions 
     382# @return       int                             success (0) or error (-1) 
    367383sub setfmode { 
    368384 
    369     my ($fname, $fuid, $fgid, $fperms) = @_; 
     385    my ($fname, $fuser, $fgroup, $fperms) = @_; 
    370386 
    371387    push_el(\@main::el, 'setfmode()', 'Starting...'); 
    372388 
    373     if ( 
    374         !defined($fname) || !defined($fuid) || 
    375         !defined($fgid) || !defined($fperms) || 
    376         $fname eq '' || $fuid eq '' || 
    377         $fgid eq '' || $fperms eq '' 
    378        ) 
    379     { 
    380  
    381         push_el( 
    382                 \@main::el, 
    383                 'setfmode()', 
    384                 "ERROR: Undefined input data, fname: |$fname|, fuid: |$fuid|, fgid: |$fgid|, fperms: |$fperms| !" 
    385                ); 
    386  
     389    if (!defined($fname) || !defined($fuser) || !defined($fperms) || 
     390                $fname eq '' || $fname eq '' || $fgroup eq '' || $fperms eq '') { 
     391 
     392        push_el(\@main::el, 'setfmode()', 
     393                "ERROR: Undefined input data, fname: |$fname|, fuid: |$fuser|, fgid: |$fgroup|, fperms: |$fperms| !"); 
    387394        return -1; 
    388  
    389395    } 
    390396 
    391397    if (! -e $fname) { 
    392  
    393         push_el( 
    394                 \@main::el, 
    395                 'setfmode()', 
    396                 "ERROR: File '$fname' does not exist !" 
    397                ); 
    398  
     398        push_el(\@main::el, 'setfmode()', "ERROR: File '$fname' does not exist !"); 
    399399        return -1; 
    400400    } 
    401401 
    402402    my @udata = (); 
    403  
    404403    my @gdata = (); 
    405404 
    406     my ($uid, $gid) = ($fuid, $fgid); 
    407  
    408         if ($fuid =~ /^\d+$/) { 
    409  
    410                 $uid = $fuid; 
    411  
    412     } elsif ($fuid ne '-1') { 
    413  
    414         @udata = getpwnam($fuid); 
    415  
    416         if (scalar(@udata) == 0) { 
    417  
    418             push_el( 
    419                     \@main::el, 
    420                     'setfmode()', 
    421                     "ERROR: Unknown user '$fuid' !" 
    422                    ); 
    423  
    424             return -1; 
    425  
    426         } 
    427  
    428         $uid = $udata[2]; 
    429     } 
    430  
    431         if ($fgid =~ /^\d+$/) { 
    432  
    433                 $gid = $fgid; 
    434  
    435         } elsif ($fgid ne '-1') { 
    436  
    437         @gdata = getgrnam($fgid); 
    438  
    439         if (scalar(@gdata) == 0) { 
    440  
    441             push_el( 
    442                     \@main::el, 
    443                     'setfmode()', 
    444                     "ERROR: Unknown group '$fgid' !" 
    445                    ); 
    446  
    447             return -1; 
    448  
    449         } 
    450  
    451         $gid = $gdata[2]; 
    452     } 
     405    my ($uid, $gid) = (undef, undef); 
     406 
     407        # get UID of user 
     408        if ($fuser =~ /^\d+$/) { 
     409                $uid = $fuser; 
     410        } 
     411        elsif ($fuser ne '-1') { 
     412            @udata = getpwnam($fuser); 
     413 
     414            if (scalar(@udata) == 0) { 
     415               push_el(\@main::el, 'setfmode()', "ERROR: Unknown user '$fuser' !"); 
     416               return -1; 
     417            } 
     418            $uid = $udata[2]; 
     419        } 
     420 
     421        # get GID of user 
     422        if ($fgroup =~ /^\d+$/) { 
     423                $gid = $fgroup; 
     424        } 
     425        elsif ($fgroup eq null) { 
     426                $gid = $udata[3]; 
     427        } 
     428        elsif ($fgroup ne '-1') { 
     429                @gdata = getgrnam($fgroup); 
     430 
     431            if (scalar(@udata) == 0) { 
     432               push_el(\@main::el, 'setfmode()', "ERROR: Unknown user '$fgroup' !"); 
     433               return -1; 
     434            } 
     435            $gid = $gdata[2]; 
     436        } 
    453437 
    454438    my $res = chmod ($fperms, $fname); 
    455439 
    456440    if ($res != 1) { 
    457  
    458         push_el( 
    459                 \@main::el, 
    460                 'setfmode()', 
    461                 "ERROR: Can not change permissions of file '$fname' !" 
    462                ); 
    463  
     441        push_el(\@main::el, 'setfmode()', "ERROR: Can not change permissions of file '$fname' !"); 
    464442        return -1; 
    465  
    466443    } 
    467444 
     
    469446 
    470447    if ($res != 1) { 
    471  
    472         push_el( 
    473                 \@main::el, 
    474                 'setfmode()', 
    475                 "ERROR: Can not change user/group of file '$fname' !" 
    476                ); 
    477  
     448        push_el(\@main::el, 'setfmode()', "ERROR: Can not change user/group of file '$fname' !"); 
    478449        return -1; 
    479450 
     
    481452 
    482453    push_el(\@main::el, 'setfmode()', 'Ending...'); 
    483  
    484454    return 0; 
    485  
    486 
     455
     456 
    487457 
    488458sub get_file { 
     
    19341904    } 
    19351905 
    1936     $rs = store_file($main::cfg_file, $fline, 'root', 'root', 0644); 
     1906    $rs = store_file($main::cfg_file, $fline, 'root', null, 0644); 
    19371907 
    19381908    return 1 if ($rs != 0); 
     
    21182088 
    21192089            my $suexec_user_pref = $main::cfg{'APACHE_SUEXEC_USER_PREF'}; 
    2120  
    21212090            my $sys_user = "$suexec_user_pref$sys_uid"; 
    2122  
    21232091            my $sys_group = "$suexec_user_pref$sys_gid"; 
    2124  
    2125         # group data. 
    2126  
    2127         my $cmd = "$main::cfg{'CMD_GROUPADD'} -g $sys_gid $sys_group"; 
    2128  
     2092                my $cmd = undef; 
     2093 
     2094        # group data - BSD has another format: 
     2095                if ($main::cfg{'ROOT_GROUP'} eq "wheel") { 
     2096                        $cmd = "$main::cfg{'CMD_GROUPADD'} $sys_group -g $sys_gid"; 
     2097                } else { 
     2098                        $cmd = "$main::cfg{'CMD_GROUPADD'} -g $sys_gid $sys_group"; 
     2099                } 
    21292100        $rs = sys_command($cmd); 
    21302101 
     
    21362107                my $homedir = "$main::cfg{'APACHE_WWW_DIR'}/@$dmn_data[1]"; 
    21372108 
    2138                 $cmd = "$main::cfg{'CMD_USERADD'} -c virtual-user -d $homedir -g $sys_group -s /bin/false -u $sys_uid $sys_user"; 
     2109                # BSD has another format: 
     2110                if ($main::cfg{'ROOT_GROUP'} eq "wheel") { 
     2111                        $cmd = "$main::cfg{'CMD_USERADD'} $sys_user -c virtual-user -d $homedir -g $sys_group -s /bin/false -u $sys_uid"; 
     2112                } else { 
     2113                        $cmd = "$main::cfg{'CMD_USERADD'} -c virtual-user -d $homedir -g $sys_group -s /bin/false -u $sys_uid $sys_user"; 
     2114                } 
    21392115 
    21402116        $rs = sys_command($cmd); 
  • trunk/engine/setup/ispcp-setup

    r1026 r1031  
    411411sub setup_system_users { 
    412412 
    413         my ($rs, $rdata) = (undef, undef); 
     413        my ($rs, $rdata, $cmd) = (undef, undef, undef); 
    414414 
    415415        push_el(\@main::el, 'setup_system_users()', 'Starting...'); 
     
    425425 
    426426        if (scalar(@gdata) == 0) { # we have not this one group data; 
    427                 my $cmd = "$main::cfg{'CMD_GROUPADD'} $fgid"; 
     427                if ($main::cfg{'ROOT_GROUP'} eq "wheel") { 
     428                        $cmd = "$main::cfg{'CMD_GROUPADD'} -g $fgid"; 
     429                } else { 
     430                        $cmd = "$main::cfg{'CMD_GROUPADD'} $fgid"; 
     431                } 
    428432                $rs = sys_command($cmd); 
    429433 
     
    438442 
    439443        if (scalar(@udata) == 0) { # we have not this one user data; 
    440                 my $cmd = "$main::cfg{'CMD_USERADD'} -c vmail-user -g $gid -s /bin/false $fuid"; 
     444                if ($main::cfg{'ROOT_GROUP'} eq "wheel") { 
     445                        $cmd = "$main::cfg{'CMD_USERADD'} vmail-user -s /bin/false $fuid"; 
     446                } else { 
     447                        $cmd = "$main::cfg{'CMD_USERADD'} -c vmail-user -g $gid -s /bin/false $fuid"; 
     448                } 
    441449                $rs = sys_command($cmd); 
    442450 
     
    458466 
    459467        if (scalar(@gdata) == 0) { # we do not have this group 
    460                 my $cmd = "$main::cfg{'CMD_GROUPADD'} -g $mgid $prefix$mgid"; 
     468                if ($main::cfg{'ROOT_GROUP'} eq "wheel") { 
     469                        $cmd = "$main::cfg{'CMD_GROUPADD'} v-group -g $mgid $prefix$mgid"; 
     470                } else { 
     471                        $cmd = "$main::cfg{'CMD_GROUPADD'} -g $mgid $prefix$mgid"; 
     472                } 
    461473                $rs = sys_command($cmd); 
    462474 
     
    466478 
    467479        if (scalar(@udata) == 0) { # we do not have this user 
    468                 my $cmd = "$main::cfg{'CMD_USERADD'} -d  $main::cfg{'PHP_STARTER_DIR'}/master -m -c vu-master -g $prefix$mgid -s /bin/false -u $muid $prefix$muid"; 
     480                if ($main::cfg{'ROOT_GROUP'} eq "wheel") { 
     481                        $cmd = "$main::cfg{'CMD_USERADD'} vu-master -d  $main::cfg{'PHP_STARTER_DIR'}/master -m -s /bin/false -u $muid $prefix$muid"; 
     482                } else { 
     483                        $cmd = "$main::cfg{'CMD_USERADD'} -d  $main::cfg{'PHP_STARTER_DIR'}/master -m -c vu-master -g $prefix$mgid -s /bin/false -u $muid $prefix$muid"; 
     484                } 
    469485                $rs = sys_command($cmd); 
    470486 
  • trunk/tools/daemon/ispcp_daemon.c

    r712 r1031  
    55extern char *optarg; 
    66extern int optind, opterr, optopt; 
    7    
     7 
    88 
    99int main(int argc, char **argv) 
     
    2424        given_pid = 0; 
    2525        pidfile_path = (char)'\0'; 
    26          
     26 
    2727        while (( c = getopt( argc, argv, "p:" )) != EOF ) { 
    28         switch( c ) { 
    29         case 'p': 
    30             pidfile_path = optarg; 
    31             given_pid = 1; 
    32             break; 
    33  
    34         } 
     28                switch( c ) { 
     29                        case 'p': 
     30                            pidfile_path = optarg; 
     31                            given_pid = 1; 
     32                            break; 
     33                } 
    3534    } 
    3635 
     
    8180                fclose(file); 
    8281        } 
    83          
     82 
    8483        for ( ; ; ) { 
    8584