Tuesday, August 18, 2015

KDE vs GTK theme mixup

I run KDE (plasma) 5 as my main desktop windowing environment and every once in a while I like to go back to gnome just to see how different things are.  Mostly they both play nicely together, however once in a while it seems my theme settings get mixed up.  I think some of the settings are application dependent.

Here's the problem:

I use Gnome temporarily for a day or two and use KDE based applications like Dolphin for example.  In this scenario, dolphin will automatically adapt and use a GTK+ theme when used in Gnome.  When I revert to using KDE and start using Dolphin, this application will be stuck in GTK+ theme and will not automatically revert back to its KDE based theme, like breeze.

My first attempt at reverting the theme was obviously to use the "system settings -> application style" interface.  This did work for some applications under some circumstances, but it did not appear to solve all of the theme issues.

I've tried a "fix" which was recommended by luebking on the KDE forum: https://forum.kde.org/viewtopic.php?f=17&t=120676

The recommended solution is to run the "qtconfig-qt4" tool, which will provide you with the ability to reset all the themes.  While it appears similar to the "system settings -> application style" interface, it seems to do a more thorough job of fixing the problem.

$ qtconfig-qt4

Since I was running "breeze" as the theme, I had to switch to something else, then back to breeze.  Upon closing the window, the interface prompted me to save my changes, which I did; there is no "apply" button.

Friday, August 14, 2015

VirtualBox clipboard sharing on Linux host

It's not explicitly clear what is required to ensure bidirectional clipboard sharing works seamlessly in Linux.

While the obvious is to ensure your guest has the VirtualBox drivers installed, another not so obvious point is to ensure that your Linux host user is part of the "vboxusers" group.

To add yourself to this group run the following command:

$ sudo gpasswd -a vboxusers

Logout of your current host session and log back in.

This is also required to ensure your guest can access USB devices connected to your host, but this is explicitely stated in the VirtualBox documentation.

Wednesday, July 22, 2015

Gnome 3 Super key focus

Running Windows guest in a VirtualBox session can be complicated when the host is Gnome 3.

The "windows / superkey" keyboard shortcut is mapped strictly to the host, so the guest never catches it.  How do you then use the "windows" key in a Windows guest?

There are two very simple options:

1) If your keyboard has two "Windows" key, then the one on the right is not mapped to the Gnome 3 host by default.  It will be passed to the windows guest.

2) If you don't have two "Windows" keys, then you can use the windows key combination: Left Ctrl+Esc

The windows guest will interpret it as the "Windows" key.

Friday, June 26, 2015

Resolve IPs from list of domains

A command to resolve IPs from a list of domains, without impacting a DNS server too much.

I needed to resolve the IPs for a list of 900+ domains and didn't want to impact our DNS servers too much, so I improved on commands and suggestions that I found online; in particular a command from user alanwilliamson on http://www.commandlinefu.com/commands/view/3066/resolve-a-list-of-domain-names-to-ip-addresses


list2.txt is a simple text file with a domain per line.

$ awk < list2.txt '{ while( ("resolveip -s " $1 " 2>/dev/null; sleep 1;" | getline tmp ) > 0){ print $1 "," tmp} }'


For a given list of:

domain1.com
domain2.com
www.domain3.com

The output would look like: 

domain1.com,xxx.xxx.xxx.xxx
domain2.com,xxx.xxx.xxx.xx2
www.domain3.com,xxx.xxx.xxx.xx3


A slightly improved version which times the command, outputs to a file and flushes the buffer immediately so that the following "tail" command will be in real-time. 

$ time awk < list.txt '{ while( ("resolveip -s " $1 " 2>/dev/null; sleep 1;" | getline tmp ) > 0){ print $1 "," tmp; fflush(stdout) } }' > report.txt

You can then watch the growth of report.txt or set a tail -f on it to watch the progress:

$ tail -f ./report.txt 

Wednesday, April 22, 2015

Format XML with Gedit and xmllint

