[wpa key management is down inside /etc/network/interfaces Olivier Schwander **20120803144538 Ignore-this: 31e3ace790a0170b5a03dc47dbfa73e9 ] hunk ./MANIFEST 11 -lib/Ifweb/WPA_Supplicant.pm hunk ./lib/Ifweb.pm 10 -use Ifweb::WPA_Supplicant; hunk ./lib/Ifweb.pm 112 - $essid, - $encryption, - "$essid"; - my $wpa_supplicant = Ifweb::WPA_Supplicant::config_template - $essid, - $encryption, - "$key"; + $cell, + "$essid", + "$key", + ; hunk ./lib/Ifweb.pm 128 - wpa_supplicant => $wpa_supplicant, - key => $key, + key => $key, hunk ./lib/Ifweb.pm 143 - $essid, - $encryption, - $name; - my $wpa_supplicant = Ifweb::WPA_Supplicant::config_template - $essid, - $encryption, + $cell, + $name, hunk ./lib/Ifweb.pm 148 - my $wpa_dir = config->{wpa_dir}; hunk ./lib/Ifweb.pm 149 - my $wpa_file = $wpa_dir . "/" . $name . ".conf"; - - if (-e $wpa_file) { - session info => undef; - session error => "The network $name already exists !"; - session question => undef; - session msg_seen => false; - - redirect "/select?id=$id"; - } - else { - print STDERR $interfaces_file, ":\n"; - print STDERR $interfaces, "\n"; - open(my $file_if, '>>', $interfaces_file); - print $file_if $interfaces; - close($file_if); - - if (defined($wpa_supplicant)) { - print STDERR $wpa_file, ":\n"; - print STDERR $wpa_supplicant; - open(my $file_wpa, '>', $wpa_file); - print $file_wpa $wpa_supplicant; - close($file_wpa); - } + print STDERR $interfaces_file, ":\n"; + print STDERR $interfaces, "\n"; + open(my $file_if, '>>', $interfaces_file); + print $file_if $interfaces; + close($file_if); hunk ./lib/Ifweb.pm 155 - session info => "Network $name successfully added for ESSID $essid."; - session error => undef; - session question => {text => "Do you want to bring it up now ?", yes => "Yes"}; - session msg_seen => false; + session info => "Network $name successfully added for ESSID $essid."; + session error => undef; + session question => {text => "Do you want to bring it up now ?", yes => "Yes"}; + session msg_seen => false; hunk ./lib/Ifweb.pm 160 - redirect '/'; - } + redirect '/'; hunk ./lib/Ifweb/Ifupdown.pm 91 - my ($essid, $encryption, $name) = @_; - my $content; + my ($cell, $name, $key) = @_; + my $content = "iface $name inet dhcp\n"; hunk ./lib/Ifweb/Ifupdown.pm 94 - if ($encryption eq 'Off') { - $content = <{encryption} eq 'Off') { + $content .= " wireless-essid ". $cell->{ESSID}. "\n"; hunk ./lib/Ifweb/Ifupdown.pm 98 - $content = <{encryption} eq 'WEP') { + $content .= " wireless-essid ". $cell->{ESSID}. "\n"; + $content .= " wireless-key $key\n"; + } + else { + if ($cell->{encryption} eq 'WPA-PSK') { + $content .= " wpa-ssid ". $cell->{ESSID}. "\n"; + $content .= " wpa-psk $key\n"; + } + } hunk ./lib/Ifweb/Ifupdown.pm 109 + hunk ./lib/Ifweb/WPA_Supplicant.pm 1 -package Ifweb::WPA_Supplicant; - -use strict; -use warnings; - -use Dancer ':syntax'; - -sub config_template { - my ($essid, $encryption, $key) = @_; - my $content; - - if ($encryption eq 'Off') { - $content = undef; - } - - if ($encryption eq 'WPA-PSK') { - $content = < +<% IF encryption != "Off" %> hunk ./views/select.tt 25 -<% IF wpa_supplicant %> -

/etc/wpa_supplicant/<% essid %>.conf

-
-<% wpa_supplicant %>
-
-<% END %> -