Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set variable for password in netconfig.rb #43

Open
apinter opened this issue Jul 7, 2015 · 4 comments
Open

Set variable for password in netconfig.rb #43

apinter opened this issue Jul 7, 2015 · 4 comments

Comments

@apinter
Copy link

apinter commented Jul 7, 2015

Hi Guys,

Started to play around with Concerto a few days ago, it is awesome, but noticed that it can, but out of the box can't connect to encrypted wireless networks (wpa personal) so I added a field in ../application/views/netsettings.erb which is fine and tried to add an instance variable in ../lib/bandshell/netconfig.rb @pwas:

class WirelessConnection
def initialize(args={})
@SSID = args['ssid'] || ''
@interface_name = args['interface_name'] if args['interface_name']
@wpa_config_file = '/tmp/wpa_supplicant.concerto.conf'
@pwas = args['pwas'] || ''
end

attr_accessor :pwas, :ssid, :interface_name

def config_interface_name
  # If the user has requested a specific interface, use it.
  # Otherwise, just pick the first wlan interface, assuming
  # it works and all wlan interfaces have approximately equal
  # reception. When this assumption is wrong the user must force.
  if @interface_name && @interface_name != ''
    @interface_name
  else
    self.class.interfaces[0].name
  end
end

def validate
  if @ssid == ''
    fail "Need SSID for wireless connection"
  end
end

def safe_assign
  [ :pwas, :ssid, :interface_name ]
end

def write_configs
  # Write a wpa_supplicant.conf file for an unsecured network.
  File.open(@wpa_config_file, 'w') do |wpaconf|
    # long lines, sorry!
    wpaconf.puts "ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev"
    wpaconf.puts "network={"
    wpaconf.puts "ssid=\"#{@ssid}\""
    wpaconf.puts "scan_ssid=1"
    wpaconf.puts "key_mgmt=wpa"
    wpaconf.puts "password=#{@pwas}"
    wpaconf.puts "}"
  end
end

def interfaces_lines
  # This links the wpa config to the interfaces file.
  ["wpa-conf #{@wpa_config_file}"]
end

def args
  {
    'interface_name' => @interface_name,
    'ssid' => @ssid
    'pwas' => @pwas
  }
end

This clearly not working, can you please advise where can I set this variable to make sense?

Thanks in advance!

@augustf augustf changed the title Set variable for password in netcofnig.rb Set variable for password in netconfig.rb Jul 7, 2015
@augustf
Copy link
Member

augustf commented Jul 7, 2015

@asquared Would adding a password field to pass along to wpa_supplicant will be sufficient here? It wouldn't seem to me to be that simple...

@asquared
Copy link
Member

asquared commented Jul 8, 2015

It looks like the key_mgmt option needs to be set to WPA-PSK and the option for the password is then called "psk", not "password".

I would also advocate for making this a new class of connection, perhaps a subclass of WirelessConnection, or an object that plugs into WirelessConnection. There are many different kinds of wireless authentication that might be in use in a Concerto deployment, so we want to factor this in a way that allows new methods to be added easily.

@asquared
Copy link
Member

asquared commented Jul 8, 2015

For reference, here's the man page for wpa_supplicant.conf: http://manpages.ubuntu.com/manpages/hardy/man5/wpa_supplicant.conf.5.html

@apinter
Copy link
Author

apinter commented Jul 9, 2015

Guys, the question is not exactly about wpa_suppilcant, I know how to configure it, was just posting a silly example (was lazy to copy from my vm, sorry). The problem what I have unfortunately is that I'm not able to define a variable to the password field on the GUI which would pass the input to the wpa_supplicant eventually. Think it would be awesome to have a function like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants