Skip to content

Be wary of “optimised for …” devices

Hello

This story began with linphone having a weird behavior: every now and then, the mouse pointer would become stuck: the pointer moves, but clikcking on it always activate the same widget. Since this always happened in the middle of phone conference done for work, this was infuriating.

Long story short, I finally found that my plantronics USB headset was responsible for this weird behavior. This headset is connected to the USB bus and is seen by the computer as a USB sound card. The bug was triggered by pressing the “mute” button provided by the headset.

Suspicious of this usb device, I used lsusb to find the features provided by the heaset:

$ lsusb -v -s 1:3 2>&1 |grep InterfaceClass
bInterfaceClass 1 Audio
bInterfaceClass 1 Audio
bInterfaceClass 1 Audio
bInterfaceClass 1 Audio
bInterfaceClass 1 Audio
bInterfaceClass 3 Human Interface Device

Audio devices were expected, but why a HID device ? This device is a headset, not a keyboard or a mouse… Testing further, I also saw some number poping up on my screen whenever I pressed the the mute button. The only way to get the mouse back was to unplug the headset.

A quick google search gave a solution to setup X11 to ignore the headset. Problem solved.

But this did not answer the question regarding the HID device. Then I got a hint in the form of a sticker glued on the headset USB plug: “Optimized for Microsoft Lync”. This page gave the answer: an “optimised for Lync” device provides “mute/unmute across PC and device”.

I can only guess that when the mute button is pressed, some data is sent from the HID interface. Unfortunately, the window manager does not like to be on the receiving end of this data.

The moral of this story is: “optimized for something” actually means “not standard“.

ok. There’s a bug somewhere. The comments of this blog have convinced me that I went too far with the moral of this story. It’s now overstriked instead of plainly remvoed so the comments still make sense.

Thanks everybody for the constructive comments.

All the best

How to fix a configuration model

Hello

I’ve written a tutorial to show how a configuration model can be updated to cope with new features provided by new software release.

This tutorial shows how to add a new parameter provided by OpenSsh 5.9 into Ssh model. This example can be applied to other models (like Dpkg model).

I hope that people will be able now to perform simple enhancements to current models.

Feedback are welcome

Dpkg source editor/checker is going native

Hello

As Config::Model was becoming too big with too many dependencies, I’ve moved all Debian stuff from Config::Model repository into a separate Debian repository.

If you install only libconfig-model-perl 2.026-1 (from experimental), the command ‘cme check dpkg’ will not work. You must also install libconfig-model-dpkg-perl to get it back. libconfig-model-dpkg-perl is currently in experimental.

libconfig-model-dpkg-perl repository is hosted on Alioth in debian perl-packaging team and is a Debian native package. Nevertheless, it will be uploaded to CPAN. (just like dh-make-perl).
All people involved in packaging are welcome to hack it or suggest improvements

I’ll upload both packages into unstable once the dust settles.

All the best

Kerberos configuration editor looking for a maintainer

Hello

A while ago, Peter Knowles wrote a configuration model for Kerberos. Unfortunately, his priorities shifted before he completed this work. He was kind enough to send me the prototype in hope someone could take over.

Although I do not know Kerberos, I believe the model is rather complete. Just click on the image below to judge for yourself:

Class diagram of Kerberos configuration model

This work was released under a LGPL-2+ license.

There are some tasks left to get a Kerberos configuration editor. These are mentioned in config-model-kerberos readme file.

To look at the code, just clone config-model-kerberos with

git://github.com/dod38fr/config-model-kerberos.git

If you need more information on Config::Model, see:

If you are interested in adopting Kerberos model, please keep us informed on config-model-users at lists.sourceforge.net. This will avoid duplicated work. On my side, I’ll gladly answer questions related to Config::Model to help you get started.

All the best

cme fix dpkg now track and display changes

Hello

I’ve released Config::Model 2.018 which is now able to track the changes done with cme to your configuration data.

Thw GUI now features a new menu entry File -> show unsaved change that will give you a list of the changes done since running the command or since the last save (whichever occured last). For instance:

This feature is also available in non-graphic mode.

As an example, let’s refresh the lcdproc package:

