Changeset 1062 for branches


Ignore:
Timestamp:
07/24/12 11:18:18 (12 years ago)
Author:
nanardon
Message:
  • tag version 2.0
Location:
branches
Files:
30 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web.pm

    r861 r1062  
    2727 
    2828# Configure the application.  
    29  
    30 my $config_file = '/etc/latmos-accounts/latmos-accounts-web.yml'; 
    31 if (-r $config_file ) { 
    32     __PACKAGE__->config( 'Plugin::ConfigLoader' => {  
    33             file => $config_file  
    34         }  
    35     ); 
    36 } 
     29# 
     30# Note that settings in LATMOS::Accounts::Web.yml (or other external 
     31# configuration file that you set up manually) take precedence 
     32# over this when using ConfigLoader. Thus configuration 
     33# details given here can function as a default configuration, 
     34# with a external configuration file acting as an override for 
     35# local deployment. 
    3736 
    3837# http://stackoverflow.com/questions/1664816/is-there-a-way-to-force-c-urifor-in-catalyst-to-generate-a-uri-that-begins-wit 
  • branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Users.pm

    r861 r1062  
    7979                    if ($msg ne 'ok') { 
    8080                        $c->stash->{pmerror} = $msg . ', mot de passe inchangé'; 
    81                     } elsif ($suser && $suser->set_password($c->req->param('passwd'))) { 
     81                    } elsif ($suser && $suser->_set_password($c->req->param('passwd'))) { 
    8282                        $c->stash->{pmerror} = 'Mot de passe changé'; 
    8383                        $sync->commit; 
     
    162162            $c->stash->{db} = $base; 
    163163            $c->stash->{template} = 'users/my.tt'; 
     164            last; 
    164165        }; 
    165166        /^dump$/ and do { 
  • branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrFilter.pm

    r861 r1062  
    1919    group => [ qw(cn description gidNumber sutype) ], 
    2020    site => [ qw(l) ], 
    21     nethost => [ qw(name cname otherName ip macaddr owner serialNumber) ], 
     21    nethost => [ qw(name cname otherName ip macaddr owner) ], 
    2222    netzone => [ qw(net group type site) ], 
    2323}; 
  • branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm

    r861 r1062  
    8080    siteNick => [ 'Acronyme' ], 
    8181    serialNumber => [ 'N° de série' ], 
    82     snNative => [ 'Nom d\'origine' ], 
    83     givenNameNative => [ 'Prénom d\'origine' ], 
    84     wWWHomePage => [ 'Site Web' ], 
    85     halReference => [ 'Référence HAL' ], 
     82    user => [ 'Utilisateur' ], 
    8683}; 
    8784 
     
    114111            contratType 
    115112            expire 
    116         ) ], 
    117     }, 
    118     usermy => { 
    119         name => 'My', 
    120         attrs => [ qw( 
    121             snNative 
    122             givenNameNative 
    123             wWWHomePage 
    124             halReference 
    125113        ) ], 
    126114    }, 
     
    175163            serialNumber 
    176164            owner 
     165            user 
    177166            ip 
    178167            macaddr 
     
    498487} 
    499488 
    500 sub write_attributes { 
     489sub set_attrs { 
    501490    my ($self) = @_; 
    502     my @attrs; 
     491    $self->{c}->req->param($self->label) or return; 
     492    my $prefix = $self->{object}->id . '_'; 
     493    my %fields; 
    503494    foreach ($self->attributes) { 
    504495        my $attr = ($self->{object} 
     
    506497            : $self->base->attribute($self->otype, $_)) or next; 
    507498        $attr->readonly and next; 
    508         push(@attrs, $_); 
    509     } 
    510     @attrs; 
    511 } 
    512  
    513 sub set_attrs { 
    514     my ($self) = @_; 
    515     $self->{c}->req->param($self->label) or return; 
    516     my $prefix = $self->{object}->id . '_'; 
    517     my %fields; 
    518     foreach ($self->write_attributes) { 
    519         my $attr = ($self->{object} 
    520             ? $self->{object}->attribute($_) 
    521             : $self->base->attribute($self->otype, $_)) or next; 
    522499        if (($attrs->{$_}[1] || '') eq 'checkbox') { 
    523500            $fields{$_} = $self->{c}->req->param("$prefix$_") ? 1 : 0; 
  • branches/2.0/LATMOS-Accounts-Web/root/html/groups/index.tt

    r861 r1062  
    1010<table border="0"> 
    1111<tr><td colspan="2">[% groupslist.size %] groupes</td></tr> 
    12 <tr><th>Nom</th><th>Description</th><th></th></tr> 
     12<tr><th>Nom</th><th>Description</th></tr> 
    1313[% FOREACH groupname = groupslist %] 
    1414[% group = db.get_object('group', groupname) %] 
    1515<tr> 
    16     <td><a href="[% c.uri_for('/groups', groupname) %]"> 
    17         <img src="[% c.uri_for('/static', 'icons', 'icon_edit.png') %]" 
     16    <td>[% group.id | html %]</td> 
     17    <td>[% group.get_c_field('description') | truncate(30) | html %] 
     18    <a href="[% c.uri_for('/groups', groupname) %]"> 
     19        <img src="[% c.uri_for('/static', 'icons', 'arrow-right.png') %]" 
    1820            height="16" width="16" 
    1921            alt="[% "edit " _ groupname | html %]"> 
    20     </a> [% group.id | html %]</td> 
    21     <td> 
    22     <span title="[% group.get_c_field('description') | html %]"> 
    23     [% group.get_c_field('description') | truncate(30) | html %] 
    24     </span> 
    25     </td> 
     22    </a></td> 
    2623</tr> 
    2724[% END %] 
  • branches/2.0/LATMOS-Accounts-Web/root/html/includes/form.tt

    r861 r1062  
    1313<tr><th>[% form.attr_label(attr) %]</th><td>[% form.attr_field(attr) %]</td> 
    1414[% IF loop.last %] 
    15 [% IF form.write_attributes %] 
    1615<tr><td colspan=2>[% form.submit %]</td></tr> 
    17 [% END %] 
    1816</table> 
    1917</form> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/includes/header.tt

    r861 r1062  
    3232</span> 
    3333[% END %] 
    34  
    3534[% BLOCK user_flag %] 
    36 [% INCLUDE object_flag object = ouser %] 
    37 [% END %] 
    38  
    39 [% BLOCK object_flag %] 
    40 [% IF object.type == 'user' %] 
    41     [% IF object.get_attributes('unexported') %] 
     35[% IF ouser.get_attributes('unexported') %] 
    4236<img src="[% c.uri_for('/static', 'icons', 'gtk-delete.png') %]" 
    4337class="notice" title="Ce compte est désactivé" alt="disable"> 
    44     [% ELSIF object.get_attributes('expired') %] 
     38[% ELSIF ouser.get_attributes('expired') %] 
    4539<img src="[% c.uri_for('/static', 'icons', 'emblem-urgent.png') %]" 
    46 class="notice" title="Ce compte est expiré ([% object.get_attributes('expired') %])" alt="expired"> 
    47     [% ELSIF object.get_attributes('expire') %] 
     40class="notice" title="Ce compte est expiré ([% ouser.get_attributes('expired') %])" alt="expired"> 
     41[% ELSIF ouser.get_attributes('expire') %] 
    4842<img src="[% c.uri_for('/static', 'icons', 'appointment-new.png') %]" 
    49 class="notice" title="Ce compte est temporaire ([% object.get_attributes('expire') %])" alt="temporary"> 
    50     [% END %] 
    51 [% ELSE %] 
    52     [% IF object.get_attributes('unexported') %] 
    53 <img src="[% c.uri_for('/static', 'icons', 'gtk-delete.png') %]" 
    54 class="notice" title="Cette entrée est désactivés" alt="disable"> 
    55     [% END %] 
     43class="notice" title="Ce compte est temporaire ([% ouser.get_attributes('expire') %])" alt="temporary"> 
    5644[% END %] 
    5745[% END %] 
     
    6149<div id="head"> 
    6250    <div class="pmenu"> 
    63         [% IF c.config.company %] 
    64         Gestion informatique - [% c.config.company | html %] 
    65         [% ELSE %] 
    66         Gestion informatique 
    67         [% END %] 
     51        Gestion informatique du LATMOS 
    6852    [% IF c.user.username %] 
    6953    <span style="float:right; font-size: 0.5em;"> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/nethosts/default.tt

    r861 r1062  
    1 <!-- $Id: default.tt 3673 2010-09-17 16:57:32Z nanardon $ --> 
     1<!-- $Id: default.tt 3055 2010-08-20 17:34:56Z nanardon $ --> 
    22[% IF NOT nethost %] 
    33No group [% nethostname | html %] found. 
     
    2424[% END %] 
    2525 
     26[% IF c.model('Accounts').db.check_acl('nethost', 'ip', 'w') %] 
     27<tr><th>Ajouter une ip libre:</th> 
    2628<tr><td> 
    27 [% IF c.model('Accounts').db.check_acl('nethost', 'ip', 'w') %] 
    28 <fieldset> 
    29 <legend>Ajouter une ip libre:</legend> 
    3029<form action="[% c.uri_for(nethostname) %]" method="POST"> 
    3130<label  for="zone">Zone:</label> <select name="zone" id="zone"> 
     
    4847<input type="submit" name="addip"> 
    4948</form> 
    50 </fieldset> 
     49</td></tr> 
    5150[% END %] 
    5251 
    5352[% IF c.model('Accounts').db.check_acl('nethost', '@CREATE', 'w') %] 
    54 <fieldset><legend>Renommer la machine en:</legend> 
     53<tr><th>Renommer la machine en:</th></tr> 
     54<tr><td> 
    5555<form action="[% c.uri_for(nethostname) %]" method="POST"> 
    5656<input type="text" name="to"><br> 
     
    5959<input type="submit" name="rename"> 
    6060</form> 
    61 </fieldset> 
     61</td></tr> 
    6262[% END %] 
    6363 
     
    7575// --> 
    7676</script> 
    77 <fieldset> 
    78 <legend>Supprimer cet hÃŽte</legend> 
     77<tr><th>Supprimer cet hÃŽte</th></tr> 
     78<tr><td> 
    7979<form action="[% c.uri_for(nethostname) %]" method="POST" onsubmit="return confirmSubmit()"> 
    80 <input type="image" name="delete" value="Supprimer" title="Supprimer" alt="effacer" src="[% 
    81 c.uri_for('/static', 'images', 'edit-delete.png') %]"> 
    82 <input type="hidden" name="delete" value="Supprimer"> 
     80<input type="submit" name="delete" value="Supprimer"> 
    8381</form> 
    84 </fieldset> 
     82</td></tr> 
    8583[% END %] 
    8684 
    87 </td></tr> 
    8885</table> 
    8986</div> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/nethosts/index.tt

    r861 r1062  
    99 
    1010<table border="0"> 
    11 <tr><td colspan="3"> 
     11<tr><td colspan="2"> 
    1212[% IF initials %] 
    1313Pages: 
     
    2222[% END %] 
    2323</td></tr> 
    24 <tr><td></td><th>Nom</th><th>Description</th></tr> 
     24<tr><th>Nom</th><th>Description</th></tr> 
    2525[% FOREACH nethostname = nethostlist %] 
    2626[% nethost = db.get_object('nethost', nethostname) %] 
    2727<tr> 
     28    <td>[% nethostname | html %]</td> 
    2829    <td> 
    29 [% INCLUDE 'object_flag' object=nethost %] 
    30     </td> 
    31     <td> 
    32     <a href="[% c.uri_for('/nethosts', nethostname) %]"> 
    33     <img src="[% c.uri_for('/static', 'icons', 'icon_edit.png') %]" 
    34       height="16" width="16" 
    35       alt="[% "edit " _ nethostname | html %]"> 
    36     </a>[% username | html %] 
    37     [% nethostname | html %] 
    3830    [% IF nethost.get_attributes('owner') %] 
    3931    (<a href="[% c.uri_for('/users', nethost.get_attributes('owner')) %]">[% nethost.get_attributes('owner') %]</a>) 
    4032    [% END %] 
    41     </td> 
    42     <td> 
    43     <span title="[% nethost.get_attributes('description') | html %]"> 
    4433    [% nethost.get_attributes('description') | truncate(20) | html %] 
    45     </span> 
    46     </td> 
     34    <a href="[% c.uri_for('/nethosts', nethostname) %]"> 
     35        <img src="[% c.uri_for('/static', 'icons', 'arrow-right.png') %]" 
     36            height="16" width="16" 
     37            alt="[% "edit " _ nethostname | html %]"> 
     38    </a></td> 
    4739</tr> 
    4840[% END %] 
  • branches/2.0/LATMOS-Accounts-Web/root/html/netzones/default.tt

    r861 r1062  
    1 <!-- $Id: default.tt 3673 2010-09-17 16:57:32Z nanardon $ --> 
     1<!-- $Id: default.tt 2902 2010-08-07 13:49:21Z nanardon $ --> 
    22[% IF NOT netzone %] 
    33No group [% netzonename | html %] found. 
     
    2222<td> 
    2323[% END %] 
    24 [% ohost = c.model('Accounts').db.get_object('nethost', host) %] 
    2524<a href="[% c.uri_for('/nethosts', host) %]">[% host | html %]</a><br> 
    26 [% INCLUDE object_flag object = ohost %] 
    2725[% IF loop.last %] 
    2826</td> 
     
    3836<td> 
    3937[% END %] 
    40 [% ohost = c.model('Accounts').db.get_object('nethost', host) %] 
    41 <a href="[% c.uri_for('/nethosts', host) %]">[% host | html %]</a> 
    42 [% INCLUDE object_flag object = ohost %] 
    43 <br> 
     38<a href="[% c.uri_for('/nethosts', host) %]">[% host | html %]</a><br> 
    4439[% IF loop.last %] 
    4540</td></tr> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/netzones/index.tt

    r861 r1062  
    1818    <td> 
    1919    <a href="[% c.uri_for('/netzones', netzonename) %]"> 
    20         <img src="[% c.uri_for('/static', 'icons', 'icon_edit.png') %]" 
     20        <img src="[% c.uri_for('/static', 'icons', 'arrow-right.png') %]" 
    2121            height="16" width="16" 
    2222            alt="[% "edit " _ netzonename | html %]"> 
     
    3333[% netzonelist = db.search_objects('netzone', 'type=' _ netztype) %] 
    3434[% FOREACH netzonename = netzonelist.sort %] 
    35 [% netzone = db.get_object('netzone', netzonename) %] 
    3635[% IF loop.first %] 
    37 <tr><th colspan="2">[% netztype | ucfirst | html %]</th></tr> 
    38 <tr><th>Nom</th><th>Description</th></tr> 
     36<table> 
     37<tr><th colspan="2">[% netztype | html %]</th></tr> 
    3938[% END %] 
    4039<tr> 
     40    <td>[% netzonename | html %]</td> 
    4141    <td> 
    4242    <a href="[% c.uri_for('/netzones', netzonename) %]"> 
    43         <img src="[% c.uri_for('/static', 'icons', 'icon_edit.png') %]" 
     43        <img src="[% c.uri_for('/static', 'icons', 'arrow-right.png') %]" 
    4444            height="16" width="16" 
    4545            alt="[% "edit " _ netzonename | html %]"> 
    46         </a> 
    47         [% netzonename | html %] 
    48     </td> 
    49     <td> 
    50         <span title="[% netzone.get_c_field('description') | html %]"> 
    51         [% netzone.get_c_field('description') | truncate(20) | html %] 
    52         </span> 
    53     </td> 
     46    </a></td> 
    5447</tr> 
    5548[% IF loop.last %] 
     49</table> 
    5650[% END %] 
    5751[% END %] 
  • branches/2.0/LATMOS-Accounts-Web/root/html/users/address.tt

    r861 r1062  
    2020</form> 
    2121 
    22 [% IF address.base.check_acl(address, '@DELETE', 'w') %] 
    2322<table border=1><tr><td align="center"> 
    2423<form action="[% c.uri_for(username, subform) %]" method="POST"> 
     
    2928</form> 
    3029</td></tr></table> 
    31 [% END %] 
    3230 
    3331</div> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/users/address_form.tt

    r861 r1062  
    6363    <td>[% form.attr_field('co', fieldtype) %]</td> 
    6464</tr> 
    65 [% IF form.write_attributes %] 
    6665<tr> 
    6766    <th></th> 
    68     <td> 
    69     [% form.submit %] 
    70     </td> 
     67    <td>[% form.submit %]</td> 
    7168</tr> 
    72 [% END %] 
    7369</table> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/users/index.tt

    r861 r1062  
    99 
    1010<table border="0"> 
    11 <tr><td colspan="5"> 
     11<tr><td colspan="3"> 
    1212[% IF initials %] 
    1313Pages:  
     
    2222[% END %] 
    2323</td></tr> 
    24 <tr><td></td><th>Login</th><th>Nom</th><th>Description</th><th>Mail</th></tr> 
     24<tr><td></td><th>Login</th><th>Nom</th></tr> 
    2525[% FOREACH username = userslist %] 
    2626[% user = db.get_object('user', username) %] 
     
    2929[% INCLUDE 'user_flag' ouser=user %] 
    3030    </td> 
    31     <td><a href="[% c.uri_for('/users', username) %]"> 
    32         <img src="[% c.uri_for('/static', 'icons', 'icon_edit.png') %]" 
    33             height="16" width="16" 
    34             alt="[% "edit " _ username | html %]"> 
    35     </a>[% username | html %]</td> 
     31    <td>[% username | html %]</td> 
    3632    <td> 
    3733        [% user.get_c_field('sn') | html %] 
    3834        [% user.get_c_field('givenName') | html %] 
    39    </td> 
    40     <td> 
    41     <span title="[% user.get_c_field('description') | html %]">     
    42     [% user.get_c_field('description') | truncate(20) | html %] 
    43     </span> 
    44    </td> 
    45     <td><span title="[% user.get_c_field('mail') | html %]"> 
    46     [% user.get_c_field('mail') | truncate(20) | html %]</span> 
    47    </td> 
     35        [% user.get_c_field('description') | truncate(20) | html %] 
     36    <a href="[% c.uri_for('/users', username) %]"> 
     37        <img src="[% c.uri_for('/static', 'icons', 'arrow-right.png') %]" 
     38            height="16" width="16" 
     39            alt="[% "edit " _ username | html %]"> 
     40    </a></td> 
    4841</tr> 
    4942[% END %] 
  • branches/2.0/LATMOS-Accounts-Web/root/html/users/my.tt

    r861 r1062  
    1 <!-- $Id: my.tt 7943 2011-11-10 15:33:13Z nanardon $ --> 
     1<!-- $Id: my.tt 3103 2010-08-26 12:47:15Z nanardon $ --> 
    22[% IF NOT user %] 
    33No user [% username | html %] found. 
     
    66<div id="objectform" class="objectform"> 
    77[% INCLUDE 'users/menu.tt' %] 
    8  
    9 [% INCLUDE 'includes/form.tt' 
    10     form = form 
    11     form_uri = c.uri_for(username, subform) %] 
    128 
    139<div class="oform"> 
  • branches/2.0/LATMOS-Accounts-Web/root/html/users/passwd.tt

    r861 r1062  
    33[% INCLUDE 'users/menu.tt' %] 
    44 
    5 <script type="text/javascript"> 
    6 function check_passwd() { 
    7     new Ajax.Updater( 
    8         'perror', 
    9         '[% c.uri_for('/ajax', 'cracklib', username) %]', 
    10         { parameters: 'passwd=' + document.getElementById("passwd").value + 
    11             '&cpasswd=' + document.getElementById("cpasswd").value } 
    12     ) 
    13 } 
    14 </script> 
    15  
    165<div id="oform"> 
    176[% IF c.model('Accounts').db.check_acl(user, 'userPassword', 'w') %] 
    187<form id="fpasswd" action="[% c.uri_for(username, subform) %]" method="POST"> 
     8[% c.prototype.observe_form('fpasswd', { 
     9    url => c.uri_for('/ajax', 'cracklib', username), 
     10    update => 'perror', 
     11    frequency => 1, 
     12}) %] 
    1913<table border="1"> 
    2014<tr> 
    2115<th>Nouveau mot de passe:</th> 
    22 <td><input type="password" name="passwd" id="passwd" onkeyup="check_passwd()"></td> 
     16<td><input type="password" name="passwd"></td> 
    2317</tr> 
    2418<tr> 
    2519<th>Confirmation:</th> 
    26 <td><input type="password" name="cpasswd" id="cpasswd" onkeyup="check_passwd()"></td> 
     20<td><input type="password" name="cpasswd"></td> 
    2721</tr> 
    2822<tr><td colspan="2"><span id="perror">[% pmerror | html %]</span></td></tr> 
  • branches/2.0/LATMOS-Accounts/bin/la-rename

    r861 r1062  
    3636Modify object having type 'otype', default is user 
    3737 
    38 =item -t|--test 
    39  
    40 Don't change the password but check its validity using CrackLib. 
    41  
    4238=back 
    4339 
  • branches/2.0/LATMOS-Accounts/bin/la-sync-manager

    r861 r1062  
    8787    local $SIG{HUP} = 'IGNORE'; 
    8888    if ($retpid) { 
    89         my $res = $? << 8; 
     89        my $res = $? >> 8; 
    9090        if ($res) { 
    9191            la_log LA_ERR, "Sync process exit with $res"; 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts.pm

    r861 r1062  
    148148    my ($self, $section) = @_; 
    149149    # this method perform a cache 
    150     $self->_load_base($section); 
     150    $self->_load_base($section || $self->default_base_name); 
    151151} 
    152152 
     
    171171sub default_base { 
    172172    my ($self) = @_; 
    173     my $default = $self->default_base_name or return; 
    174     $self->base($default); 
     173    $self->base(); 
    175174} 
    176175 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm

    r861 r1062  
    187187sub is_supported_object { 
    188188    my ($self, $otype) = @_; 
    189     return $self->_load_obj_class($otype) ? 1 : 0; 
     189     
     190    if (my $pclass = $self->_load_obj_class($otype)) { 
     191        if ($pclass->can('is_supported')) { 
     192            return $pclass->is_supported($self); 
     193        } else { 
     194            return 1; 
     195        } 
     196    } else { 
     197        return 0; 
     198    } 
    190199} 
    191200 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Heimdal/User.pm

    r861 r1062  
    3838        uid 
    3939        modName 
     40        userPassword 
    4041            )) { 
    4142        $info->{$_} = { ro => 1 }; 
     
    158159        /krb5MaxRenew/ and return $self->{entry}->getMaxRenewableLife(); 
    159160        /krb5MaxLife/ and return $self->{entry}->getMaxLife(); 
     161        /userPassword/ and return ''; 
    160162    } 
    161163 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ldap/Onlyaddress.pm

    r861 r1062  
    5454        givenName => {}, 
    5555        initials => {}, 
    56         mail => {}, 
     56        # mail => {}, 
    5757        sn => {}, 
    5858        mobile => {}, 
     
    7575        objectClass => { ro => 1 }, 
    7676    } 
     77} 
     78 
     79sub is_supported { 
     80    my ($class, $base) = @_; 
     81    return $base->param('onlyaddress_container') ? 1 : 0; 
    7782} 
    7883 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm

    r861 r1062  
    1414 
    1515our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 
     16 
     17my $SCHEMA_VERSION = 3; 
    1618 
    1719=head1 NAME 
     
    9395sub load { 
    9496    my ($self) = @_; 
    95     return $self->db ? 1 : 0;     
     97    if (!$self->db) { return 0 }; 
     98 
     99    my $sv = $self->get_global_value('schema_version') || 1; 
     100    if ($sv < $SCHEMA_VERSION) { 
     101        $self->log(LA_CRIT, 
     102            "Schema version %d found, %d is need, please update db using " . 
     103            "`la-sql-upgrade' tool for `%s' base", 
     104            $sv, 
     105            $SCHEMA_VERSION, 
     106            $self->label, 
     107        ); 
     108        # return; 
     109    } 
     110 
     111    1; 
    96112} 
    97113 
     
    317333} 
    318334 
     335sub check_user_manager { 
     336    $_[0]->_handle_by_unexported('user', 'manager', 'active'); 
     337} 
     338 
     339sub check_group_manager { 
     340    $_[0]->_handle_by_unexported('group', 'managedBy'); 
     341} 
     342 
     343sub check_nethost_owner { 
     344    $_[0]->_handle_by_unexported('nethost', 'owner', 'active'); 
     345} 
     346 
     347sub _handle_by_unexported { 
     348    my ($self, $otype, $refattr, $chkattr) = @_; 
     349 
     350    my $ptrotype = $self->attribute($otype, $refattr)->reference(); 
     351 
     352    my %unhandle; 
     353    foreach my $objname ($self->search_objects($otype, 'active=1', 'exported=1', "$refattr=*")) { 
     354        my $obj = $self->get_object($otype, $objname) or next; 
     355        my $val = $obj->get_attributes($refattr) or next; 
     356        if (my $refobj = $self->get_object($ptrotype, $val)) { 
     357            if (!$refobj->get_attributes($chkattr || 'exported')) { 
     358                $unhandle{$objname} = $val; 
     359            } 
     360        } else { 
     361            $unhandle{$objname} = $val; 
     362        } 
     363    } 
     364    %unhandle; 
     365} 
     366 
    3193671; 
    320368 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm

    r861 r1062  
    8282            }, 
    8383            owner   => {  
     84                reference => 'user', 
     85                delayed => 1, 
     86            }, 
     87            user   => {  
    8488                reference => 'user', 
    8589                delayed => 1, 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm

    r861 r1062  
    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            ( 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm

    r861 r1062  
    5050    $class->SUPER::_get_attr_schema($base, 
    5151        { 
    52             uidNumber => { inline => 1, iname => 'uidnumber', uniq => 1, 
    53                 mandatory => 1, }, 
     52            uidNumber => { 
     53                inline => 1, 
     54                iname => 'uidnumber', 
     55                uniq => 1, 
     56                mandatory => 1, 
     57                formopts => { length => 7 }, 
     58            }, 
    5459            uidnumber => { inline => 1, hide => 1, }, 
    5560            gidNumber => {  
     
    308313    } elsif ($field eq 'otheraddress') { 
    309314        my $sth = $self->db->prepare_cached(q{ 
    310             select name from address where "user" = ? 
     315            select name from address left join address_attributes 
     316            on address.ikey = address_attributes.okey and 
     317            address_attributes.attr = 'isMainAddress' 
     318            where "user" = ? 
     319            order by address_attributes.attr 
    311320        }); 
    312321        $sth->execute($self->id); 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/BuildNet.pm

    r861 r1062  
    1313use File::Path; 
    1414use File::Temp qw(tempfile); 
     15use Net::IPv4Addr; 
     16use Net::IPv6Addr; 
    1517 
    1618sub _base { 
     
    116118    if (! -d $path) { 
    117119        la_log(LA_INFO, 'Creating directory %s', $path); 
    118         make_path($path) or return; 
     120        mkpath($path) or return; 
    119121    } 
    120122    my $output = join('/', $path, $ozone->get_attributes('outputD')); 
     
    340342            nethost.ikey = nethost_attributes_ips.okey 
    341343            where value::inet <<= any(?) 
    342                 order by value, name 
     344            order by value, name 
    343345        }); 
    344346        $findhost->execute( 
     
    350352            return; 
    351353        }; 
    352         my @lists; 
     354        my %lists; 
    353355        my %names; 
    354356        # Storing all name in %names to check later if CNAME does not conflict 
    355357        while (my $res = $findhost->fetchrow_hashref) { 
    356             push(@lists, $res); 
    357             $names{$res->{name}} = 1; 
     358            $lists{$res->{name}} ||= {}; 
     359            push(@{$lists{$res->{name}}{ip}}, $res->{value}); 
    358360            my $host_o = $self->_base->get_object('nethost', $res->{name}); 
    359361            foreach (grep { $_ } $host_o->get_attributes('otherName')) { 
     
    362364        } 
    363365 
    364         foreach my $res (@lists) { 
    365             my $host_o = $self->_base->get_object('nethost', $res->{name}) or do { 
     366        foreach my $res (sort keys %lists) { 
     367            my $host_o = $self->_base->get_object('nethost', $res) or do { 
    366368                la_log LA_ERR, "Cannot fetch host %s", $res->{name}; 
    367369                return; 
     
    371373                ? '; ' . $desc . "\n" 
    372374                : ''; 
    373             $dbzone .= sprintf("%-30s IN    A     %s\n", $res->{name}, $res->{value}); 
     375            foreach my $ip (@{$lists{$res}{ip}}) { 
     376                $dbzone .= sprintf( 
     377                    "%-30s IN    %-4s     %s\n", 
     378                    $res, 
     379                    ($ip =~ /:/ ? 'AAAA' : 'A'), 
     380                    $ip 
     381                ); 
     382            } 
    374383            foreach (grep { $_ } $host_o->get_attributes('otherName')) { 
    375                 $dbzone .= sprintf("%-30s IN    A     %s\n", $_, $res->{value}); 
     384                foreach my $ip (@{$lists{$res}{ip}}) { 
     385                    $dbzone .= sprintf( 
     386                        "%-30s IN    %-4s     %s\n", 
     387                        $_, 
     388                        ($ip =~ /:/ ? 'AAAA' : 'A'), 
     389                        $ip 
     390                    ); 
     391                } 
    376392            } 
    377393            foreach (grep { $_ } $host_o->get_attributes('cname')) { 
     
    387403                    $dbzone .= "; $msg\n"; 
    388404                } else { 
    389                     $dbzone .= sprintf("%-30s IN    CNAME %s\n", $_, $res->{name},); 
     405                    $dbzone .= sprintf("%-30s IN    CNAME    %s\n", $_, $res,); 
    390406                } 
    391407            } 
     
    456472                ? '; ' . $desc . "\n" 
    457473                : ''; 
    458             my @ippart = split(/\./, $res->{value}); 
    459             splice(@ippart, 0, $mask/8); # get rid of start of ip 
    460             my @nippart; 
    461             while (@ippart) { unshift(@nippart, shift(@ippart)) } 
    462             $dbzone .= sprintf("%-12s IN    PTR    %s%s\n", join('.', @nippart), 
     474            my $revip; 
     475            my $fmt; 
     476            if ($res->{value} =~ /:/) { 
     477                # IPv6 
     478                my $m = $mask/4; 
     479                $revip = Net::IPv6Addr->new($res->{value})->to_string_ip6_int; 
     480                $revip =~ s/\.([0-9,a-f]\.?){$m}\.IP6\.INT\.$//i; 
     481                $fmt = "%-72s IN    PTR    %s%s\n"; 
     482            } else { 
     483                # ipv4 
     484                my @ippart = split(/\./, $res->{value}); 
     485                splice(@ippart, 0, $mask/8); # get rid of start of ip 
     486                my @nippart; 
     487                while (@ippart) { unshift(@nippart, shift(@ippart)) } 
     488                $revip = join('.', @nippart); 
     489                $fmt = "%-12s IN    PTR    %s%s\n"; 
     490            } 
     491            $dbzone .= sprintf($fmt, $revip, 
    463492                $reverse  
    464493                    ? ($reverse, '.') 
  • branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Maintenance.pm

    r861 r1062  
    8484        my %mail = ( 
    8585            From => $self->val('_default_', 'mailFrom', 'nomail@localhost'), 
    86             Subject => 'LATMOS Expire in ' . $user->{delay} . 'days', 
     86            Subject => sprintf('Account %s Expire in %s days', $user->{name}, $user->{delay}), 
    8787            smtp => $self->val('_default_', 'smtp'), 
    8888            'Content-Type' => 'text/plain; charset=utf-8', 
     
    293293} 
    294294 
    295 sub generate_rsa_key { 
    296     # compat functions 
    297     my ($self, $password) = @_; 
    298     $self->_base->generate_rsa_key($password); 
    299 } 
    300  
    301  
    302 sub store_rsa_key { 
    303     # compat functions 
    304     my ($self, $public, $private) = @_; 
    305     $self->_base->store_rsa_key($public, $private); 
    306 } 
    307  
    308 sub private_key { 
    309     # compat functions 
    310     my ($self, $password) = @_; 
    311     $self->_base->private_key($password); 
    312 } 
    313  
    314 sub get_rsa_password { 
    315     # compat functions 
    316     my ($self) = @_; 
    317     $self->_base->get_rsa_password; 
    318 } 
    319  
    3202951; 
  • branches/2.0/LATMOS-Accounts/sqldata/base.sql

    r861 r1062  
    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-- 
  • branches/3.0/LATMOS-Accounts/sqldata/base.sql

    r863 r1062  
    30813081-- 
    30823082 
     3083INSERT INTO settings (varname, val) VALUES ('schema_version', '3'); 
     3084 
Note: See TracChangeset for help on using the changeset viewer.