Search This Blog

Wednesday, March 30, 2011

E-sata, solid, and udisks

Last year I wrote about how to hack hal to recognise disks attached to an e-sata port as removable. Now that udisks is the default disk manager in Solid I will explain how to hack udisks to do the same:

  1. The hal hack is just a xml file that overrides disk's removable flag. With udisks things are a bit more complicated. I had to apply this patch to udisks and recompile it. The patch adds the flag UDISKS_FORCE_SYSTEM_INTERNAL, which lets us mark the disk as internal or external (AKA removable).
  2. Restart udisks. Just kill it and it will restart automatically: killall udisks-daemon # as root
  3. After that we need to add an udev rule which will actually mark the disk as removable:
  4. File /etc/udev/rules.d/99-esata.rules
    DEVPATH=="/devices/pci0000:00/0000:00:1f.2/host4/*", ENV{UDISKS_FORCE_SYSTEM_INTERNAL}="0"
    Change the DEVPATH to match your e-sata port. You can find it using the command:
    evolucao ~ # find /sys/devices/ -name sdb
  5. Reload udev rules: udevadm control --reload-rules
That is it :-)

There is already a bug entry about the e-sata problem in udisks' bugzilla. In fact, I found the UDISKS_FORCE_SYSTEM_INTERNAL patch in that bug entry.

Sunday, March 27, 2011

Plasma NM: bugs fixed

Since Plasma NM does not follow KDE SC release schedule I thought posting a list of bugs fixed should be a good idea. Some users do not know we do not follows KDE SC release schedule, some distribution packagers also seem to not know which important bugs have been fixed this year.

Fixes commited between 4.6.1 and 4.6.2 release dates (March 4th - April 6th):

212941214985: Ah-hoc wireless and connection sharing are working now. Many thanks to Ilia Kats for this patch.
. Now it is possible to click on the AP name (essid) in the main window and Plasma NM will launch the configuration dialog with the essential settings (connection name, essid, encryption type) already filled in and ask for encryption key. After that the user just need to click on the Ok button to complete the configuration.
269853: Opens Mobile Connection Wizard to create a 3G connection when modem is inserted and no 3G connection has been created yet.
208219: Add PEAP-GTC wireless authentication.
257777: do not save secrets if user asked for it.
241798: vpnc: fix storing/loading of secrets type
268484: Do not send "low signal" notification if connection is not activated.
262555: fix missing secrets for VPN plugins without explicit  storage type.
243792: fix connecting to WiFi when "In file (unencrypted)" secrets storage is used.
267952: Enable Del key to remove connection.
267967: Sanitize the Networking, Wireless and Wwan checkbox handling.
. Fix changing VPN password type not being recognised until user logout/login.

Fixes commited between 4.6.0 and 4.6.1 release dates (January 26th - March 4th):

267556: Hide the "Enable Wireless" checkbox if there is no wireless interface available.
248348: Fix potential crash.
263286: Enable notifications.
253584: Prevent potential crash.
266807: Comment some code that unnecessarily triggers polkit authentication agent.
264607: Fix crash in Mobile Connection Wizard.
238046: Fix knetworkmanager doesn´t recognize BSSID.
266097: Fix potential crash.
210878: Another try to solve the dangling pointers problem.
. Add support to Wwan (AKA Mobile Broadband) on/off switch.
. Make most of the wifi info work.
. Fix memory leak.
. Insert the right catalogs to translate UI.
. Support to show details for interface usb0.

Fixes commited in 2011 and before 4.6.0 release date:

255855261738256031: Fix crashes in Mobile Connection Wizard.
255508: Restrict the connection name label in the networkmanagement. Also corrected two typos.
. Default configuration module (kcm) to wireless tab.
. Fix crasher when an interface that's gone unavailable is disconnected.
. Changes to make cmake warns about mobile-broadband-provider-info package presence/omission.

Some important fixes commited last year:

210878: Plasma NM (and Knetworkmanager) crashes when restarting NetworkManager. Note: Not all crash cases have been fixed yet.
244416: New files for VPNC auth UI, VPNC authentication UI allowing one time secrets.
150680: Support password protected keys in OpenVPN.
. Mobile Connection Wizard to create Gsm/Cdma connections commited.

You can get a more detailed list here or cloning the repository and using git log.

Plasma NM: big feature (in progress...)

System connection implementation is progressing in Plasma NM. Andrey Borzenkov took over the task of maintaining Gökçen Eraslan's system connection implementation. It is working, I am using it right now but it still needs some adjustments before we push it to master branch though. Anybody willing to test it can get the patch in Please report bugs in the system connection bug entry in

Meanwhile, I created a nm09 branch to let others, specially Jiří Klimeš and Andrey Borzenkov, implement the necessary changes for NetworkManager-0.9 support. The code in that branch does not work with NetworkManager-0.8, only with NetworkManager-0.9.

Thursday, March 10, 2011

Plasma NM: big feature (bigger than I have thought)

When I got the idea to implement system connections I thought in just fixing a bug, but since NetworkManager is changing its API and ABI during the 0.8 to 0.9 transition the challenge has increased.