$ cme fix dpkg
Fixing...
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Warning in 'control source Standards-Version' value '3.9.2': Current standards version is 3.9.3
Warning in 'copyright Format' value 'http://dep.debian.net/deps/dep5/': Format does not match the recommended URL for DEP-5

Changes:
- control source Standards-Version: '3.9.2' -> '3.9.3' # applied fix
- copyright Format: 'http://dep.debian.net/deps/dep5/' -> 'http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/' # applied fix

The Changes list can be reused to update the changelog, but the author does not dare injecting this directly in debian/changelog…

Let’s check the resulting changes:

$ git diff
diff --git a/debian/control b/debian/control
index 11a5b8a..2b81192 100644
--- a/debian/control
+++ b/debian/control
@@ -20,7 +20,7 @@ Build-Depends: autoconf,
                libxosd-dev,
                pkg-config,
                texinfo
-Standards-Version: 3.9.2
+Standards-Version: 3.9.3
 Vcs-Browser: http://git.debian.org/?p=collab-maint/lcdproc.git;a=summary
 Vcs-Git: git://git.debian.org/collab-maint/lcdproc.git
 Homepage: http://www.lcdproc.org/
diff --git a/debian/copyright b/debian/copyright
index 6cea444..4b48619 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -1,4 +1,4 @@
-Format: http://dep.debian.net/deps/dep5/
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
 Upstream-Name: lcdproc
 Upstream-Contact: William W. Ferrell 
 Source: http://www.lcdproc.org/
domi@ylum:~/debian-dev/lcdproc-stuff/lcdproc$ 

Last but not least, this track and display changes features is also available for other models, like OpenSsh, lcdproc, multistrap

All the best

A success story for Config::Model

Hello

Here’s a mail telling how the Config::Model Perl module was used to refactor existing configuration tools in Perl. Some punctuation and blank lines were added to improve the flow of this text. The full name and mail address of gkr is withheld on his request.

I took over a perl script that was responsible to pull data from several sources and push it after validation and re-packaging including some meta data into one of our production systems.

The script was never intended to be used for more then a few month. But as things go, we were still using it after a few years. Only now for a lot more sources. Since all the configuration of sources and meta data were contained as a single hash in this script, it became very unwieldy. Although the configuration seldom changed, once it got added it was not an option to keep it like this especially as we decided to prepare a Debian package for faster installation and version tracking. So I had to re-work it and was looking for some library that was allowing me to define how the configuration has to look like, providing sensible hard coded and computed defaults for some of the values.

This was when I found Config::Model on Cpan. It was, after some digging into the documentation, quite simple to define a rough first version of the complete config, including global default values as ini file and very simple to read in and write out. A more advanced version was not working because the Config::Model in Debian squeeze did not provide needed features.

Switching to yaml as configuration file format not only increased readability but also worked with the standard Squeeze package. Consistency is checked automatically inside the model so broken configurations are more unlikely in the future.

Of course I had some work re-factoring the original source but Config::Model allowed an easy addition of a value-checked and documented configuration file. To access the Config::Model::Instance I added small wrapper packages that allowed an easy access of the config elements by name to make the source easier to understand. The re-factoring needed for creating a Debian package for the Script – which is now a set of modules and a small executable – was simple once I had Config::Model working, since I was able to add new configuration items effortlessly and remove a lot of hard coded parameters.

I don’t use the cli tool yet for configuration editing but that’s going to be the next step.

Many thanks to gkr for this feedback. Let’s hope he will continue to give feedback on his usage of Config::Model.

All the best

My setup for vdr automatic wake up and shutdown

Hello

Like all kids, my kids really enjoy watching cartoons. Unfortunately, most of them are broadcast during the morning, sometimes very early in the morning. Since I don’t want my kids to wake up (or wake me up…) too early in the morning to watch cartoon, I record the most interesting programs with vdr (I also edit out commercials before my kids watch them)

To limit my carbon (or equivalent radio-active waste) footprint, I do not want to leave the computer on 24/24, so the machine has to power up by itself before a recording time.

