After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 756081 - Add 'nmcli device wifi hotspot' for easy creation of a Wi-Fi hotspot
Add 'nmcli device wifi hotspot' for easy creation of a Wi-Fi hotspot
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: nmcli
git master
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks: nm-review
 
 
Reported: 2015-10-05 15:14 UTC by Jiri Klimes
Modified: 2015-11-10 08:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
"iw list" output (7.79 KB, text/plain)
2015-11-08 14:45 UTC, Beniamino Galvani
Details

Description Jiri Klimes 2015-10-05 15:14:31 UTC
nmcli allows creating a hotspot. But that requires two step operation. First a connection with the right parameters has to be created, and only then a hotspot can be activated.

It could to be useful to have a simple command for setting up a hotspot.
Comment 1 Jiri Klimes 2015-10-05 15:16:29 UTC
Implemented the command:
nmcli device wifi hotspot [ifname <ifname>] [con-name <name>] [ssid <SSID>] [band a|bg] [channel <channel>]

See jk/nmcli-hotspot branch.
Comment 2 Thomas Haller 2015-10-05 16:26:25 UTC
It seems to me that this command is too specific. Very few people will actually need it, and those who do probably are not happy with the generated connection.

-- for example, the password cannot be specified. I would not want to leave the password generation up to nmcli.
But even then, before the user can connect any clients, he has to lookup the generated password:
  nmcli connection show --show-secrets 
and at that point, it's not clear how "two steps" were saved.