A very simple technique to format (beautify) xml using xmllint and gedit.

Gedit allows you to create plugins (external tools) which can act upon the current document.

Make sure xmllint is installed on your system.

1) Open gedit

2) Edit->Preferences->Plugins:  Check the "External Tools" box and close.

3) Tools->Manage External Tools

4) Click on the "new" button which looks like a plus in the bottom left corner of the window.

5) Insert a name for this plugin, "FormatXML" for example, then press enter.

6) Insert the following code in the "edit" portion of the screen:

#!/bin/sh
xmllint --format /dev/stdin


7) Set the "Input" menu to "Current document" and "Output" menu to "Replace current document".  Close the "manage external tools" window.

Now, you can paste or type unformatted XML.

And simply click on Tools->External Tools->FormatXML to format it properly.

Wednesday, March 4, 2015

Apache control on RedHat 7

As RedHat 7 is rolled out, the standard method to control Apache has been changed:  It seems RedHat is now favouring the original apachectl command; and this is probably a good thing as it lines up well with other distributions.

See the RHEL 7 docs: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Web_Servers.html

Systemctl is still used to start, stop, enable and disable the service (and more), however configuration testing, graceful restarts, have all been restituted to apachectl.  NOTE: apachectl was always available under RedHat, since it is part of the Apache package, but it was not the RHEL recommended way to control it.

For example:
# service httpd graceful
is replaced by:
# apachectl graceful
Or,
# service httpd configtest
is replaced by
# apachectl configtest

Friday, November 21, 2014

Mapping a VMWARE SCSI device to its Linux OS device

In VMWARE, you can see your SCSI channel and ID number in the Virtual Machine's Properties window under "Hardware": 



Once you have this information, you can then start determining where it is being used by your system either as /dev/ or an LVM physical volume.

Check the attached SCSI devices on linux:

[root@<server> ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 02 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 03 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02


And finally you can co-relate that with the OS's own mapping:

[root@<server> ~]# ll /sys/bus/scsi/drivers/sd/2\:0\:3\:0/block/
total 0
drwxr-xr-x. 8 root root 0 Nov 19 15:10 sdd


This means that the SCSI device on Channel 00 ID 03 maps to /dev/sdd

Monday, May 26, 2014

Zabbix agent and Selinux

UPDATED (Aug 1, 2017 - yes very late): RedHat released an errata in October 2014 which resolves this problem: https://access.redhat.com/errata/RHBA-2014:1568

-- Original Post --

Recently, certain versions of SeLinux and the Zabbix Agent are having a  hard time working together.  Some of the Zabbix discovery processes are failing as they are being blocked by SeLinux.

More details are available at RedHat:
https://bugzilla.redhat.com/show_bug.cgi?id=1032691

Since I use both systems quite a bit, I needed to find a simple solution rather quickly.  (I probably wouldn't recommend this solution for extremely high security systems.  On the other hand, it does allow me to monitor systems which need to be continously available.)  I added the Zabbix process type to the SeLinux permissive list.  This can be done very easily by issuing the following commands:

First, you will need to be certain you know which process type zabbix-agent is running as on your system:

$ sudo ps -eZ | grep zabbix
...
unconfined_u:system_r:zabbix_agent_t:s0 7848 ? 00:00:00 zabbix_agentd
...

Next, we will add this type to the permissive list:

$ sudo semanage permissive -a zabbix_agent_t

Finally, we can check that we did this correctly:

$ sudo semanage permissive -l
...
Customized Permissive Types

zabbix_agent_t


You will have seen a list of all the permissive types go by and finally the customized premissive types - with yours in it.

Once Zabbix or RedHat issues a fix, you can remove the permissive type by running the same command with the -d option instead of -a.

$ sudo semanage permissive -d zabbix_agent_t

Hopefully a proper solution will be available soon.  Interestingly, just after posting this, I found that another blogger had a published almost exactly the same article:
http://inboundtraffic.net/selinux-permissive-domain/

Oh well - two similar articles can't hurt.