Changeset 1062 for branches/2.0
- Timestamp:
- 07/24/12 11:18:18 (12 years ago)
- Location:
- branches/2.0
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web.pm
r861 r1062 27 27 28 28 # 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. 37 36 38 37 # 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 79 79 if ($msg ne 'ok') { 80 80 $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'))) { 82 82 $c->stash->{pmerror} = 'Mot de passe changé'; 83 83 $sync->commit; … … 162 162 $c->stash->{db} = $base; 163 163 $c->stash->{template} = 'users/my.tt'; 164 last; 164 165 }; 165 166 /^dump$/ and do { -
branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrFilter.pm
r861 r1062 19 19 group => [ qw(cn description gidNumber sutype) ], 20 20 site => [ qw(l) ], 21 nethost => [ qw(name cname otherName ip macaddr owner serialNumber) ],21 nethost => [ qw(name cname otherName ip macaddr owner) ], 22 22 netzone => [ qw(net group type site) ], 23 23 }; -
branches/2.0/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Model/AttrForms.pm
r861 r1062 80 80 siteNick => [ 'Acronyme' ], 81 81 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' ], 86 83 }; 87 84 … … 114 111 contratType 115 112 expire 116 ) ],117 },118 usermy => {119 name => 'My',120 attrs => [ qw(121 snNative122 givenNameNative123 wWWHomePage124 halReference125 113 ) ], 126 114 }, … … 175 163 serialNumber 176 164 owner 165 user 177 166 ip 178 167 macaddr … … 498 487 } 499 488 500 sub write_attributes {489 sub set_attrs { 501 490 my ($self) = @_; 502 my @attrs; 491 $self->{c}->req->param($self->label) or return; 492 my $prefix = $self->{object}->id . '_'; 493 my %fields; 503 494 foreach ($self->attributes) { 504 495 my $attr = ($self->{object} … … 506 497 : $self->base->attribute($self->otype, $_)) or next; 507 498 $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;522 499 if (($attrs->{$_}[1] || '') eq 'checkbox') { 523 500 $fields{$_} = $self->{c}->req->param("$prefix$_") ? 1 : 0; -
branches/2.0/LATMOS-Accounts-Web/root/html/groups/index.tt
r861 r1062 10 10 <table border="0"> 11 11 <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> 13 13 [% FOREACH groupname = groupslist %] 14 14 [% group = db.get_object('group', groupname) %] 15 15 <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') %]" 18 20 height="16" width="16" 19 21 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> 26 23 </tr> 27 24 [% END %] -
branches/2.0/LATMOS-Accounts-Web/root/html/includes/form.tt
r861 r1062 13 13 <tr><th>[% form.attr_label(attr) %]</th><td>[% form.attr_field(attr) %]</td> 14 14 [% IF loop.last %] 15 [% IF form.write_attributes %]16 15 <tr><td colspan=2>[% form.submit %]</td></tr> 17 [% END %]18 16 </table> 19 17 </form> -
branches/2.0/LATMOS-Accounts-Web/root/html/includes/header.tt
r861 r1062 32 32 </span> 33 33 [% END %] 34 35 34 [% 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') %] 42 36 <img src="[% c.uri_for('/static', 'icons', 'gtk-delete.png') %]" 43 37 class="notice" title="Ce compte est désactivé" alt="disable"> 44 [% ELSIF object.get_attributes('expired') %]38 [% ELSIF ouser.get_attributes('expired') %] 45 39 <img src="[% c.uri_for('/static', 'icons', 'emblem-urgent.png') %]" 46 class="notice" title="Ce compte est expiré ([% o bject.get_attributes('expired') %])" alt="expired">47 [% ELSIF object.get_attributes('expire') %]40 class="notice" title="Ce compte est expiré ([% ouser.get_attributes('expired') %])" alt="expired"> 41 [% ELSIF ouser.get_attributes('expire') %] 48 42 <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 %] 43 class="notice" title="Ce compte est temporaire ([% ouser.get_attributes('expire') %])" alt="temporary"> 56 44 [% END %] 57 45 [% END %] … … 61 49 <div id="head"> 62 50 <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 68 52 [% IF c.user.username %] 69 53 <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 3 673 2010-09-17 16:57:32Z nanardon $ -->1 <!-- $Id: default.tt 3055 2010-08-20 17:34:56Z nanardon $ --> 2 2 [% IF NOT nethost %] 3 3 No group [% nethostname | html %] found. … … 24 24 [% END %] 25 25 26 [% IF c.model('Accounts').db.check_acl('nethost', 'ip', 'w') %] 27 <tr><th>Ajouter une ip libre:</th> 26 28 <tr><td> 27 [% IF c.model('Accounts').db.check_acl('nethost', 'ip', 'w') %]28 <fieldset>29 <legend>Ajouter une ip libre:</legend>30 29 <form action="[% c.uri_for(nethostname) %]" method="POST"> 31 30 <label for="zone">Zone:</label> <select name="zone" id="zone"> … … 48 47 <input type="submit" name="addip"> 49 48 </form> 50 </ fieldset>49 </td></tr> 51 50 [% END %] 52 51 53 52 [% 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> 55 55 <form action="[% c.uri_for(nethostname) %]" method="POST"> 56 56 <input type="text" name="to"><br> … … 59 59 <input type="submit" name="rename"> 60 60 </form> 61 </ fieldset>61 </td></tr> 62 62 [% END %] 63 63 … … 75 75 // --> 76 76 </script> 77 < fieldset>78 < legend>Supprimer cet hÃŽte</legend>77 <tr><th>Supprimer cet hÃŽte</th></tr> 78 <tr><td> 79 79 <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"> 83 81 </form> 84 </ fieldset>82 </td></tr> 85 83 [% END %] 86 84 87 </td></tr>88 85 </table> 89 86 </div> -
branches/2.0/LATMOS-Accounts-Web/root/html/nethosts/index.tt
r861 r1062 9 9 10 10 <table border="0"> 11 <tr><td colspan=" 3">11 <tr><td colspan="2"> 12 12 [% IF initials %] 13 13 Pages: … … 22 22 [% END %] 23 23 </td></tr> 24 <tr><t d></td><th>Nom</th><th>Description</th></tr>24 <tr><th>Nom</th><th>Description</th></tr> 25 25 [% FOREACH nethostname = nethostlist %] 26 26 [% nethost = db.get_object('nethost', nethostname) %] 27 27 <tr> 28 <td>[% nethostname | html %]</td> 28 29 <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 %]38 30 [% IF nethost.get_attributes('owner') %] 39 31 (<a href="[% c.uri_for('/users', nethost.get_attributes('owner')) %]">[% nethost.get_attributes('owner') %]</a>) 40 32 [% END %] 41 </td>42 <td>43 <span title="[% nethost.get_attributes('description') | html %]">44 33 [% 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> 47 39 </tr> 48 40 [% 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 $ --> 2 2 [% IF NOT netzone %] 3 3 No group [% netzonename | html %] found. … … 22 22 <td> 23 23 [% END %] 24 [% ohost = c.model('Accounts').db.get_object('nethost', host) %]25 24 <a href="[% c.uri_for('/nethosts', host) %]">[% host | html %]</a><br> 26 [% INCLUDE object_flag object = ohost %]27 25 [% IF loop.last %] 28 26 </td> … … 38 36 <td> 39 37 [% 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> 44 39 [% IF loop.last %] 45 40 </td></tr> -
branches/2.0/LATMOS-Accounts-Web/root/html/netzones/index.tt
r861 r1062 18 18 <td> 19 19 <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') %]" 21 21 height="16" width="16" 22 22 alt="[% "edit " _ netzonename | html %]"> … … 33 33 [% netzonelist = db.search_objects('netzone', 'type=' _ netztype) %] 34 34 [% FOREACH netzonename = netzonelist.sort %] 35 [% netzone = db.get_object('netzone', netzonename) %]36 35 [% IF loop.first %] 37 <t r><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> 39 38 [% END %] 40 39 <tr> 40 <td>[% netzonename | html %]</td> 41 41 <td> 42 42 <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') %]" 44 44 height="16" width="16" 45 45 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> 54 47 </tr> 55 48 [% IF loop.last %] 49 </table> 56 50 [% END %] 57 51 [% END %] -
branches/2.0/LATMOS-Accounts-Web/root/html/users/address.tt
r861 r1062 20 20 </form> 21 21 22 [% IF address.base.check_acl(address, '@DELETE', 'w') %]23 22 <table border=1><tr><td align="center"> 24 23 <form action="[% c.uri_for(username, subform) %]" method="POST"> … … 29 28 </form> 30 29 </td></tr></table> 31 [% END %]32 30 33 31 </div> -
branches/2.0/LATMOS-Accounts-Web/root/html/users/address_form.tt
r861 r1062 63 63 <td>[% form.attr_field('co', fieldtype) %]</td> 64 64 </tr> 65 [% IF form.write_attributes %]66 65 <tr> 67 66 <th></th> 68 <td> 69 [% form.submit %] 70 </td> 67 <td>[% form.submit %]</td> 71 68 </tr> 72 [% END %]73 69 </table> -
branches/2.0/LATMOS-Accounts-Web/root/html/users/index.tt
r861 r1062 9 9 10 10 <table border="0"> 11 <tr><td colspan=" 5">11 <tr><td colspan="3"> 12 12 [% IF initials %] 13 13 Pages: … … 22 22 [% END %] 23 23 </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> 25 25 [% FOREACH username = userslist %] 26 26 [% user = db.get_object('user', username) %] … … 29 29 [% INCLUDE 'user_flag' ouser=user %] 30 30 </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> 36 32 <td> 37 33 [% user.get_c_field('sn') | html %] 38 34 [% 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> 48 41 </tr> 49 42 [% 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 $ --> 2 2 [% IF NOT user %] 3 3 No user [% username | html %] found. … … 6 6 <div id="objectform" class="objectform"> 7 7 [% INCLUDE 'users/menu.tt' %] 8 9 [% INCLUDE 'includes/form.tt'10 form = form11 form_uri = c.uri_for(username, subform) %]12 8 13 9 <div class="oform"> -
branches/2.0/LATMOS-Accounts-Web/root/html/users/passwd.tt
r861 r1062 3 3 [% INCLUDE 'users/menu.tt' %] 4 4 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 16 5 <div id="oform"> 17 6 [% IF c.model('Accounts').db.check_acl(user, 'userPassword', 'w') %] 18 7 <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 }) %] 19 13 <table border="1"> 20 14 <tr> 21 15 <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> 23 17 </tr> 24 18 <tr> 25 19 <th>Confirmation:</th> 26 <td><input type="password" name="cpasswd" id="cpasswd" onkeyup="check_passwd()"></td>20 <td><input type="password" name="cpasswd"></td> 27 21 </tr> 28 22 <tr><td colspan="2"><span id="perror">[% pmerror | html %]</span></td></tr> -
branches/2.0/LATMOS-Accounts/bin/la-rename
r861 r1062 36 36 Modify object having type 'otype', default is user 37 37 38 =item -t|--test39 40 Don't change the password but check its validity using CrackLib.41 42 38 =back 43 39 -
branches/2.0/LATMOS-Accounts/bin/la-sync-manager
r861 r1062 87 87 local $SIG{HUP} = 'IGNORE'; 88 88 if ($retpid) { 89 my $res = $? <<8;89 my $res = $? >> 8; 90 90 if ($res) { 91 91 la_log LA_ERR, "Sync process exit with $res"; -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts.pm
r861 r1062 148 148 my ($self, $section) = @_; 149 149 # this method perform a cache 150 $self->_load_base($section );150 $self->_load_base($section || $self->default_base_name); 151 151 } 152 152 … … 171 171 sub default_base { 172 172 my ($self) = @_; 173 my $default = $self->default_base_name or return; 174 $self->base($default); 173 $self->base(); 175 174 } 176 175 -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases.pm
r861 r1062 187 187 sub is_supported_object { 188 188 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 } 190 199 } 191 200 -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Heimdal/User.pm
r861 r1062 38 38 uid 39 39 modName 40 userPassword 40 41 )) { 41 42 $info->{$_} = { ro => 1 }; … … 158 159 /krb5MaxRenew/ and return $self->{entry}->getMaxRenewableLife(); 159 160 /krb5MaxLife/ and return $self->{entry}->getMaxLife(); 161 /userPassword/ and return ''; 160 162 } 161 163 -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Ldap/Onlyaddress.pm
r861 r1062 54 54 givenName => {}, 55 55 initials => {}, 56 mail => {},56 # mail => {}, 57 57 sn => {}, 58 58 mobile => {}, … … 75 75 objectClass => { ro => 1 }, 76 76 } 77 } 78 79 sub is_supported { 80 my ($class, $base) = @_; 81 return $base->param('onlyaddress_container') ? 1 : 0; 77 82 } 78 83 -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql.pm
r861 r1062 14 14 15 15 our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 16 17 my $SCHEMA_VERSION = 3; 16 18 17 19 =head1 NAME … … 93 95 sub load { 94 96 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; 96 112 } 97 113 … … 317 333 } 318 334 335 sub check_user_manager { 336 $_[0]->_handle_by_unexported('user', 'manager', 'active'); 337 } 338 339 sub check_group_manager { 340 $_[0]->_handle_by_unexported('group', 'managedBy'); 341 } 342 343 sub check_nethost_owner { 344 $_[0]->_handle_by_unexported('nethost', 'owner', 'active'); 345 } 346 347 sub _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 319 367 1; 320 368 -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm
r861 r1062 82 82 }, 83 83 owner => { 84 reference => 'user', 85 delayed => 1, 86 }, 87 user => { 84 88 reference => 'user', 85 89 delayed => 1, -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm
r861 r1062 119 119 select * from ( 120 120 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 122 122 except 123 123 ( -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r861 r1062 50 50 $class->SUPER::_get_attr_schema($base, 51 51 { 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 }, 54 59 uidnumber => { inline => 1, hide => 1, }, 55 60 gidNumber => { … … 308 313 } elsif ($field eq 'otheraddress') { 309 314 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 311 320 }); 312 321 $sth->execute($self->id); -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/BuildNet.pm
r861 r1062 13 13 use File::Path; 14 14 use File::Temp qw(tempfile); 15 use Net::IPv4Addr; 16 use Net::IPv6Addr; 15 17 16 18 sub _base { … … 116 118 if (! -d $path) { 117 119 la_log(LA_INFO, 'Creating directory %s', $path); 118 m ake_path($path) or return;120 mkpath($path) or return; 119 121 } 120 122 my $output = join('/', $path, $ozone->get_attributes('outputD')); … … 340 342 nethost.ikey = nethost_attributes_ips.okey 341 343 where value::inet <<= any(?) 342 344 order by value, name 343 345 }); 344 346 $findhost->execute( … … 350 352 return; 351 353 }; 352 my @lists;354 my %lists; 353 355 my %names; 354 356 # Storing all name in %names to check later if CNAME does not conflict 355 357 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}); 358 360 my $host_o = $self->_base->get_object('nethost', $res->{name}); 359 361 foreach (grep { $_ } $host_o->get_attributes('otherName')) { … … 362 364 } 363 365 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 { 366 368 la_log LA_ERR, "Cannot fetch host %s", $res->{name}; 367 369 return; … … 371 373 ? '; ' . $desc . "\n" 372 374 : ''; 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 } 374 383 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 } 376 392 } 377 393 foreach (grep { $_ } $host_o->get_attributes('cname')) { … … 387 403 $dbzone .= "; $msg\n"; 388 404 } else { 389 $dbzone .= sprintf("%-30s IN CNAME %s\n", $_, $res->{name},);405 $dbzone .= sprintf("%-30s IN CNAME %s\n", $_, $res,); 390 406 } 391 407 } … … 456 472 ? '; ' . $desc . "\n" 457 473 : ''; 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, 463 492 $reverse 464 493 ? ($reverse, '.') -
branches/2.0/LATMOS-Accounts/lib/LATMOS/Accounts/Maintenance.pm
r861 r1062 84 84 my %mail = ( 85 85 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}), 87 87 smtp => $self->val('_default_', 'smtp'), 88 88 'Content-Type' => 'text/plain; charset=utf-8', … … 293 293 } 294 294 295 sub generate_rsa_key {296 # compat functions297 my ($self, $password) = @_;298 $self->_base->generate_rsa_key($password);299 }300 301 302 sub store_rsa_key {303 # compat functions304 my ($self, $public, $private) = @_;305 $self->_base->store_rsa_key($public, $private);306 }307 308 sub private_key {309 # compat functions310 my ($self, $password) = @_;311 $self->_base->private_key($password);312 }313 314 sub get_rsa_password {315 # compat functions316 my ($self) = @_;317 $self->_base->get_rsa_password;318 }319 320 295 1; -
branches/2.0/LATMOS-Accounts/sqldata/base.sql
r861 r1062 148 148 END IF; 149 149 END;$$; 150 151 152 --153 -- Name: check_zone_name_unity(); Type: FUNCTION; Schema: public; Owner: -154 --155 156 CREATE FUNCTION check_zone_name_unity() RETURNS trigger157 LANGUAGE plpgsql158 AS $$declare159 list record;160 begin161 162 select into list * from (163 select count(*) as c, name, zone from164 (select nethost.name, zone_obj.name as zone from165 (select nethost_attributes_ips.okey, netzone.name from nethost_attributes_ips166 join netzone_attributes on167 netzone_attributes.attr='net' and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet168 join netzone on netzone.ikey = netzone_attributes.okey) as zone_obj169 join nethost on zone_obj.okey = nethost.ikey170 union all171 select nethost_attributes.value, zone_obj.name from172 (select nethost_attributes_ips.okey, netzone.name from nethost_attributes_ips173 join netzone_attributes on174 netzone_attributes.attr='net' and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet175 join netzone on netzone.ikey = netzone_attributes.okey176 join netzone_attributes as nza on nza.okey = netzone.ikey and nza.attr = 'type' and nza.value = 'dns') as zone_obj177 join nethost_attributes on nethost_attributes.attr = 'cname' and nethost_attributes.okey = zone_obj.okey178 ) as foo179 group by name, zone180 ) as foo where c > 1;181 182 IF FOUND THEN183 RAISE EXCEPTION 'record name found multiple time in a zone';184 END IF;185 186 RETURN new;187 END;$$;188 189 150 190 151 -- … … 1066 1027 -- 1067 1028 1068 CREATE TABLE nethost_attributes_ips ( CONSTRAINT nethost_is_single_ip CHECK ((netmask((value)::inet) = '255.255.255.255'::inet))1029 CREATE TABLE nethost_attributes_ips ( 1069 1030 ) 1070 1031 INHERITS (nethost_attributes); … … 2182 2143 -- 2183 2144 2184 CREATE UNIQUE INDEX nethost_cname_uniq_idx ON nethost_attributes USING btree (value , okey) WHERE (attr = 'cname'::text);2145 CREATE UNIQUE INDEX nethost_cname_uniq_idx ON nethost_attributes USING btree (value) WHERE (attr = 'cname'::text); 2185 2146 2186 2147 … … 2427 2388 2428 2389 -- 2429 -- Name: check_zone_name_unity_tg; Type: TRIGGER; Schema: public; Owner: -2430 --2431 2432 CREATE TRIGGER check_zone_name_unity_tg2433 AFTER INSERT OR UPDATE ON nethost2434 FOR EACH STATEMENT2435 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_tg2443 AFTER INSERT OR UPDATE ON netzone2444 FOR EACH STATEMENT2445 EXECUTE PROCEDURE check_zone_name_unity();2446 2447 2448 --2449 2390 -- Name: department_group_upd_tg; Type: TRIGGER; Schema: public; Owner: - 2450 2391 --
Note: See TracChangeset
for help on using the changeset viewer.