Tuesday, September 29, 2015

KDE Plasma 5 launchers not working in Gnome 3

Today I discovered that manually created KDE launchers (.desktop files in $HOME/.local/share/applications/) are not wholly compatible with Gnome 3.

I won't go into details, but instead will point you to this bug report: https://bugs.kde.org/show_bug.cgi?id=321152

I'm mainly interested in ensuring this work on my system as I regularly switch back and forth between KDE 5 and Gnome 3 (don't ask me why, we all have our oddities), and I need to ensure that Launcher icons are available under both desktop environments.

When creating entries with KDE Menu Editor, you will find that these files look somewhat similar to the example below, which I created to launch JMETER:

[Desktop Entry]
Comment=
Exec=java -jar /home/<...>/<...>/apache-jmeter-2.10/bin/ApacheJMeter.jar
Icon=applications-utilities
Icon=office-chart-line-percentage
Name=JMETER
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=


The highlighted line, Path[$e]=... is actually the cause of Gnome not displaying the launcher in it's menu. 

Simply adding a pound comment (#) symbol in front of it will allow Gnome to ignore that line and the launcher will function.

 ...
#Path[$e]=
 ...

When you have several such entries, it is easier to use SED in conjunction with FIND to edit all of them at once.
1
find . -type f -exec sed -i 's/Path\[/#Path\[/g' {} \;
It's not the most elegant solution... but it works... sort of... 

Wednesday, September 23, 2015

Block Access to Files by IP using X-Forwarded-For - part 2

In my previous post, I explained how to block access by using X-Forwarded-For.  While this works very well in many cases, there are situations where it doesn't do as good a job.

I had a need to block access to multiple VirtualHost entries to a group of IP addresses, and found that it could be achieved using rewrite rules.

Here is an example:
1
2
3
4
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-For} ^10.10.10.11$ [OR]
RewriteCond %{HTTP:X-Forwarded-For} ^10.10.10.12$
RewriteRule .* - [F]
A range can be defined:
1
2
3
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-For} ^10.10.$
RewriteRule .* - [F]
Etc...

--

This code went into a file I named /etc/httpd/conf/block.conf (CentOS specific location)

The file was then included into each and every VirtualHost entry, for example:
1
2
3
4
5
6
7
8
9
10
11
<virtualhost *:80>
    include /etc/httpd/conf/block.conf
    ServerName www.mysite1.com
    DocumentRoot /var/www/html/http/mysite1
</virtualhost>

<virtualhost *:80>
    include /etc/httpd/conf/block.conf
    ServerName www.mysite2.com
    DocumentRoot /var/www/html/http/mysite2
</virtualhost>
Etc...

Friday, September 18, 2015

Apache - Block PHP

Reminder note: Blocking PHP from executing in a directory

    php_flag engine off