Jul 14, 2008

cnetworkmanager 0.7.1

Cnetworkmanager is a command-line client for NetworkManager, intended to supplement and replace the GUI applets. So far it is a single python script. What is new in version 0.7.1:
  • it does not need a configuration file anymore:
    cnetworkmanager -C publicnet
    cnetworkmanager -C myessid --wep-hex 112234445566778899aabbccdd
    cnetworkmanager -C another --wpa-psk-hex \
  • it works with NM 0.6 (tested on Ubuntu 8.04 Hardy and a pre-release OLPC) in addition to the older support for NM 0.7pre (tested on openSUSE 11.0)
What is still left to do:
  • sooner:
    • specifying the key as a non-hex passphrase
    • reading the configuration stored by the GNOME nm-applet
    • possibility to quit after a connection is established
  • later:
    • more encryption schemes (WPA2?)
    • more connection types (dial-up, VPN)


Matteo Nardi said...

I want to thank you for cnetworkmanager, it gave me an internet connection on my laptop running arch linux, since knetworkmanager is not working anymore because of the recent kde4 update..

Thank you!

Vincent Aravantinos said...

I am currently trying to use cnetworkmanager 0.7.1 in an environment without even X11. And it gives me the following error while trying to connect :

gentoo - vincent> cnetworkmanager -C MyNet
cnetworkmanager 0.7.1 - Command Line Interface for NetworkManager
Traceback (most recent call last):
File "./cnetworkmanager.py", line 1256, in (module)
brn = bus.request_name(NMIC, _dbus_bindings.NAME_FLAG_DO_NOT_QUEUE)
File "/usr/lib64/python2.5/site-packages/dbus/bus.py", line 306, in request_name
'su', (name, flags))
File "/usr/lib64/python2.5/site-packages/dbus/connection.py", line 607, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Connection ":1.23" is not allowed to own the service "org.freedesktop.NetworkManagerInfo" due to security policies in the configuration file

This is probably a stupid question, but is NetworkManager supposed to work even without a desktop ? It seems very desktop-related, isn't it ?

I am actually trying to use it due to problems with wpa_supplicant...

(don't know if it's the good place to ask my question, sorry for the noise if it's not :-)


Anonymous said...

This is great! Thank you for this. I can now run openSUSE on a most basic install (No X) through wireless.

I did have to do one thing - change some dbus rules otherwise I would get weird permission errors with your script.

I made sure I had:

policy user="root"
allow own="*"
allow send_interface="*"

in the /etc/dbus-1/system.d directory. (I put it in nm-dhcp-client.conf)

Then everything works fine. However, I do not believe this workaround to be very secure. Is there some package I am missing to fix these dbus errors? Something not graphic related I hope.


Martin Vidner said...

G, that's a good catch. I guess that your errors are related to the NetworkManagerUserSettings service, aren't they? On my system, I do have the GUI applet packages installed and they provide policy files to allow access to the settings. Yes, cnetworkmanager should carry its own policy file to fix that.

See whether nm-applet.conf fixes it for you. Your own policy is wide, but root can do everything anyway, so I don't think it is a security problem.

That also answers Vincent's question which I forgot about (sorry).

Vincent Aravantinos said...

Sorry, I finally managed my Wifi with wpa_supplicant. So I can't provide more feedback... But thanks for answering !

Anonymous said...


You are correct. This solved the problem perfectly. Thank you very much for your good work.


Anonymous said...

I really think it is a great idea to have a commandline client for network manager. Especially for those of us who do not use desktop environments. Good stuff!

Sadly I could not get WPA2 to work with this, and then I read here that it is not supported yet. I will watch this space :)

Anonymous said...

I am trying to get the latest git version working under Fedora9 and am getting the following error:

dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: No such property Hostname

when running:
./cnetworkmanager -a

It does show my eth0 network ok first.

Arne Bergene Fossaa - said...

Don't know if you would need this, but here is small patch that adds the ability to you use WPA passphrases. Simply added a module that computes the passphrase. Haven't tested this 100%, but should work:


Martin Vidner said...

Arne, thanks! I have finally gotten around to testing it, and it is committed now (with a different, non-advertising pbkdf).

Anonymous said...

Thank you for cnetworkmanager to help those that don't use GNOME or KDE! In my specific case (hidden access point with open WEP), it fails to connect (cannot find AP).
It can connect though after having used nm-applet to connect and disconnect once before in the same login session (even after leaving the X session).

mr G said...

hi, I am trying the 0.8.1 version.
I am not sure if I understood everything properly; when I run cnetworkmanager -d, it shows among devices my mobile internet device, ttyUSB0. so that's good. However, I don't seem able to make a connection; I named it 'mobiel' in knetworkmanager, and it appears under ifconfig as 'ppp0'. So I guess the network name is 'mobiel', right?
so I do:

cnetworkmanager -C mobiel

but it tells me 'no AP found with SSID mobiel'.
tried some other names but to no avail. Am I missing a point here? or does it only connect to wifi networks?


Martin Vidner said...

mr G, sorry, it only works with WiFi now.

mr G said...

thanks, that's what I wanted to know. I'm trying to get my fluxbox to work without using anything of the kde that I have installed alongside, as a lightweight alternative. I'll give wicd a try.

Xaxalo said...

could you tell me how can i use it (im newbie in python), when i try use it, i see :

ImportError: No module named pbkdf2

I was download PBKDF2.py and save into /usr/lib/python2.5 but doesnt solve my problem.

best regards

Sven said...

Thanks for this useful tool!
It is very relevant for all of us that
do not use kde or gnome.

Any news about WPA2 support?

Socially Active said...

I am currently using cnetworkmanager 0.8.4

And is is a great tool!

From my perspective networking should NOT depended on a gui for configuration. NetworkManager is SHIT, because it prevents me from scripting fall back connections. Or editing the current connections from the command line.

I want to script cnetworkmanager.

If cnetworkmanager is scriptable. I can remotely boot my laptop and have it walk though my configured network connections trying each in order.

I want the order network connections listed in the order they would be tried.

With the current and previous alternate successful connect marked.

cnetworkmanager is much better than NetworkManager.
How can I which connection is used?
How can I edit NetworkManager connections from the commandline?

Thx in advance for any advice you have!

jago25_98 said...

python -v --> mine was 2.6. then copy the .py to usr/lib/version it said/dist-packages

Bruce said...

When will people realize that not everyone is a point and click monkey.

Thank you!!

Any chance of adding this as an Ubuntu/debian package?

Martin Vidner said...

Bruce, if you google cnetworkmanager debian or cnetworkmanager ubuntu, you will find some Intents To Package it and someone's PPA.

qubodup said...

Thanks for this applet - too bad it lacks vpn, which makes it useless at uni for me :(