Changeset 863


Ignore:
Timestamp:
12/15/11 17:23:45 (13 years ago)
Author:
nanardon
Message:
  • support IPv6 adresses
Location:
LATMOS-Accounts
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • LATMOS-Accounts/Changes

    r861 r863  
    11Revision history for Perl extension LATMOS::Accounts. 
     2 
     33.0.0 
     4    - hande IPv6 addresses 
     5    - support kerberos database (heidmal) 
    26 
    372.0.0 
  • LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm

    r861 r863  
    119119            select * from ( 
    120120            select host(network(value::inet)+ (generate_series(1, broadcast(value::inet) - network(value::inet) -1))) from netzone_attributes where 
    121             attr='net' and okey = $1 
     121            attr='net' and okey = $1 and family(value::inet) = 4 
    122122            except 
    123123            ( 
  • LATMOS-Accounts/lib/LATMOS/Accounts/BuildNet.pm

    r861 r863  
    116116    if (! -d $path) { 
    117117        la_log(LA_INFO, 'Creating directory %s', $path); 
    118         make_path($path) or return; 
     118        mkpath($path) or return; 
    119119    } 
    120120    my $output = join('/', $path, $ozone->get_attributes('outputD')); 
     
    340340            nethost.ikey = nethost_attributes_ips.okey 
    341341            where value::inet <<= any(?) 
    342                 order by value, name 
     342            order by value, name 
    343343        }); 
    344344        $findhost->execute( 
     
    350350            return; 
    351351        }; 
    352         my @lists; 
     352        my %lists; 
    353353        my %names; 
    354354        # Storing all name in %names to check later if CNAME does not conflict 
    355355        while (my $res = $findhost->fetchrow_hashref) { 
    356             push(@lists, $res); 
    357             $names{$res->{name}} = 1; 
     356            $lists{$res->{name}} ||= {}; 
     357            push(@{$lists{$res->{name}}{ip}}, $res->{value}); 
    358358            my $host_o = $self->_base->get_object('nethost', $res->{name}); 
    359359            foreach (grep { $_ } $host_o->get_attributes('otherName')) { 
     
    362362        } 
    363363 
    364         foreach my $res (@lists) { 
    365             my $host_o = $self->_base->get_object('nethost', $res->{name}) or do { 
     364        foreach my $res (sort keys %lists) { 
     365            my $host_o = $self->_base->get_object('nethost', $res) or do { 
    366366                la_log LA_ERR, "Cannot fetch host %s", $res->{name}; 
    367367                return; 
     
    371371                ? '; ' . $desc . "\n" 
    372372                : ''; 
    373             $dbzone .= sprintf("%-30s IN    A     %s\n", $res->{name}, $res->{value}); 
     373            foreach my $ip (@{$lists{$res}{ip}}) { 
     374                $dbzone .= sprintf( 
     375                    "%-30s IN    %-4s     %s\n", 
     376                    $res, 
     377                    ($ip =~ /:/ ? 'AAAA' : 'A'), 
     378                    $ip 
     379                ); 
     380            } 
    374381            foreach (grep { $_ } $host_o->get_attributes('otherName')) { 
    375                 $dbzone .= sprintf("%-30s IN    A     %s\n", $_, $res->{value}); 
     382                foreach my $ip (@{$lists{$res}{ip}}) { 
     383                    $dbzone .= sprintf( 
     384                        "%-30s IN    %-4s     %s\n", 
     385                        $_, 
     386                        ($ip =~ /:/ ? 'AAAA' : 'A'), 
     387                        $ip 
     388                    ); 
     389                } 
    376390            } 
    377391            foreach (grep { $_ } $host_o->get_attributes('cname')) { 
     
    387401                    $dbzone .= "; $msg\n"; 
    388402                } else { 
    389                     $dbzone .= sprintf("%-30s IN    CNAME %s\n", $_, $res->{name},); 
     403                    $dbzone .= sprintf("%-30s IN    CNAME    %s\n", $_, $res,); 
    390404                } 
    391405            } 
  • LATMOS-Accounts/sqldata/base.sql

    r861 r863  
    148148END IF; 
    149149END;$$; 
    150  
    151  
    152 -- 
    153 -- Name: check_zone_name_unity(); Type: FUNCTION; Schema: public; Owner: - 
    154 -- 
    155  
    156 CREATE FUNCTION check_zone_name_unity() RETURNS trigger 
    157     LANGUAGE plpgsql 
    158     AS $$declare 
    159   list record; 
    160 begin 
    161  
    162 select into list * from ( 
    163 select count(*) as c, name, zone from 
    164 (select nethost.name, zone_obj.name as zone from 
    165 (select nethost_attributes_ips.okey, netzone.name from nethost_attributes_ips 
    166 join netzone_attributes on  
    167 netzone_attributes.attr='net' and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet 
    168 join netzone on netzone.ikey = netzone_attributes.okey) as zone_obj 
    169 join nethost on zone_obj.okey = nethost.ikey 
    170 union all 
    171 select nethost_attributes.value, zone_obj.name from 
    172 (select nethost_attributes_ips.okey, netzone.name from nethost_attributes_ips 
    173 join netzone_attributes on  
    174 netzone_attributes.attr='net' and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet 
    175 join netzone on netzone.ikey = netzone_attributes.okey 
    176 join netzone_attributes as nza on nza.okey = netzone.ikey and nza.attr = 'type' and nza.value = 'dns') as zone_obj 
    177 join nethost_attributes on nethost_attributes.attr = 'cname' and nethost_attributes.okey = zone_obj.okey 
    178 ) as foo 
    179 group by name, zone 
    180 ) as foo where c > 1; 
    181  
    182 IF FOUND THEN 
    183   RAISE EXCEPTION 'record name found multiple time in a zone'; 
    184 END IF; 
    185  
    186 RETURN new; 
    187 END;$$; 
    188  
    189150 
    190151-- 
     
    10661027-- 
    10671028 
    1068 CREATE TABLE nethost_attributes_ips (CONSTRAINT nethost_is_single_ip CHECK ((netmask((value)::inet) = '255.255.255.255'::inet)) 
     1029CREATE TABLE nethost_attributes_ips ( 
    10691030) 
    10701031INHERITS (nethost_attributes); 
     
    21822143-- 
    21832144 
    2184 CREATE UNIQUE INDEX nethost_cname_uniq_idx ON nethost_attributes USING btree (value, okey) WHERE (attr = 'cname'::text); 
     2145CREATE UNIQUE INDEX nethost_cname_uniq_idx ON nethost_attributes USING btree (value) WHERE (attr = 'cname'::text); 
    21852146 
    21862147 
     
    24272388 
    24282389-- 
    2429 -- Name: check_zone_name_unity_tg; Type: TRIGGER; Schema: public; Owner: - 
    2430 -- 
    2431  
    2432 CREATE TRIGGER check_zone_name_unity_tg 
    2433     AFTER INSERT OR UPDATE ON nethost 
    2434     FOR EACH STATEMENT 
    2435     EXECUTE PROCEDURE check_zone_name_unity(); 
    2436  
    2437  
    2438 -- 
    2439 -- Name: check_zone_name_unity_tg; Type: TRIGGER; Schema: public; Owner: - 
    2440 -- 
    2441  
    2442 CREATE TRIGGER check_zone_name_unity_tg 
    2443     AFTER INSERT OR UPDATE ON netzone 
    2444     FOR EACH STATEMENT 
    2445     EXECUTE PROCEDURE check_zone_name_unity(); 
    2446  
    2447  
    2448 -- 
    24492390-- Name: department_group_upd_tg; Type: TRIGGER; Schema: public; Owner: - 
    24502391-- 
Note: See TracChangeset for help on using the changeset viewer.