| 1 | package File::SambaMSNRL; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 Module de gestion du fichier de configuration de samba (smb.conf) | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | File::SambaMSNRL - Gestion de la configuration de Samba | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | Version 0.02 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 2 | ▶ | use Exporter (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | $VERSION = 0.02; | |||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 26 | new | ||||||||||||||||||||||||||||||||||||||||||
| 27 | GetGlobal | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ModifGlobal | ||||||||||||||||||||||||||||||||||||||||||
| 29 | AddParamGlobal | ||||||||||||||||||||||||||||||||||||||||||
| 30 | DelParamGlobal | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ValeurSection | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ListPartages | ||||||||||||||||||||||||||||||||||||||||||
| 33 | CreaPartage | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ListSections | ||||||||||||||||||||||||||||||||||||||||||
| 35 | CreaSection | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ModifSection | ||||||||||||||||||||||||||||||||||||||||||
| 37 | DelPartage | ||||||||||||||||||||||||||||||||||||||||||
| 38 | DelValue | ||||||||||||||||||||||||||||||||||||||||||
| 39 | Sauve | ||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =head1 Méthodes Objets | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | =head2 new("fichier_conf_samba"); | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | Le fichier indiqué doit correspondre à un fichier de configuration de samba | ||||||||||||||||||||||||||||||||||||||||||
| 47 | Il doit posséder au minimum une partie [global] et au moins un partage | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | Retourne un nouvel objet | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | Example : | ||||||||||||||||||||||||||||||||||||||||||
| 52 | my $objet=File::SambaMSNRL->new("/etc/samba/smb.conf); | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my $classe = shift; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $smbconf = shift; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my (%global,%det_partages,@partages,%new_partage); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $self = { | |||||||||||||||||||||||||||||||||||||||||
| 62 | "SMB" => "/etc/samba/smb.conf", | ||||||||||||||||||||||||||||||||||||||||||
| 63 | "GLOBAL" => \%global, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | "DET_PARTAGES" => \%det_partages, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | "PARTAGES" => \@partages, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | "NEW_PARTAGE" => \%new_partage | ||||||||||||||||||||||||||||||||||||||||||
| 67 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $self->{SMB} = $smbconf if (defined $smbconf); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | bless($self,$classe); | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | ### Chargement du fichier samba | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my @global = $self->TakeGlobal; | |||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->TakePartages; | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return($self); | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =head2 GetGlobal | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | Lit et renvoi la partie [global] du fichier smb.conf | ||||||||||||||||||||||||||||||||||||||||||
| 82 | Le retour se fait sous la forme d'un Hash | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 85 | Aucun | ||||||||||||||||||||||||||||||||||||||||||
| 86 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 87 | Hash du global | ||||||||||||||||||||||||||||||||||||||||||
| 88 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 89 | my %global = $smb->GetGlobal; | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | sub GetGlobal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetGlobal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | my %GLOBAL = %{$this->{GLOBAL}}; | |||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | return (%GLOBAL); | |||||||||||||||||||||||||||||||||||||||||
| 98 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =head2 ModifGlobal([parametre],[nouvelle_valeur]); | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | Modifie l'un des parametres de la partie [global] du smb.conf | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 105 | parametre = Le parametre du global à modifier | ||||||||||||||||||||||||||||||||||||||||||
| 106 | nouvelle_valeur = la valeur du parametre à modifier | ||||||||||||||||||||||||||||||||||||||||||
| 107 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 108 | Retourne 1 si la modification a été effectuée | ||||||||||||||||||||||||||||||||||||||||||
| 109 | Retourne 0 si pas de modification | ||||||||||||||||||||||||||||||||||||||||||
| 110 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 111 | my $retour = $smb->ModifGlobal("workgroup","DOMAINE1"); | ||||||||||||||||||||||||||||||||||||||||||
| 112 | if ($retour == 1) {print("La modification du parametre s'est déroulée avec succés\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | sub ModifGlobal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ModifGlobal: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $return = 0; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my %GLOBAL = %{$this->{GLOBAL}}; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $param = lc($param); | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | if (exists $GLOBAL{$param}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $GLOBAL{$param} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $return = 1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $this->{GLOBAL} = \%GLOBAL; | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | return($this,$return); | |||||||||||||||||||||||||||||||||||||||||
| 135 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | =head2 AddParamGlobal ([parametre_a_ajouter],[valeur_du_parametre]); | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | Ajoute un nouveau parametre sur la partie [global] du smb.conf | ||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 142 | parametre_a_ajouter = le nom du parametre à ajouter dans la partie global | ||||||||||||||||||||||||||||||||||||||||||
| 143 | valeur_du_parametre = la valeur de ce parametre | ||||||||||||||||||||||||||||||||||||||||||
| 144 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 145 | - | ||||||||||||||||||||||||||||||||||||||||||
| 146 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 147 | $smb->AddParamGlobal("guest ok","Yes"); | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | sub AddParamGlobal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AddParamGlobal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $param = lc($param); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my %GLOBAL = %{$this->{GLOBAL}}; | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $GLOBAL{$param} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $this->{GLOBAL} = \%GLOBAL; | |||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | return($this); | |||||||||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | =head2 DelParamGlobal([parametre_a_supprimer]); | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | Supprime un parametre dans la partie [global] du smb.conf | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 172 | Nom du parametre à supprimer | ||||||||||||||||||||||||||||||||||||||||||
| 173 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 174 | Retourne 0 en cas de non suppression | ||||||||||||||||||||||||||||||||||||||||||
| 175 | Retourne 1 si le parametre a été correctement supprimé | ||||||||||||||||||||||||||||||||||||||||||
| 176 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 177 | my $result = $smb->DelParamGlobal("workgroup"); | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub DelParamGlobal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DelParamGlobal: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my $return = 0; | |||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $param = lc($param); | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my %GLOBAL = %{$this->{GLOBAL}}; | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if (exists $GLOBAL{$param}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | delete($GLOBAL{$param}); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $return = 1; | |||||||||||||||||||||||||||||||||||||||||
| 195 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $this->{GLOBAL} = \%GLOBAL; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return($this,$return); | |||||||||||||||||||||||||||||||||||||||||
| 200 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =head2 ValeurSection([nom_de_partage],[nom_de_section]) | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | Recherche la valeur d'une section pour un partage donné | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 207 | Nom du partage | ||||||||||||||||||||||||||||||||||||||||||
| 208 | Nom de la section dont on souhaite la valeur | ||||||||||||||||||||||||||||||||||||||||||
| 209 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 210 | Valeur de la section d'un partage donné | ||||||||||||||||||||||||||||||||||||||||||
| 211 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 212 | my $valeur = $smb->ValeurSection("data","path"); | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | sub ValeurSection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ValeurSection: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $partage_section = shift; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $nom_section = shift; | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $value = undef; | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my %details = %{$this->{DET_PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | my @partages = @{$this->{PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $partage_section = lc($partage_section); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | $nom_section = lc($nom_section); | |||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if (grep(/$partage_section/,@partages)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | my @temp = keys %{$details{$partage_section}}; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if (grep(/$nom_section/,@temp)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $value = $details{$partage_section}{$nom_section}; | |||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return($value); | |||||||||||||||||||||||||||||||||||||||||
| 235 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =head2 ListPartages | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | Liste la totalité des partages contenus dans le fichier de configuration de samba | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 242 | Aucun | ||||||||||||||||||||||||||||||||||||||||||
| 243 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 244 | Tableau contenant la liste des partages | ||||||||||||||||||||||||||||||||||||||||||
| 245 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 246 | my @partages = ListPartages; | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | sub ListPartages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListPartages: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my @partages = @{$this->{PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | return (@partages); | |||||||||||||||||||||||||||||||||||||||||
| 255 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | =head2 ListSections | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | Liste les différentes sections et leur valeur pour tous les partages samba | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 262 | Aucun | ||||||||||||||||||||||||||||||||||||||||||
| 263 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 264 | Hash de hash contenant le détail de chaque partage samba | ||||||||||||||||||||||||||||||||||||||||||
| 265 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 266 | my %details = $smb->ListSections; | ||||||||||||||||||||||||||||||||||||||||||
| 267 | my @part = keys %details; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | foreach $keys (@part) { | ||||||||||||||||||||||||||||||||||||||||||
| 269 | my @key2 = keys %{$details{$keys}}; | ||||||||||||||||||||||||||||||||||||||||||
| 270 | foreach my $value (@key2) { | ||||||||||||||||||||||||||||||||||||||||||
| 271 | my $valeur = $details{$keys}{$value}; | ||||||||||||||||||||||||||||||||||||||||||
| 272 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 273 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub ListSections { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ListSections: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my %detail = %{$this->{DET_PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | return (%detail); | |||||||||||||||||||||||||||||||||||||||||
| 282 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | =head2 CreaPartage("nom_du_partage"); | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | Permet la creation d'un nouveau partage | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 289 | Le nom du partage à créer | ||||||||||||||||||||||||||||||||||||||||||
| 290 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 291 | Retourne 1 si le partage a été créé | ||||||||||||||||||||||||||||||||||||||||||
| 292 | Retourne 0 si le partage n'a pas pu être créé | ||||||||||||||||||||||||||||||||||||||||||
| 293 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 294 | my $result = $smb->CreaPartage("nom_du_partage"); | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | sub CreaPartage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CreaPartage: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $partage = shift; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my %detail = %{$this->{NEW_PARTAGE}}; | |||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my @partages = @{$this->{PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $result = 1; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $partage = lc($partage); | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | ### Tester si le nom de partage n'est pas déjà utilisé ### | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if (grep /$partage/,@partages) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $result = 0; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 312 | ### Creer le partage ### | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $detail{$partage}{comment}=$partage; | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | push(@partages,$partage); | |||||||||||||||||||||||||||||||||||||||||
| 315 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $this->{NEW_PARTAGE} = \%detail; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $this->{PARTAGES} = \@partages; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return ($this,$result); | |||||||||||||||||||||||||||||||||||||||||
| 319 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | =head2 CreaSection([partage],[section],[valeur_de_la_section]); | ||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | Ajoute une nouvelle section au partage créé précédemment à l'aide de "CreaPartage" | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 326 | partage : Nom du partage sur lequel créer une section | ||||||||||||||||||||||||||||||||||||||||||
| 327 | Section : Nom de la section à créer | ||||||||||||||||||||||||||||||||||||||||||
| 328 | Valeur de la section : Valeur à inscrire pour la section indiquée | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 331 | Retourne 1 si la création s'est déroulée correctement | ||||||||||||||||||||||||||||||||||||||||||
| 332 | Retourne 0 si la création n'a pas eu lieu | ||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 335 | my $result = $smb->CreaPartage("Data"); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | $smb->CreaSection("donnees","path","/home/data"); | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub CreaSection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CreaSection: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $partage = shift; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $section = shift; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $partage = lc($partage); | |||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $section = lc($section); | |||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | my $result = 1; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my %new_partage = %{$this->{NEW_PARTAGE}}; | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my @keys = keys(%new_partage); | |||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if (!(grep(/$partage/,@keys))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $result = 0; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 358 | ### Ajouter la nouvelle section au partage en cours de creation | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | $new_partage{$partage}{$section} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 360 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return ($this,$result); | |||||||||||||||||||||||||||||||||||||||||
| 363 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | =head2 ModifSection([partage],[section],[valeur_de_la_section]); | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | Modifie la valeur d'une section pour un partage donné | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 370 | [partage] : nom du partage sur lequel travailler | ||||||||||||||||||||||||||||||||||||||||||
| 371 | [section] : nom de la section dans le partage indiqué | ||||||||||||||||||||||||||||||||||||||||||
| 372 | [valeur_de_la_section] : Valeur de la section | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 375 | Retourne 1 si la modification a été réalisée | ||||||||||||||||||||||||||||||||||||||||||
| 376 | Retourne 0 si la modification a échouée | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 379 | my $retour = $smb->ModifSection("games","inherit permissions","No"); | ||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | sub ModifSection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ModifSection: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $partage_modif = shift; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $section_modif = shift; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $value_modif = shift; | |||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $result = 1; | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $partage_modif = lc($partage_modif); | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $section_modif = lc($section_modif); | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my @partages = @{$this->{PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | my %detail = %{$this->{DET_PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if (grep(/$partage_modif/,@partages)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $detail{$partage_modif}{$section_modif}=$value_modif; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | else { $result = 0; }; | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | return ($this,$result); | |||||||||||||||||||||||||||||||||||||||||
| 403 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | =head2 DelPartage([@partages]); | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | Supprime un partage du fichier smb.conf | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 410 | Un tableau contenant le nom de chaque partage à supprimer | ||||||||||||||||||||||||||||||||||||||||||
| 411 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 412 | Retourne une référence sur un tableau contenant le nom des partages supprimés | ||||||||||||||||||||||||||||||||||||||||||
| 413 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 414 | my @partages = ("data","games","mp3","avi"); | ||||||||||||||||||||||||||||||||||||||||||
| 415 | my $RefPartagesSupp = $smb->DelPartage(@partages); | ||||||||||||||||||||||||||||||||||||||||||
| 416 | my @PartSupp = @$RefPartagesSupp; | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | foreach my $val (@PartSupp) { | ||||||||||||||||||||||||||||||||||||||||||
| 419 | print("Partage Supprimé : $val\n"); | ||||||||||||||||||||||||||||||||||||||||||
| 420 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub DelPartage { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DelPartage: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | my (@partage_del) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | my @retour; | |||||||||||||||||||||||||||||||||||||||||
| 429 | my $part; | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | my @partages = @{$this->{PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my %detail = %{$this->{DET_PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | foreach $part (@partage_del) { | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | $part = lc($part); | |||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | if (grep(/$part/,@partages)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | delete($detail{$part}); | |||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | for (my $i=0;$i<=$#partages;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | if ($partages[$i] eq $part) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | splice(@partages,$i,1); | |||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | push (@retour,$part); | |||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 443 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 444 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 445 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 446 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $this->{PARTAGES} = \@partages; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $this->{DET_PARTAGES} = \%detail; | |||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return ($this,\@retour); | |||||||||||||||||||||||||||||||||||||||||
| 452 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | =head2 DelValue([nom_partage],[valeur_a_supprimer]); | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | Suppression d'un parametre dans un partage | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 459 | nom_partage : Nom du partage où le paramètre doit être supprimé | ||||||||||||||||||||||||||||||||||||||||||
| 460 | valeur_a_supprimer : Le paramètre à supprimer dans ce partage | ||||||||||||||||||||||||||||||||||||||||||
| 461 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 462 | Retourne 1 si le parametre a été supprimé | ||||||||||||||||||||||||||||||||||||||||||
| 463 | Retourne 0 si le parametre n'a pas été supprimé | ||||||||||||||||||||||||||||||||||||||||||
| 464 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 465 | my $retour = $smb->DelValue("games","inherit permissions"); | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | sub DelValue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DelValue: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my $partage = shift; | |||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $partage = lc($partage); | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $value = lc($value); | |||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | my $retour = 1; | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | my @partages = @{$this->{PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my %detail = %{$this->{DET_PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | if (grep(/$partage/,@partages)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | if (exists $detail{$partage}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | delete $detail{$partage}{$value}; | |||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | $this->{DET_PARTAGES} = \%detail; | |||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | $retour = 0; | |||||||||||||||||||||||||||||||||||||||||
| 490 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $retour = 0; | |||||||||||||||||||||||||||||||||||||||||
| 494 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | return($this,$retour); | |||||||||||||||||||||||||||||||||||||||||
| 497 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | =head2 Sauve([nom_du_fichier]); | ||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||
| 501 | Sauvegarde des modifications effectuées > Ecriture du fichier final | ||||||||||||||||||||||||||||||||||||||||||
| 502 | Pour que l'enregistrement se passe correctement, il faut au minimum une partie global et un partage. | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 505 | Nom du fichier à sauvegarder. Ce paramêtre est facultatif. | ||||||||||||||||||||||||||||||||||||||||||
| 506 | S'il n'est pas donné, le fichier est enregistré sous son nom d'origine. | ||||||||||||||||||||||||||||||||||||||||||
| 507 | Dans ce cas, une sauvegarde de ce fichier est réalisée dans le même répertoire avant l'écriture. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 510 | Si sauvegarde avec le nom du fichier d'origine, renvoi le nom du fichier sauvegardé | ||||||||||||||||||||||||||||||||||||||||||
| 511 | Si sauvegarde avec un nouveau nom, renvoi 1 | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | Example: | ||||||||||||||||||||||||||||||||||||||||||
| 514 | my $retour = $smb->Sauve("/etc/samba/smbnew.conf"); | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | sub Sauve { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Sauve: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $fic_sauve = shift; | |||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $retour; | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); | |||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my %partage_a_sauver = %{$this->{NEW_PARTAGE}}; | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my %det_part = %{$this->{DET_PARTAGES}}; | |||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $smb = $this->{SMB}; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | my %global = %{$this->{GLOBAL}}; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | $year = $year+1900; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my $save = "$smb-$mon$year-$hour$min$sec"; | |||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if ((defined $fic_sauve) and ($smb ne $fic_sauve)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fic_sauve and $smb ne $fic_sauve
MC/DC0%0/2
defined $fic_sauve and $smb ne $fic_sauve
defined $fic_sauve
$smb ne $fic_sauve
Truth table0%0/3
A and B
A= defined $fic_sauveB= $smb ne $fic_sauve
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | $smb = $fic_sauve; | |||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $retour = 1; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 537 | ### Sauvegarde du fichier d'origine ### | ||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | copy("$smb","$save"); | |||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $retour = $save; | |||||||||||||||||||||||||||||||||||||||||
| 540 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | ### Integration du nouveau partage dans la liste des partages à enregistrer | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | my @keys_new = keys(%partage_a_sauver); | |||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | if ($#keys_new >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | foreach my $key_new (@keys_new) { | |||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | my @section_new = keys(%{$partage_a_sauver{$key_new}}); | |||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | foreach my $sectio (@section_new) { | |||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $det_part{$key_new}{$sectio}=$partage_a_sauver{$key_new}{$sectio}; | |||||||||||||||||||||||||||||||||||||||||
| 550 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 551 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 552 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||
| 554 | ### Mettre le premier caractere en majuscule (uniquement pour Yes ou No) | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my @keys_maj = keys(%det_part); | |||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | foreach my $_key (@keys_maj) { | |||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | my @section_maj = keys(%{$det_part{$_key}}); | |||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | foreach my $_section (@section_maj) { | |||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if ($det_part{$_key}{$_section} =~ /^yes$|^no$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | $det_part{$_key}{$_section} = ucfirst($det_part{$_key}{$_section}); | |||||||||||||||||||||||||||||||||||||||||
| 562 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 563 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 564 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | ### Ouverture du fichier en ecriture | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | open(FICSMB,">",$smb)||croak("Impossible de créer le fichier $smb !!!\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | ### En-tête personnalisé | ||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | print FICSMB (";============================================================================\n"); | |||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | print FICSMB (";================== xxxxxxx perl -- SambaMSNRL xxxxxxx ==================\n"); | |||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | print FICSMB (";============ xxxx raphael.gommeaux\@gmail.com xxxx ===========\n"); | |||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | print FICSMB (";============================================================================\n\n\n"); | |||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | ### Ecriture du global dans le fichier | ||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | my @keys_global = sort(keys(%global)); | |||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $maj_key; | |||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if ($#keys_global >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | print FICSMB ("[global]\n"); | |||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | foreach my $key_global (@keys_global) { | |||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $maj_key = $global{$key_global}; | |||||||||||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | if ($global{$key_global} =~ /^yes$|^no$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $maj_key = lc($maj_key); | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $maj_key = ucfirst($maj_key); | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | print FICSMB ("\t$key_global = $maj_key\n"); | |||||||||||||||||||||||||||||||||||||||||
| 589 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | else { croak("Impossible de trouver la partie global...\n"); }; | |||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||
| 593 | ### Separation entre le global et les partages | ||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | print FICSMB ("\n;=========================================================================\n\n"); | |||||||||||||||||||||||||||||||||||||||||
| 595 | ### Ecriture des partages dans le fichier | ||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my @keys_detail_part = sort(keys(%det_part)); | |||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | if ($#keys_detail_part >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | foreach my $key_part (@keys_detail_part) { | |||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | print FICSMB ("\n[$key_part]\n"); | |||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my @section = sort(keys(%{$det_part{$key_part}})); | |||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | foreach my $sectio (@section) { | |||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $det_maj = $det_part{$key_part}{$sectio}; | |||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | if ($det_maj =~ /^yes$|^no$/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | $det_maj = lc($det_maj); | |||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $det_maj = ucfirst($det_maj); | |||||||||||||||||||||||||||||||||||||||||
| 606 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | print FICSMB ("\t$sectio = $det_maj\n"); | |||||||||||||||||||||||||||||||||||||||||
| 608 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 609 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | else { croak("Pas de partages à enregistrer... surement une erreur...\n");}; | |||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | ### Fermeture du fichier | ||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | close FICSMB; | |||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | return($retour); | |||||||||||||||||||||||||||||||||||||||||
| 617 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | =head2 load("nom_du_fichier"); | ||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||
| 623 | Charge un fichier de configuration samba | ||||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | Params: | ||||||||||||||||||||||||||||||||||||||||||
| 626 | Nom du fichier de configuration | ||||||||||||||||||||||||||||||||||||||||||
| 627 | Returns: | ||||||||||||||||||||||||||||||||||||||||||
| 628 | Retourne un tableau contenant le fichier chargé | ||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||
| 630 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | sub load { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my $name = shift; | |||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my @smbconf; | |||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if (-z $name) { croak("Le fichier $name est vide !!!\n");}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | open(FICSMB,$name)||croak("Impossible de lire le fichier $name !!!!!\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my @smb = <FICSMB>; | |||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | close FICSMB; | |||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | return (@smb); | |||||||||||||||||||||||||||||||||||||||||
| 643 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||
| 645 | =head2 TakePartages | ||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||
| 647 | Charge la liste des partages présents dans le fichier de configuration de samba | ||||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | ▶ | sub TakePartages { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TakePartages: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my @SHARES; | |||||||||||||||||||||||||||||||||||||||||
| 654 | my @SHARES_DET; | ||||||||||||||||||||||||||||||||||||||||||
| 655 | 0 | my $share_detail; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | my $fin; | |||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my %share_detail; | |||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $part; | |||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $ligne; | |||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | my @SMB = load($this->{SMB}); | |||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | for (my $i=0;$i<=$#SMB;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | chomp($SMB[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | $ligne = $SMB[$i]; | |||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | if (($ligne =~ /\[/) and (!($ligne =~ /\[global\]/))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$ligne =~ /\[/ and not $ligne =~ /\[global\]/
MC/DC0%0/2
$ligne =~ /\[/ and not $ligne =~ /\[global\]/
$ligne =~ /\[/
not $ligne =~ /\[global\]/
Truth table0%0/3
A and not(B)
A= $ligne =~ /\[/B= not $ligne =~ /\[global\]/
| |||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $part = lc($SMB[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $part =~ s/\[//; | |||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | $part =~ s/\]//; | |||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | $part =~ s/ //g; | |||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | push(@SHARES,$part); | |||||||||||||||||||||||||||||||||||||||||
| 675 | } | ||||||||||||||||||||||||||||||||||||||||||
| 676 | ### Ne passe pas dans cette boucle si : | ||||||||||||||||||||||||||||||||||||||||||
| 677 | ### - pas encore trouvé de partage | ||||||||||||||||||||||||||||||||||||||||||
| 678 | ### - la ligne est vide | ||||||||||||||||||||||||||||||||||||||||||
| 679 | ### - la ligne commence par un ; ou un # | ||||||||||||||||||||||||||||||||||||||||||
| 680 | ### - la ligne commence par une ou plusieurs tabulations suivies d'un ; ou d'un # | ||||||||||||||||||||||||||||||||||||||||||
| 681 | ### - la ligne commence par un ou plusieurs espaces suivis d'un ; ou d'un # | ||||||||||||||||||||||||||||||||||||||||||
| 682 | ▶ | elsif (($#SHARES >= 0) and (!($ligne =~ /^\s*$|^;|^\t*;|^\s*;|^#|^\t*#|^\s*#/))) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$#SHARES >= 0 and not $ligne =~ /^\s*$|^;|^\t*;|^\s*;|^#|^\t*#|^\s*#/
MC/DC0%0/2
$#SHARES >= 0 and not $ligne =~ /^\s*$|^;|^\t*;|^\s*;|^#|^\t*#|^\s*#/
$#SHARES >= 0
not $ligne =~ /^\s*$|^;|^\t*;|^\s*;|^#|^\t*#|^\s*#/
Truth table0%0/3
A and not(B)
A= $#SHARES >= 0B= not $ligne =~ /^\s*$|^;|^\t*;|^\s*;|^#|^\t*#|^\s*#/
| |||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | $ligne =~ /(.+)=(.+)/; | |||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | my $section = $1; | |||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $valeur = $2; | |||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | ▶ | if (($valeur eq "") or ($valeur eq " ")) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$valeur eq "" or $valeur eq " "
MC/DC0%0/2
$valeur eq "" or $valeur eq " "
$valeur eq ""
$valeur eq " "
Truth table0%0/3
A or B
A= $valeur eq ""B= $valeur eq " "
| |||||||||||||||||||||||||||||||||||||||||||
| 688 | { | ||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | $section = $ligne; | |||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | $section =~ s/=//; | |||||||||||||||||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | $section =~ s/\t//; | |||||||||||||||||||||||||||||||||||||||||
| 694 | 0 | $section =~ s/^ +//; | |||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | $section =~ s/ +$//; | |||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $section = lc($section); | |||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $valeur =~ s/\t//; | |||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | $valeur =~ s/^ +//; | |||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | $valeur =~ s/ +$//; | |||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | $share_detail{$part}{$section} = $valeur; | |||||||||||||||||||||||||||||||||||||||||
| 704 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 705 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | $this->{PARTAGES} = \@SHARES; | |||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $this->{DET_PARTAGES} = \%share_detail; | |||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | return $this; | |||||||||||||||||||||||||||||||||||||||||
| 711 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | =head2 TakeGlobal | ||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||
| 715 | Charge la partie global du fichier de configuration samba | ||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | sub TakeGlobal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TakeGlobal: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 721 | 0 | my @smb = load($this->{SMB}); | |||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | my %GLOBAL; | |||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 0 | ▶ | for (my $i=0;$i<=$#smb;$i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | chomp($smb[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | if ($smb[$i] eq "[global]") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | ▶ | for (my $j=$i+1;$j<=$#smb;$j++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | ▶ | if (grep (/\[/,$smb[$j])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 730 | } | ||||||||||||||||||||||||||||||||||||||||||
| 731 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | chomp($smb[$j]); | |||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | if ((!($smb[$j] =~ /^;/)) and (!($smb[$j] =~ /^#/)) and (grep (/=/,$smb[$j]))) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $smb[$j] =~ /^;/ || $smb[$j] =~ /^#/ and grep /=/, $smb[$j]
$smb[$j] =~ /^;/ || $smb[$j] =~ /^#/
MC/DC0%0/3
not $smb[$j] =~ /^;/ || $smb[$j] =~ /^#/ and grep /=/, $smb[$j]
$smb[$j] =~ /^;/
$smb[$j] =~ /^#/
grep /=/, $smb[$j]
Truth table0%0/4
not(A || B) and C
A= $smb[$j] =~ /^;/B= $smb[$j] =~ /^#/C= grep /=/, $smb[$j]
| |||||||||||||||||||||||||||||||||||||||||||
| 734 | # $smb[$j] =~ /(.*?)=(.*)/; | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $smb[$j] =~ m/([^=]+) = (.+)/x; | |||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $section_global = $1; | |||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | my $valeur_section = $2; | |||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | if (($valeur_section eq "") or ($valeur_section eq " ")) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$valeur_section eq "" or $valeur_section eq " "
MC/DC0%0/2
$valeur_section eq "" or $valeur_section eq " "
$valeur_section eq ""
$valeur_section eq " "
Truth table0%0/3
A or B
A= $valeur_section eq ""B= $valeur_section eq " "
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $section_global = $smb[$j]; | |||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | $section_global =~ s/=//; | |||||||||||||||||||||||||||||||||||||||||
| 743 | } | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | $section_global =~ s/\t//; | |||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $section_global =~ s/^ +//; | |||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $section_global =~ s/ +$//; | |||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $section_global = lc($section_global); | |||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | $valeur_section =~ s/\t//; | |||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | $valeur_section =~ s/^ +//; | |||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $valeur_section =~ s/ +$//; | |||||||||||||||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||||||||||||||||
| 754 | 0 | $GLOBAL{$section_global}=$valeur_section; | |||||||||||||||||||||||||||||||||||||||||
| 755 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 756 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 757 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 758 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 759 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $this->{GLOBAL} = \%GLOBAL; | |||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | return (%GLOBAL); | |||||||||||||||||||||||||||||||||||||||||
| 762 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||