The main change from 0.8 to 0.9 specification is that now all connections are system wide with new DBus interfaces for the clients (Plasma NM for instance) to provide secrets (user name, password, encrpyt keys) to NetworkManager. Most of the changes are there to shrink NM's clients (Plasma NM, nm-applet, cnetworkmanager) source code, so it seems to be good change. We will need to change Solid's NM backend to meet the new specificaton, which can be problematic for distributions because they will only be available in KDE SC 4.7, scheduled to be released in late July.

Talking about distributions, one Fedora guy showed up in kde-networkmanagement mailinglist. NM-0.9 is going to be released next week and Fedora guys are thinking in using NM-0.9 in F15, preferably with a working Plasma NM. To do so would require changes in KDE SC 4.6x API used in F15, something that KDE tries really hard to avoid.

One good news is that a guy from Pardus Linux (Gökçen Eraslan) have been working in implementing system connections since last year, I just forgot about that hehe, sorry. So we already have a working implementation but Gökçen Eraslan still have not answered my e-mail about his implemenation. If it is working good with no side-effects we can add it to networkmanagement master repository and starting from there to meet NM 0.9 specification from Plasma NM's point of view. The Solid's NM backend part will need more discussing about how to proceed.

Monday, March 7, 2011

Plasma NM: big feature

Now that I have commited the read/save plasmoid state patch it is time to implement a big feature. Before that I must say that there is a bug in Solid's NetworkManager backend, it does not emit the wirelessHardwareEnabledChanged signal. Without that signal the "Enable wireless" checkbox does not work as expected, sometimes it gets disabled (read-only), so I suggest that distribution packagers apply this one line patch to fix the problem. The patch will be available in KDE SC 4.6.2.

Turning the big feature, nothing better to implement than the most hated Plasma NM bug: knetworkmanager does not show system connections. I spend last Sunday trying to understand how to list system connections, that part now works:

Now I need to fill in the blanks in the edit dialog:

As I could see in command line NM shows very few information about my ethernet connection:

For instance it does not show the autoconnect state or if the interface should use DHCP or not. I suppose autoconnect and DHCP are default states, so they are not shown.

I think I can finish a working implementation by the end of this week and post it in for suggestions.

Sunday, March 6, 2011

Plasma NM: small feature

In the last days I have been trying to figure out how to "enable" Mobile Broadband modems by default. By "enable" I mean make the modem powers up when it is attached to the computer. NetworkManager and ModemManager require the modem to be "enabled" before using it.

I have always thought it should be something simple like modem = Solid::Control::ModemManager::findModemInterface(...); modem->enable(true). Actually that sample code works... for root only. ModemManager protects most of its DBus interface through policy-kit, so I had to figure out how to do it for normal users without asking for a password. As you probably know, Plasma NM run as normal user, not root. Time to take a look at how nm-applet does that.

After some digging in nm-applet source code I found this function nm_client_wwan_set_enabled. I have never seen that "wwan" interface in NetworkManager specification, the public specification did not mention it some days ago. In the end I figured out wwan is a synonym for mobile broadband. Today I have looked at the specification site again and now there is a 0.9 specification that mentions wwan, although NetworkManager 0.8 supports wwan but the 0.8 specification does not mention that, cool, huh?

Anyway, now that I know those functions are there, I have updated Solid::Control::NetworkManager to make use of them. The changes are already in kde://kde-workspace and kde://networkmanagement, they are going to be available in KDE SC 4.7. The visual changes in Plasma NM are very small, just a new checkbox called "Enable mobile broadband". The checkbox is visible only when there is at least one Gsm/Cdma modem attached. Following the same idea, I have changed the "Enable wireless" checkbox to also be visible only when there is at least one wireless card attached.

When you attach a modem to your computer ModemManager disables it by default. NetworkManager disables wwan if all modems are disabled, which means everytime you attach a modem NM will disable wwan. Even worse, if you have two modems, attach the first, enable wwan, attach the second modem, NM will disable wwan because the last modem is disabled. Nm-applet also demonstrates the same behavior in my tests. I think that explains why sometimes when my notebook is connected through 3G and I attach my cellphone in "PCSuite mode" to my notebook the 3G connection drops. To workaround the enable/disable problem I am using a QTimer::singleShot(...) to enable wwan after NM disables it if the mobile broadband checkbox is checked. Seems to work.

Now that I can enable/disable wwan the next thing to implement is saving the plasmoid configuration. Plasma NM is splitted into two parts, one plasmoid and a kded module. The kded module already saves its configuration, it is responsible to talk to NetworkManager and ModemManager and manages all interfaces. Of course the plasmoid is the user interface, it does not save its configuration yet, that is why everytime you resume from ram or disk the wireless state is on, it is on because your computer's BIOS set it to on, not Plasma NM. Plasma NM just reads the wireless state from NetworkManager.

The plasmoid state is just those three checkbox (Networking, Wireless and Mobile Broadband). I plan to save those three state to a configuration file and restore them when Plasma NM is started or resumes from ram/disk. So if the user set wwan to enable and attaches a modem to his/her computer, the modem will be be enabled after a short flux of DBus calls. Use dbus-monitor to see what I am talking about :-)