(I don't agree in favor for a "[password <password>]" option)


Also, the created connection depends on the detected capabilities. That is great, but you cannot inspect what will be created. E.g. activating an open/WEP hotspot by accident seems like a security issue.





It is indeed great, the create a Hotspot connection by checking device capabilities!! The detect&create part is very useful.

But I'd rather see a command that prints such a created connection to stdout only, and a command that can create a connection by reading stdin.



I'd go from a UI model where
  "there is a specific commands to do a whole chain of actions"
to
  "individual (generic) commands can be combined by chaining them"
Comment 3 Thomas Haller 2015-10-05 16:28:31 UTC
(In reply to Thomas Haller from comment #2)

> (I don't agree in favor for a "[password <password>]" option)

s/agree/argue/
Comment 4 Jiri Klimes 2015-10-06 06:24:15 UTC
I think the command is useful and basically is does the same think as "Use as Hotspot" button in gnome-control-center, that does not see it as a problem.

Anyway, power users can always create a hotspot connection manually if they want, but for normal usage the created hotspot is sufficient in my opinion. And it does not create open network, but WPA or WEP one.
We could add a "password" parameter if it is seen as important.
Comment 5 Lubomir Rintel 2015-10-06 11:53:52 UTC
This looks good to me (both the code and the idea).
Comment 6 Jiri Klimes 2015-10-14 10:25:35 UTC
Added password-related options to the branch.
Comment 7 Thomas Haller 2015-10-20 13:06:11 UTC
>> cli: add 'show-password' option for 'nmcli device wifi hotspot'
   

I think, show-password should be an option. Now it looks like a property of the hotspot connection itself.

Rather:

  wifi hotspot [--show-password] [ifname <ifname>] [con-name <name>]...



Also, a trailing whitespace in 
+    if (show_password)
+         g_print (_("Hotspot password: %s\n"), key);
+    
     return TRUE;
Comment 8 Jiri Klimes 2015-10-20 13:50:44 UTC
(In reply to Thomas Haller from comment #7)
> >> cli: add 'show-password' option for 'nmcli device wifi hotspot'
>    
> 
> I think, show-password should be an option. Now it looks like a property of
> the hotspot connection itself.
> 
> Rather:
> 
>   wifi hotspot [--show-password] [ifname <ifname>] [con-name <name>]...
>
Done.
 
> 
> Also, a trailing whitespace in 
> +    if (show_password)
> +         g_print (_("Hotspot password: %s\n"), key);
> +    
>      return TRUE;
Fixed.
Comment 9 Beniamino Galvani 2015-10-22 15:31:56 UTC
> nmcli: add an hotspot example to nmcli manual page

+creates a hotspot profile and connects it. Prints the hotpsot password the user should use

s/hotpsot/hotspot/

If I try:

 $ nmcli dev wifi hotspot con-name QuickHotspot --show-password
 Hotspot password: d5f19pWI
 Error: Failed to setup a Wi-Fi hotspot: 802-11-wireless-security.pairwise: 'adhoc' connections require 'none' in this property

What am I doing wrong?
Comment 10 Jiri Klimes 2015-10-23 11:55:47 UTC
(In reply to Beniamino Galvani from comment #9)
> > nmcli: add an hotspot example to nmcli manual page
> 
> +creates a hotspot profile and connects it. Prints the hotpsot password the
> user should use
> 
> s/hotpsot/hotspot/
> 
Fixed.

> If I try:
> 
>  $ nmcli dev wifi hotspot con-name QuickHotspot --show-password
>  Hotspot password: d5f19pWI
>  Error: Failed to setup a Wi-Fi hotspot: 802-11-wireless-security.pairwise:
> 'adhoc' connections require 'none' in this property
> 
> What am I doing wrong?

You do it right. You just have a card supporting adhoc WPA. And we require "none" in pairwise property.
libnm-core/nm-setting-wireless-security.c:verify()

I have tried now with a USB adapter
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
and got the same error.

Fixed by adding "none" with nm_setting_wireless_security_add_pairwise (s_wsec, "none");

Great you caught that!
Comment 11 Beniamino Galvani 2015-11-02 13:56:09 UTC
Ok, now the hotspot creation succeeds. But I noticed that even if the
connection is created with a password, clients are able to connect
without any authentication. I haven't investigated why yet.
Comment 12 Jiri Klimes 2015-11-06 12:54:15 UTC
(In reply to Beniamino Galvani from comment #11)
> Ok, now the hotspot creation succeeds. But I noticed that even if the
> connection is created with a password, clients are able to connect
> without any authentication. I haven't investigated why yet.

It may be the problem of kernel creating open network instead of AdHoc with WPA.
See e.g.
https://bugzilla.redhat.com/show_bug.cgi?id=818214
https://bugzilla.redhat.com/show_bug.cgi?id=787733

We should probably use WEP instead of WPA if we can detect that the device only supports AdHoc (IBSS) mode instead of AP.

What device do you use?

$ iw list | grep -A 8 "Supported interface modes:"

# iw dev <device name> list
  when you connect the profile
$ nmcli d w
on the machine with Hotspot and on the other you connect with.
Comment 13 Dan Williams 2015-11-06 23:45:19 UTC
nl80211 reports whether the device supports RSN-IBSS through the wiphy attribute NL80211_ATTR_SUPPORT_IBSS_RSN.  We should check that and add a new NM_WIFI_DEVICE_CAP_ADHOC_RSN capability which nmcli could then detect.  But that can happen later after this branch gets merged.


> cli: add 'nmcli device wifi hotspot' command

In set_wireless_security_for_hotspot() I think the mode should be "wpa-psk" for the NM_SETTING_WIRELESS_MODE_AP case.  WPA-NONE is only for IBSS mode.

For IBSS/AdHoc, wpa-none only gets used with IBSS TKIP.  The supplicant sample wpa_supplicant.conf file says that WPA-PSK also gets used with adhoc RSN.
Comment 14 Beniamino Galvani 2015-11-08 14:45:06 UTC
Created attachment 315077 [details]
"iw list" output

(In reply to Jiri Klimes from comment #12)
> What device do you use?

04:00.0 Network controller [0280]: Intel Corporation Wireless 7260 [8086:08b2] (rev bb)

> $ iw list | grep -A 8 "Supported interface modes:"

	Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * monitor
                 * P2P-client
                 * P2P-GO
                 * P2P-device

> # iw dev <device name> list

Attached output of 'iw list' ('iw dev <dev> list' doesn't work).

>   when you connect the profile
> $ nmcli d w
> on the machine with Hotspot

*  SSID        MODE   CHAN  RATE      SIGNAL  BARS  SECURITY
*  Hotspot-tp  Infra  1     0 Mbit/s  0       ____  WPA1

> and on the other you connect with.

I'm using an Android phone.
Comment 15 Jiri Klimes 2015-11-09 16:11:31 UTC
(In reply to Dan Williams from comment #13)
> nl80211 reports whether the device supports RSN-IBSS through the wiphy
> attribute NL80211_ATTR_SUPPORT_IBSS_RSN.  We should check that and add a new
> NM_WIFI_DEVICE_CAP_ADHOC_RSN capability which nmcli could then detect.  But
> that can happen later after this branch gets merged.
>
Great. I filed a bug for that - bug 757823.

> 
> > cli: add 'nmcli device wifi hotspot' command
> 
> In set_wireless_security_for_hotspot() I think the mode should be "wpa-psk"
> for the NM_SETTING_WIRELESS_MODE_AP case.  WPA-NONE is only for IBSS mode.
> 
> For IBSS/AdHoc, wpa-none only gets used with IBSS TKIP.  The supplicant
> sample wpa_supplicant.conf file says that WPA-PSK also gets used with adhoc
> RSN.

Fixed.
Now only using "wpa-psk" when with AP mode. For IBSS, the branch uses WEP to work around the kernel IBSS vs. WPA problem issue.

(In reply to Beniamino Galvani from comment #14)
> *  SSID        MODE   CHAN  RATE      SIGNAL  BARS  SECURITY
> *  Hotspot-tp  Infra  1     0 Mbit/s  0       ____  WPA1
> 
Hmm, it seems that the AP has a security. Anyway it might be caused by the wpa-none value. Would you try again with the re-pushed branch?
Comment 16 Beniamino Galvani 2015-11-09 17:05:59 UTC
(In reply to Jiri Klimes from comment #15)
> Hmm, it seems that the AP has a security. Anyway it might be caused by the
> wpa-none value. Would you try again with the re-pushed branch?

Now it works for me, a password is needed to connect.
Comment 17 Jiri Klimes 2015-11-10 08:39:11 UTC
Code merged to master branch:
2b4b78e merge: add 'nmcli device wifi hotspot' command (bgo #756081)
fe5927a nmcli: add a hotspot example to nmcli manual page
2f52a10 cli: add '--show-password' option for 'nmcli device wifi hotspot'
781d24f cli: add 'password' option for 'nmcli device wifi hotspot'
d6427d7 cli: add 'nmcli device wifi hotspot' command
cd217db cli: move unique_connection_name() to common.c as nmc_unique_connection_name()