Passed
Push — master ( 542ccc...11646b )
by Tomasz
06:50
created
devices/linux/DeviceLinuxSh.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
      $SSIDs = $this->attributes['internal:SSID'];
66 66
      $delSSIDs = $this->attributes['internal:remove_SSID'];
67 67
 
68
-     $out_string .= $this->printNMScript($SSIDs,$delSSIDs);
68
+     $out_string .= $this->printNMScript($SSIDs, $delSSIDs);
69 69
      $out_string .= $this->writeWpaConf($SSIDs);
70
-     if($this->selected_eap == \core\common\EAP::EAPTYPE_TLS) 
70
+     if ($this->selected_eap == \core\common\EAP::EAPTYPE_TLS) 
71 71
        $out_string .= $this->printP12Dialog();
72 72
      else
73 73
        $out_string .= $this->printPasswordDialog();
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
    }
79 79
 
80 80
     public function writeDeviceInfo() {
81
-    $ssid_ct=count($this->attributes['internal:SSID']);
81
+    $ssid_ct = count($this->attributes['internal:SSID']);
82 82
     $out = '';
83 83
 
84 84
    $out .= _("The installer is in the form of a bash script. It will try to configure eduroam under Network Manager and if this is either not appropriate for your system or your version of Network Manager is too old, a wpa_supplicant config file will be created instead.");
85 85
    $out .= "<p>";
86
-    if($ssid_ct > 1) {
87
-        if($ssid_ct > 2) {
88
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"),implode(', ',\config\ConfAssistant::CONSORTIUM['ssid']))." ";
86
+    if ($ssid_ct > 1) {
87
+        if ($ssid_ct > 2) {
88
+            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to the following networks:"), implode(', ', \config\ConfAssistant::CONSORTIUM['ssid']))." ";
89 89
         } else
90
-            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"),implode(', ',\config\ConfAssistant::CONSORTIUM['ssid']))." ";
90
+            $out .= sprintf(_("In addition to <strong>%s</strong> the installer will also configure access to:"), implode(', ', \config\ConfAssistant::CONSORTIUM['ssid']))." ";
91 91
         $i = 0;
92 92
         foreach ($this->attributes['internal:SSID'] as $ssid=>$v) {
93
-           if(! in_array($ssid, \config\ConfAssistant::CONSORTIUM['ssid'])) {
94
-             if($i > 0)
93
+           if (!in_array($ssid, \config\ConfAssistant::CONSORTIUM['ssid'])) {
94
+             if ($i > 0)
95 95
            $out .= ", ";
96 96
          $i++;
97 97
          $out .= "<strong>$ssid</strong>";
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     $out .= "<p>";
101 101
     }
102 102
    $out .= _("The installer will create .cat_installer sub-directory in your home directory and will copy your server certificates there.");
103
-if($this->eap == \core\common\EAP::EAPTYPE_TLS)
103
+if ($this->eap == \core\common\EAP::EAPTYPE_TLS)
104 104
    $out .= _("In order to connect to the network you will need a personal certificate in the form of a p12 file. You should obtain this certificate from your home institution. Consult the support page to find out how this certificate can be obtained. Such certificate files are password protected. You should have both the file and the password available during the installation process. Your p12 file will also be copied to the .cat_installer directory.");
105 105
 else {
106 106
    $out .= _("In order to connect to the network you will need an account from your home institution. You should consult the support page to find out how this account can be obtained. It is very likely that your account is already activated.");
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 
115 115
   private function printCheckDirectory() {
116 116
 $out = 'if [ -d $HOME/'.$this->local_dir.' ] ; then
117
-   if ! ask "'.sprintf(_("Directory %s exists; some of its files may be overwritten."),'$HOME/'.$this->local_dir).'" "'._("Continue").'" 1 ; then exit; fi
117
+   if ! ask "'.sprintf(_("Directory %s exists; some of its files may be overwritten."), '$HOME/'.$this->local_dir).'" "'._("Continue").'" 1 ; then exit; fi
118 118
 else
119 119
   mkdir $HOME/'.$this->local_dir.'
120 120
 fi
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
    if ! ask "'.("Network Manager configuration failed, but we may generate a wpa_supplicant configuration file if you wish. Be warned that your connection password will be saved in this file as clear text.").'" "'._("Write the file").'" 1 ; then exit ; fi
131 131
 
132 132
 if [ -f '.$this->conf_file.' ] ; then
133
-  if ! ask "'.sprintf(_("File %s exists; it will be overwritten."),$this->conf_file).'" "'._("Continue").'" 1 ; then confirm_exit; fi
133
+  if ! ask "'.sprintf(_("File %s exists; it will be overwritten."), $this->conf_file).'" "'._("Continue").'" 1 ; then confirm_exit; fi
134 134
   rm '.$this->conf_file.'
135 135
   fi
136 136
    create_wpa_conf
137
-   show_info "'.sprintf(_("Output written to %s"),$this->conf_file).'"
137
+   show_info "'.sprintf(_("Output written to %s"), $this->conf_file).'"
138 138
 fi
139 139
 ';
140 140
   return $out;
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
 
151 151
 
152 152
 private function printProfileConfirmation() {
153
- if($this->attributes['internal:profile_count'][0] > 1)
154
-       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."),'${bf}'.$this->attributes['general:instname'][0].'${n}','${bf}'.$this->attributes['profile:name'][0]).'${n}"';
153
+ if ($this->attributes['internal:profile_count'][0] > 1)
154
+       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s and the user group: %s."), '${bf}'.$this->attributes['general:instname'][0].'${n}', '${bf}'.$this->attributes['profile:name'][0]).'${n}"';
155 155
     else
156
-       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."),'${bf}'.$this->attributes['general:instname'][0]).'${n}"';
156
+       $out = 'if ! ask "'.sprintf(_("This installer will only work properly if you are a member of %s."), '${bf}'.$this->attributes['general:instname'][0]).'${n}"';
157 157
     $out .= ' "'._("Continue").'" 1 ; then exit; fi
158 158
 ';
159 159
   return $out;
@@ -163,12 +163,12 @@  discard block
 block discarded – undo
163 163
 
164 164
   private function printUserConsent() {
165 165
     $out = '';
166
-    if(isset($this->attributes['support:info_file'])) {
167
-      if( $this->attributes['internal:info_file'][0]['mime'] == 'txt') {
168
-         $handle = fopen($this->attributes['internal:info_file'][0]['name'],"r");
166
+    if (isset($this->attributes['support:info_file'])) {
167
+      if ($this->attributes['internal:info_file'][0]['mime'] == 'txt') {
168
+         $handle = fopen($this->attributes['internal:info_file'][0]['name'], "r");
169 169
          $consent = '';
170 170
          while (($buffer = fgets($handle, 4096)) !== false) {
171
-           $consent .= rtrim($buffer) . '\n';
171
+           $consent .= rtrim($buffer).'\n';
172 172
          }
173 173
          $out = 'if ! ask "'.$consent.'${n}" "'._("Continue").'" 1 ; then exit; fi
174 174
 ';
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 # if the second argument is 0 then the first element of yes_no array
182 182
 # will be the default value prompted to the user
183 183
   private function printFunctions() {
184
-$url = (isset($this->attributes['support:url'][0]) && $this->attributes['support:url'][0] ) ? $this->attributes['support:url'][0] : $this->support_url_substitute;
185
-$support=(isset($this->attributes['support:email'][0]) && $this->attributes['support:email'][0] ) ? $this->attributes['support:email'][0] : $this->support_email_substitute;
186
-$out ='
184
+$url = (isset($this->attributes['support:url'][0]) && $this->attributes['support:url'][0]) ? $this->attributes['support:url'][0] : $this->support_url_substitute;
185
+$support = (isset($this->attributes['support:email'][0]) && $this->attributes['support:email'][0]) ? $this->attributes['support:email'][0] : $this->support_email_substitute;
186
+$out = '
187 187
 my_name=$0
188 188
 
189 189
 
@@ -404,10 +404,10 @@  discard block
 block discarded – undo
404 404
   eap='.$e['OUTER'].'
405 405
   ca_cert="${HOME}/'.$this->local_dir.'/ca.pem"
406 406
   identity="${USER_NAME}"';
407
-  if($this->server_name)
407
+  if ($this->server_name)
408 408
     $out .= '
409 409
   domain_suffix_match="'.$this->server_name.'"';
410
-  if($this->selected_eap == \core\common\EAP::EAPTYPE_TLS) {
410
+  if ($this->selected_eap == \core\common\EAP::EAPTYPE_TLS) {
411 411
     $out .= '
412 412
   private_key="${HOME}/'.$this->local_dir.'/user.p12"
413 413
   private_key_passwd="${PASSWORD}"';
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
     $out .= '
416 416
   phase2="auth='.$e['INNER'].'"
417 417
   password="${PASSWORD}"';
418
-  if($this->attributes['internal:use_anon_outer'][0] == 1) 
418
+  if ($this->attributes['internal:use_anon_outer'][0] == 1) 
419 419
     $out .= '
420 420
   anonymous_identity="'.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'"';
421 421
   }
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
   return $out;
440 440
 }
441 441
   private function printP12Dialog() {
442
-  $out ='function p12dialog {
442
+  $out = 'function p12dialog {
443 443
   if [ ! -z $ZENITY ] ; then
444 444
     if ! cert=`$ZENITY --file-selection --file-filter="'._("personal certificate file (p12 or pfx)").' | *.p12 *.P12 *.pfx *.PFX" --file-filter="All files | *" --title="'._("personal certificate file (p12 or pfx)").'" 2>/dev/null` ; then
445 445
        exit
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 ';
501 501
         } else {
502 502
             $out .= '      if [ -z "$USER_NAME" ] ; then
503
-             if ! USER_NAME=`prompt_nonempty_string 1 "' . _("enter your userid") . '" ""` ; then
503
+             if ! USER_NAME=`prompt_nonempty_string 1 "' . _("enter your userid").'" ""` ; then
504 504
                  exit 1
505 505
              fi
506 506
       fi
@@ -515,31 +515,31 @@  discard block
 block discarded – undo
515 515
 
516 516
 
517 517
 private function glueServerNames($server_list) {
518
-  if(! $server_list)
518
+  if (!$server_list)
519 519
     return '';
520
-  $A0 =  array_reverse(explode('.',array_shift($server_list)));
520
+  $A0 = array_reverse(explode('.', array_shift($server_list)));
521 521
   $B = $A0;
522
-  foreach($server_list as $a) {
523
-     $A= array_reverse(explode('.',$a));
524
-     $B = array_intersect_assoc($A0,$A);
522
+  foreach ($server_list as $a) {
523
+     $A = array_reverse(explode('.', $a));
524
+     $B = array_intersect_assoc($A0, $A);
525 525
      $A0 = $B;
526 526
    }
527
-  return(implode('.',array_reverse($B)));
527
+  return(implode('.', array_reverse($B)));
528 528
 }
529 529
 
530 530
 private function mkSubjectAltNameList($server_list) {
531
-  if(! $server_list)
531
+  if (!$server_list)
532 532
     return '';
533 533
   $out = '';
534
-  foreach($server_list as $a) {
535
-     if($out)
534
+  foreach ($server_list as $a) {
535
+     if ($out)
536 536
        $out .= ','; 
537 537
      $out .= "'DNS:$a'";
538 538
   }
539 539
   return $out;
540 540
 }
541 541
 
542
-private function printNMScript($SSIDs,$delSSIDs) {
542
+private function printNMScript($SSIDs, $delSSIDs) {
543 543
    $e = \core\common\EAP::eapDisplayName($this->selectedEap);
544 544
 $out = 'function run_python_script {
545 545
 PASSWORD=$( echo "$PASSWORD" | sed "s/\'/\\\\\\\'/g" )
@@ -678,11 +678,11 @@  discard block
 block discarded – undo
678 678
             \'eap\': [\''.strtolower($e['OUTER']).'\'],
679 679
             \'identity\': \'$USER_NAME\',
680 680
             \'ca-cert\': dbus.ByteArray("file://{0}\0".format(self.cacert_file).encode(\'utf8\')),';
681
-    if($this->server_name) {
681
+    if ($this->server_name) {
682 682
              $out .= '
683 683
              match_key: match_value,';
684 684
     }
685
-    if($this->selected_eap == \core\common\EAP::EAPTYPE_TLS) {
685
+    if ($this->selected_eap == \core\common\EAP::EAPTYPE_TLS) {
686 686
        $out .= '
687 687
             \'client-cert\':  dbus.ByteArray("file://{0}\0".format(self.pfx_file).encode(\'utf8\')),
688 688
             \'private-key\':  dbus.ByteArray("file://{0}\0".format(self.pfx_file).encode(\'utf8\')),
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
        $out .= '
692 692
             \'password\': \'$PASSWORD\',
693 693
             \'phase2-auth\': \''.strtolower($e['INNER']).'\',';
694
-         if($this->attributes['internal:use_anon_outer'][0] == 1) 
694
+         if ($this->attributes['internal:use_anon_outer'][0] == 1) 
695 695
               $out .= '
696 696
             \'anonymous-identity\': \''.$this->attributes['internal:anon_local_value'][0].'@'.$this->attributes['internal:realm'][0].'\',';
697 697
     }
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
         self.check_opts()
714 714
         ver = self.connect_to_NM()';
715 715
      foreach (array_keys($SSIDs) as $ssid) {
716
-           $out .='
716
+           $out .= '
717 717
         self.delete_existing_connections(\''.$ssid.'\')
718 718
         self.add_connection(\''.$ssid.'\')';
719 719
      }
720 720
 //   create a list of profiles to be deleted after installation
721 721
      foreach ($delSSIDs as $ssid => $cipher) {
722
-         if($cipher == 'DEL')
723
-            $out .='
722
+         if ($cipher == 'DEL')
723
+            $out .= '
724 724
         self.delete_existing_connections(\''.$ssid.'\')';
725 725
      }
726 726
 
727
-$out .='
727
+$out .= '
728 728
 
729 729
 if __name__ == "__main__":
730 730
     ENMCT = EduroamNMConfigTool()
Please login to merge, or discard this patch.