Enabling the suspend hotkey in KDE4

There are several reports of problems with the suspend hotkey on KDE4 [1] [2]. And there is even a bug report on that issue. Naturally, I wouldn’t write about this if I hadn’t experienced the same problem myself. I solved it by slightly modifiying the approach described at Linux Basement, avoiding the need to create a dedicated shell script somewhere.

This might not have been possible in KDE 4.2 (I haven’t verified), but it is in KDE SC 4.4. The Input Actions dialog (under System Settings) allows for the configuration of DBus calls from hotkeys. This was configured fast and works painless. I have exported the hotkey group and pasted the content below. To use it, save this as PowerManagement.khotkeys and import it in the Input Actions dialog.

[Data]
DataCount=1

[Data_1]
Comment=Power management mappings of XF86 events
DataCount=1
Enabled=true
Name=Power Management
SystemGroup=0
Type=ACTION_DATA_GROUP

[Data_1Conditions]
Comment=
ConditionsCount=0

[Data_1_1]
Comment=Enables suspend hotkey
Enabled=true
Name=Suspend
Type=SIMPLE_ACTION_DATA

[Data_1_1Actions]
ActionsCount=1

[Data_1_1Actions0]
Arguments=
Call=org.freedesktop.PowerManagement.Suspend
RemoteApp=org.freedesktop.PowerManagement
RemoteObj=/org/freedesktop/PowerManagement
Type=DBUS

[Data_1_1Conditions]
Comment=
ConditionsCount=0

[Data_1_1Triggers]
Comment=Simple_action
TriggersCount=1

[Data_1_1Triggers0]
Key=Sleep
Type=SHORTCUT
Uuid={c1706a53-bde8-4364-b0af-71e9c1be6b3f}

[Main]
AllowMerge=true
ImportId=Power Management
Version=2

WebDAV on Windows Vista & Windows 7

There are quite a number of tales of woe around that topic. I had to find that out when I experienced some trouble myself today. If you’re in the same situation skip right down to the last two lines of this posting, the stuff in between just details the problem to associate the solution to the problem for the search engines.

My intention was to connect to my freshly set up  WebDAV directory served by Apache. The setup on the server side was quite tedious as well, but as expected, there are countless howtos around and one just has to put the pieces together as usual. The real problem however arose, when I starry-eyed tried to connect to that online directory using Vista’s „Map Network Drive …“ dialog. After some steps into the wizard that always gave me the error popup saying „The folder you entered does not appear to be valid“.

Well that soon let me drop to the beloved command line. But using net use W: https://example.com/davroot was answered by „System error 67 has occurred“ and „The network name cannot be found“. Using net use W: \\example.com@SSL\davroot gave no improvement.

I will spare you my other trials and all the different possible solutions that can be found on the net (I even installed a Microsoft patch which didn’t change anything) and write down straight what solved the problem:

  1. Make sure the „WebClient“ service is running! (Type „services.msc“ into the search box in the start menu and hit enter.  Scroll down the WebClient and check.)
  2. Use „\\yourserver@SSL\DavWWWRoot\yourshare“ as the server address in the Folder field of the Map Network Drive dialog box. Do not forget the DavWWWRoot or the @SSL.  

How-to reduce fail2ban memory usage

This morning, when I did the routinely scan of the server’s resource usage history, I noticed a suspicious network activity between 1 and 5 am. Some reading of the latest log files soon identified the traffic to have been caused by a dictionary attack on my SSH server. I took the opportunity to extend my current setup for the script-kiddie enemy called fail2ban. This program monitors potentially any service’s log file for failed login attempts and if their number exceeds a certain limit, it blocks the issuing host using iptables rules.

Unfortunately the first start of the new service turned out to blow up the memory usage by about 100 MB which is unacceptable regarding the tight resources of my virtual private server. As I found out, others had similar experience and switched to DenyHosts due to this issue. My experience with setting up Trac two weeks ago taught me that a Python application (like fain2ban) might consume a lot of memory only because of the relatively oversized default stack size on Linux.

The means to reduce the default stack size in Linux are widely known to be the limits.conf file and the ulimit command. But how to use those two in my situation? The solution turns out to be a one-liner on Debian Lenny: All I had to do was to append the ulimit command to my /etc/default/fail2ban file.

This is the changed /etc/default/fail2ban file:

# This file is part of Fail2Ban.
#
# Fail2Ban is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Fail2Ban is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Fail2Ban; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Author: Cyril Jaquier
#
# $Revision: 1.2 $

# Command line options for Fail2Ban. Refer to "fail2ban-client -h" for
# valid options.

FAIL2BAN_OPTS=""

ulimit -s 256

Using this sets the default stack size for the Python instances running fail2ban to 256 KB and lowers the memory consumption of fail2ban approximately by a factor of 10.