So I’ve setup vdr to automatically setup the wake up time of the computer and shutdown the machine once the recording is finished. Note that this machine is also my main home machine, so it must not shutdown while I’m working on it (typing this blog, for instance).

This should have been easy and fairly documented. Well, it was not that easy. A lot of doc mentions nvram-wakeup which is more or less obsolete. Other docs were in German. So, here’s a summary of the setup so other can benefit from my experience.

First, this was done on a Debian/sid machine, this post should be usable on other distros, provided some adaptations. These adaptations are left as an exercise to the reader (which is marketing lingo for “I don’t have a clue”)

First add this line in /etc/default/vdr:

 ENABLE_SHUTDOWN=1

When vdr has nothing to do, it will run some shutdown scripts, including /usr/share/vdr/shutdown-hooks/S90.custom, which is a link to /etc/vdr/shutdown-hooks/S90.custom.

The output of this script will be eval’ed by vdr, so vdr knows what to do next (e.g. abort shutdown, display a message to user, retry later…).

Here are the possible output of a vdr shutdown script (list taken from vdr-wiki):

  • To abort the shutdown, exit with an errorlevel != 0.
  • If you want a message to be displayed on the OSD when aborting a shutdown,
    then write to stdout:
    ABORT_MESSAGE=<message to display>
  • If you want to defer the shutdown, write to stdout:
    TRY_AGAIN=<minutes to wait before next shutdown request>
  • To overwrite the command that will be executed to shutdown the machine
    after all shutdown hooks have been processed, write to stdout:
    SHUTDOWNCMD=<new shutdown command>
    i.e.:
    echo "ABORT_MESSAGE=\"I do not want to shutdown now!\"" ; exit 1

This script will mess with /sys/class/rtc/rtc0/wakealarm so it must be run as root. But vdr will launch this script and does not run as root. Instead of setting a suid bit, let’s setup sudo to enable this script to gain root privilege from vdr. Add this line in /etc/sudoers (with visudo):

vdr ALL= NOPASSWD: /etc/vdr/shutdown-hooks/S90.custom *

And here’s a commented Perl script that handle the shutdown test:

#!/usr/bin/perl
use IO::File ;
use 5.10.0 ;
use English;
use Path::Class; 

use Sys::Syslog qw(:standard :macros);  # standard functions & macros
openlog('vdr-shutdown', "", "user");

Here’s the call to sudo to gain root privilege (if not already run as root):

if ($EUID) {
    system('sudo','/etc/vdr/shutdown-hooks/S90.custom', @ARGV) ;
    syslog(info => "vdr-shutdown: sudo myself returned $@") ;
}

Get the next timer info from the command arguments provided by vdr:

my ($next_timer,$interval) = @ARGV ;

Setup the next alarm in the mother board:

if ( $next_timer) {
  my $dev_fh = IO::File->new("> /sys/class/rtc/rtc0/wakealarm");
  die "cannot open $dev_fh: $!" unless $dev_fh ;
  my $newtime = $next_timer - 300  ;  # Start 5 minutes earlier
  $dev_fh->print( "$newtime\n" ) ;
  $dev_fh->close ;

  syslog(info => "vdr-shutdown: set wakeup to $newtime") ;
}

Now, let’s check if someone is logged on the system. Weirdly enough, forking a command from this Perl script does not work when it’s run by vdr. Calling the ‘who’ command always return empty. The trick to find if anyone is logged is to check the content of /dev/pts directory. No files in there means that nobody is logged:

my @pts  = dir('/dev/pts')->children;
syslog(info => "vdr-shutdown:  found pts @pts") ;

if (@pts > 1) {
    syslog(info => "vdr-shutdown: retry later: someone is logged") ;
    say 'ABORT_MESSAGE="someone is logged, shutting down deferred"';
    say 'TRY_AGAIN=30'
}
else {
    syslog(info => "vdr-shutdown: nobody is logged, halting") ;
}

Now some cleanup then exit:

closelog() ;

exit 0;

This script has been working for one month, and not a single programs was missed. My kids are happy.

I’m not so happy because I now have a lot of commercials to edit out ;-)

All the best

Follow

Get every new post delivered to your Inbox.

Join 37 other followers