Dec 25, 2014

New Fedora 21 update to Kernel 3.17.7-300.fc21.x86_64 activated nouveau driver again

On my system, I have a NVidia Quadro FX 770 and therefore I'm using
the NVidia driver itself, since rpmfusion does not support my graphic anymore.

But the last update to kernel 3.17.7-300.fc21.x86_64 activated the free
nouveau driver, which sets a kernelmode. But this didn't let me install
the NVidia driver. So I blacklisted the nouveau driver, but it was also in
the initramdisk. So a
dracut --force

built a new one and after a reboot, I could install the NVidia driver again.


Dec 13, 2014

Upgrade of Laptop from Fedora 20 to Fedora 21 worked partly ( Nvidia problems )

I updated my Laptop from Fedora 20 to Feodra 21.

The update with fedup worked nice out of the box:

fedup --network 21 --product=workstation




But after rebooting I didn't get X11.

Some time before, I had the nvidia-driver installed, so I started

nvidia-installer --update


which downloaded the latest nvidia driver installed it and after a reboot X11 and the GUI-Login
was back.

When I have more time, I have to look why the rpmfusion akmod drivers do not work for me.

My docker image with mariadb based on Fedora 20 started and could be accessed with mysql client.


Nov 26, 2014

fast switching to a specific window in a different tmux terminal-session

tmux and tmuxinator ( mux ) allow the usage of multiple shells in one
or more sessions.

The Terminal can be detached from the session and everything is still
running in the background.

If you have multiple sessions in tmux running ( perhaps configured with
tmuxinator ), you can switch between the sesssions with
<Ctrl>-<a><s> or <Host-Key><s>, which shows all sessions.

Per accident I found, that you can show all windows in a session by
moving the selection to the session an pressing the <right-Arrow-Key>
( left-Arrow-Key closes the view of the windows ).

After selecting the window in the session, you're directly put into this
shell.


Nov 19, 2014

Getting hg ( mercurial) completion in bash

On my Fedora 20 environment I'm using Mercurial ( hg ) beside svn & git for
version control.

This is a nice distributed version control system, which was the only one
available on Solaris/Linux/Windows, at the time I switched. Git was available
on windows only by using a cygwin environment.

Now git on my Fedora box has a nice little command/branch-name ...
completion.
When starting commands and typing <TAB> the suitable completion is
searched and shown, if there are multiple ones.


For hg I was missing this, because I install mercurial from source on my
fedora system.

The missing key part is to source in the completion file into .bashrc in the
homedirectory. The completion file is delivered in the source release of mercurial:

e.g.:

if [ -f /tools/DevTools/mercurial/latest/contrib/bash_completion ]; then
    . /tools/DevTools/mercurial/latest/contrib/bash_completion
fi

After resourcing the .bashrc the completion also works for hg

[ewer@lxewer hg-git]$ hg checkout<TAB>
0.1.0    0.2.2    0.2.5    0.3.1    0.3.4    0.6.0    master  
0.2.0    0.2.3    0.2.6    0.3.2    0.4.0    0.6.1    next    
0.2.1    0.2.4    0.3.0    0.3.3    0.5.0    default  tip     
[ewer@lxewer hg-git]$ hg checkout 0.<TAB>
0.1.0  0.2.1  0.2.3  0.2.5  0.3.0  0.3.2  0.3.4  0.5.0  0.6.1 
0.2.0  0.2.2  0.2.4  0.2.6  0.3.1  0.3.3  0.4.0  0.6.0 

Nov 12, 2014

Repeat command in bash and replacing arguments in Fedora 20

I'm running one command a lot again, but have to replace some
arguments.

e.g.

wo abcd > abcd.log 

Instead of retyping everything again you can :

!!:gs/abcd/efgh/

which results in the command
wo efgh > efgh.log 

being executed.
The '!!' repeat the last command executed from the history. See also '!-5' or
the absolute command nummber '!93' and the 'gs' for global substitution. 

There's also a simple version with just 's', but this does just one subsitution.


Nov 10, 2014

TAB-completion in bash on Fedora 20 escapes the $-Sign of the variable - how to prevent

I'm copying files on the bash command line on Fedora 20.

To deploy a war, I've set the JBOSS_HOME environmentvariable and
deploy the war with

cp target/service.war $JOBSS_HOME/sta

and do here a <TAB> to complete to standalone, but in this case the command line get to

cp target/service.war \$JBOSS_HOME/standalone 

For the next completion of deployment the $ must be unescaped.

I found a hint here.

One way is to enable directory expansion with

shopt -s direxpand

or to use 

<Ctrl>-<Alt>-<e>
 to expand. 

Since the setting of the shell option must be done everywhere, even when logging in to a different server, I tend 
to remember the <Ctrl>-<Alt>-<e> .

Sep 29, 2014

tmux - tmuxinator => Terminal Multiplexer as alternative to screen and a nice configuration tool for the session.

During some time I used screen, which allows to open multiple shells in one
terminal, detach from the session and let the session continue in the back-
ground.

Some time ago I switched to tmux, as an alternative which is highly
customizeable.

You can switch between different sessions by using the binding key.
In my case <Ctrl>-<a>-<s>.

to start a new session inside of tmux use <Ctrl>-<a>-<:> new-session

You can cycle through the session with <Ctrl>-<a>-<(> or <Ctrl>-<a>-<s>


There is an other tool named tmuxinator. On Fedora 20 you can install it
with sudo yum install tmuxinator


tmuxinator new <Name> or mux new <Name> starts the configuration
of a session, where you can configure the setup of the session.


Here is a config:

# ~/.tmuxinator/TT.yml

name: TT
root: ~/entw/dev

# Optional tmux socket
# socket_name: foo

# Runs before everything. Use it to start daemons etc.
pre: docker start lxewerMysql; sleep 10; updateDockerIp.sh lxewerMysql

# Runs in each window and pane before window/pane specific commands. Useful for setting up interpreter versions.
pre_window: . /home/ewer/prod/TTenv.bashrc

# Pass command line options to tmux. Useful for specifying a different tmux.conf.
# tmux_options: -f ~/.tmux.mac.conf

# Change the command to call tmux.  This can be used by derivatives/wrappers like byobu.
# tmux_command: byobu

windows:
  - JBOSS:
      layout: main-hoirzontal
      panes:
        - sleep 5; cd $JBOSS_HOME; bin/standalone.sh
        - cd $JBOSS_HOME
  - COMPILE:

This example starts my mysqldatabase docker container, updates the IP
adress in my local hosts file.

The start directory is set to the value of root: ~/entw/dev.

On every window the environment the file from pre_window:is sourced in.

The first window named JBOSS has 2 panes where in the  first JBOSS is
started, with a sleep to let docker start the database container, which is
referenced by the datasources in the JBOSS Appserver.

The second pane just changes to the HOME of the jboss installation.

On the second window the directory is set to the dev Directory set on the
beginning of the config.

Here you can create multiple sessions. with mux <sessionname> and
switch between the sessions as describe above. The other session are
running in the background.





Jul 30, 2014

How to collapse all project nodes in a the netbeans projects window

When you have a lot of projects open in netbeans and edited a lot of
files, it is hard to navigate.

By pressing <Ctrl>-<1> you get to the project window and by typing you can move the selection.

To collapse all project nodes it is a little bit tricky. I found the solution in
this bugfix 113278.

You have to be in the projects-Windows by pressing <Ctrl>-<1>.

There you are not allowed to have something selected -> press <Ctrl>-<Space>.

Now In the context-menu ( get it by pressing <Shift>-<F10> ) and <UP>-<UP> you get to the "Collapes All" Context menu entry, which closes
all nodes in the projects-window.

Jul 25, 2014

executing only one testcase with maven

During the testing call with maven all available testcases are executed.

mvn test

if you have problems with a testcase you can just execute this one testcase
with

mvn test -Dtest=<TestCase>

removing a package on a solaris global zone hangs with the message: ## Waiting for up to <300> seconds for package administration commands to become available (another user is administering packages on zone <Zonename>

Today the attempt of removing a package in the global zone of a solaris 10
system waited for an other administration task to complete.

This is the message:

## Waiting for up to &lt;300&gt; seconds for package administration commands to become available (another user is administering packages on zone &lt;Zonename&gt;

The problem is, that there is not running any administration task.

After truss'ing I got the hint of /tmp/.ai*lock* files. I removed the file
in the global, but this didn't have any success.

The solution was available here. In every zone-filesystem there is also
a /tmp/.ai*lock* file, which was dangling around from a killed pkg-command.

After

rm /zones/*/root/tmp/.ai* 

the pkgrm command succeeded.

awesome session on vJUG about Testing and refactoring Legacy Code

Most of the time on a busride during the vJUG sessions, so I view the
sessions most of the time offline :-(.

But the last one I viewed about "Testing and Refactoring of Legacy Code"
was awesome.

See it  @youtube:

https://www.youtube.com/watch?v=JTHMd1nQlSg


Jul 22, 2014

How to search for files containing a text fragment in Fedora20/ Gnome 3.10.2

About a year ago, I posted about a function in Gnome Nautilus ( File manager ) in gnome, on how to search for files containing a text fragment.

But this function was removed. I didn't want to change the file manger
or use one from a different Desktop environment, so I used a shell script.

Now I found a solution or two ;-). Install gnome-search-tool, which supports the searching for the content and some more by  adding a Nautilus action







After searching in the software-repository, I found the package

nautilus-search-tool.x86_64.

After installing with
sudo yum install  nautilus-search-tool.x86_64 
and killing and restarting nautilus ( kill all running instances )
I got a context-menu entry, which starts the gnome-search-tool 
and you do not need to add an action.


After starting gnome-search-tool, the Folder to start searching in is set to
None. Selecting "Other" in "Look in Folder" opens a file browser selection dialog, which is presetted with the acutal selected directory in nautilus, which  can be taken over to the search.

Jul 21, 2014

maven and Testcase processing - skipping Tests or skipp building test classes

The maven default attempts to compile and execute testcases from
src/test, but if you want to skip the tests you can do this with

mvn install -DskipTests=true

but this compiles the test classes in your project. If you also want to
skip the compilation of the test classes you have to use

mvn install -Dmaven.test.skip=true 


Can't show the actual docker Containers as normal user

Since the last updates of fedora 20, I can't show the actual active docker container.

I always get a Permission denied on the socket:

$ docker ps
2014/07/21 09:37:32 Get http:///var/run/docker.sock/v1.12/containers/json: dial unix /var/run/docker.sock: permission denied


The former problem was that my account was not in the docker-group, but
now it's a different problem, because I'm in the group.

Found the workaround-hint in this Bug.( Different systemd versions for
actual configuration and running systemd )

Changing the group ownership of /var/run/docker.sock to docker allowed
me to view the containers again:

chown root:docker /var/run/docker.sock

Jul 13, 2014

Communication between two docker container

I started to use docker in my dev environment.

On my laptop are two containers, where on one is a java process running and on the second is a tomcat active, which offers the java process services
as WebServices.

On the WebService-Container I have to have the dynamic IP-Address of the
container, but this changes on every start.


The solution is to add the --link Option on starting the WebService Container.

This option sets some Environment variables, but what is much more of
use for me is the entry in the /etc/hosts filewith the name I can set in the --link option.

Now the WebService Container only needs to reference the hostname and
on every start with the --link Option, the new IP is inserted into the /etc/hosts.

sudo always asks for password, although I have inserted all commands for me.

On my laptop I'm the only user and have inserted my account in the
/etc/sudoers on Fedora 20.

But I still get the request for the password even I have inserted the following line :

ewer    ALL=NOPASSWD:ALL

after the available line for root

root    ALL=(ALL)       ALL


I lived some time with this, but now I know why I got always the password request:

 I'm also in the wheel group. After moving my config line at the end of the
file, I can now "sudo" without password request


Jul 4, 2014

switch between tabs by keyboard in nautilus ( Gnome Filemanager )

I'm running Fedora 20 and use nautilus as a filemanager frequently.

Navigating through huge directory trees by typing letter is sometimes
slow.

Here I use <Ctrl>-<s> and mark the desired directy with wildcards.
This is in my case much faster.

Switching between TAB's opened with <Ctrl>-<t> is  done with <Alt>-<[0-9]>

More Shortcuts can be found at http://askubuntu.com/questions/364595/how-to-switch-between-tabs-in-nautilus


Jun 20, 2014

SOAP-Call on Mantis installed on Fedora 20 failed with: [mantisconnect.php] Error Type: SYSTEM NOTICE,\nError Description: Array to string conversion\nStack Trace:\nnusoap.php L6335 serializeType('attachments'

For testing purpose, I had to install MantisBT 1.2.17 on my local Fedora 20
with mysql running in a docker-Container.

But requesting a ticket with soapUI failed with the message:

[mantisconnect.php] Error Type: SYSTEM NOTICE,\nError Description: Array to string conversion\nStack Trace:\nnusoap.php L6335 serializeType(<string>'attachments'

After some searching, I found the reason:

I had to install php-soap with:

yum install php-soap.x86_64

after the installation, the SOAP-Request can be executed.

Jun 18, 2014

How to convert a PST-File of Outlook to mbox Format? -> libpst is your friend?

I got a pst file from an outlook-client, but I'm using thunderbird on linux.
Now I had to convert somehow the pst file to a mbox-Format, which can be
used by thunderbird.


After some searching a found this site, which revered me to libpst.

But this page is not available anymore, so Google referd me to http://www.five-ten-sg.com/libpst/packages/.

After downloading, doing some yum install's on my Fedora to get the
dependencies, I could compile and install libpst.

After this just a simple:

bin/readpst -o /output_dir -u /outlook.pst
Opening PST file and indexes...
Processing Folder "Gelöschte Elemente"
Processing Folder "Bugreports"
        "Outlook-Datendatei" - 2 items done, 0 items skipped.
        "Gelöschte Elemente" - 3 items done, 0 items skipped.
        "Bugreports" - 700 items done, 0 items skipped.

extracted the emails from the pst.

By the help of the ImportExportTools-AddOn of thunderbird I could
import the resulting mbox-File and read the mails froom the pst file. 

May 2, 2014

Which process on AIX has a specific TCP-port open?

Attempting to start a process, but the port is already opened by some
other process.

So the next question is: Which process has opened that port?

On Linux: 

netstat -anp | grep :22

On solaris:

The pcp-Script, which interrogates the /proc filesystem.
pfiles listens the open files/ports by process-ID. 

bash-3.00# ./pcp.sh -p 22
PID     Process Name and Port
_________________________________________________________
755     /usr/lib/ssh/sshd       22
sockname: AF_INET6 ::  port: 22
_________________________________________________________
4279    /usr/lib/ssh/sshd       22
sockname: AF_INET6 ::ffff:192.168.1.50  port: 22
_________________________________________________________
4280    /usr/lib/ssh/sshd       22
sockname: AF_INET6 ::ffff:192.168.1.50  port: 22
_________________________________________________________

On AIX

netstat -Aan | grep 22
> netstat -Aan | grep 22 
f10007001354ebb0 tcp4 0 0 *.22 *.* LISTEN 
f100070001c98bb0 tcp4 0 0 *.22 *.* LISTEN 
> rmsock f100070001c98bb0 tcpcb 
The socket 0x1c98808 is being held by proccess 118888 (sshd). 

Apr 25, 2014

changing CSV-Separator in exported CSV in a PrimeFaces App

PrimeFaces is a JSF Implementation, which supports with the
<p:dataExporter> the possibility to export a <p:dataTabel> to a
CSV, EXCEL or PDF file.

But for the CSV file, the separator is fixed with the sign ','. You can
not change this directly with PrimeFaces.

Therefore you have to use an extension from here. On this page you see
the dependencies for maven:

<dependency>
  <groupId>com.lapis.jsfexporter</groupId>
    <artifactId>jsf-exporter-core</artifactId>
    <version>1.0.2.Final</version>
</dependency>


<dependency>
    <groupId>com.lapis.jsfexporter</groupId>
    <artifactId>export-type-csv</artifactId>
    <version>1.0.2.Final</version>
</dependency>


<dependency>
    <groupId>com.lapis.jsfexporter</groupId>
    <artifactId>export-source-primefaces</artifactId>
    <version>1.0.2.Final</version>
</dependency>
In your JSF-Pages you have to include the namespace:

xmlns:l="http://www.lapis.com/jsf/exporter"
 and use the dataExportert from this extension:

    <l:dataExporter source="table" fileType="excel" fileName="myfile"/>
To change the separator use the option fileOptions="" and supply an
ExpressionLanguage which refers to an CSVExportOptions instance.

e.g. 
fileOptions="#{optionBean.option}"
In this bean you supply an CSVExportOptions, which can be configured
the way you like and change e.g the separator for the CSV file.

Mar 26, 2014

How to get executed SQL-Queries from MySQL/MariaDB

I have a program, which queries a mysql database, but I wanted to know the
query it executes.

To activate the logging of the queries to a databasetable I found the hint here.

It is as simple as executing the following statements:

SET GLOBAL log_output='TABLE';
SET GLOBAL general_log='ON';

After this just query the databasetable general_log in the mysql database.

use mysql;
select * from general_log;

Mar 22, 2014

docker on Fedora 20

Docker is  a kind of virtualization software, feeling a little bit like zones in
Solaris.

In the REPO for Fedora 20, there is a package containing a lot of
examples for docker containers.

The package is named fedora-dockerfiles.noarch and put's its files into

[ewer@lxewer usr]$ cd /usr/share/fedora-dockerfiles/
[ewer@lxewer fedora-dockerfiles]$ ls
apache   firefox    mongodb  nginx   postgres  ssh
couchdb  memcached  mysql    nodejs  rabbitmq  wordpress_single_container

Building the first container:

cd /usr/share/fedora-dockerfiles/mysql
docker build -rm -t ewer/MySQL .


I had problems building the container, because I'm sitting behind a proxy to
the internet and the yum update failed. 

I added the following entry into /usr/lib/systemd/system/docker.service

EnvironmentFile=/etc/sysconfig/docker

into the section [Service]

the docker-Environment file /etc/sysconfig/docker contains:

HTTP_PROXY=http://<ip>:<port>                                          
http_proxy=$HTTP_PROXY
HTTPS_PROXY=$HTTP_PROXY
https_proxy=$HTTP_PROXY

export HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

After restarting the docker-service

systemctl restart docker.service

the building of the container succeeded and it could be started:

docker run -d -p 3306:3306 <yourname>/MySQL

The README.md in the fedora-dockerfiles/mysql/README.md contains all the hints including the default password for mysql.

To get the IP adresse of the container execute

docker inspect <container_id> | grep -i ipaddr


and you can connect with the mysql client.


After stopping the container with

docker stop <Container-ID> 

where the container-ID is retrieved by

docker ps

you can restart the same container with

docker start <Container-ID> 

which you get with

docker ps -a

if the container is not up.


To attach to the container you can use lxc

docker ps -a --no-trunc
lxc-attach --name=<Full Container ID>

My current problem is, that the container doesn't start, if there is only the
WLAN adapter active and the physical LAN is not connected.


Mar 19, 2014

MemoryAnalyzer Tool based on Eclipse coredumps in libsoup on Fedora 20

I've downloaded MAT ( Memory Analyzer Tool ) for linux x64 and unzipped
on my Fedora 20 installation.

But when starting MemoryAnalyzer, the JVM dumps a core:

[ewer@lxewer mat]$ ./MemoryAnalyzer
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000033b6a70061, pid=9044, tid=140447298418432
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b132) (build 1.8.0-b132)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libsoup-2.4.so.1+0x70061]  soup_session_feature_detach+0x11
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /tools/DevTools/mat/hs_err_pid9044.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
This problem is already known and there is also a workaround:

Adding
-Dorg.eclipse.swt.browser.DefaultType=mozilla
to the ini-File. In this case the MemoryAnalyzer.ini.

After adding this line, the Analyzer starts.

Mar 13, 2014

Using docker behind a http-proxy on Fedora 20 with systemd starting the docker-service

On my Fedora 20 System docker is started by systemd.

The problem during installing an image is, that I'm living behind a proxy.

In the systemd configuration file you can set a file to load the environment from.

In my case this is /usr/lib/systemd/system/docker.service

Under the section [Service] add the entry for Environmentfile:


[Service]                                                                      
EnvironmentFile=/etc/sysconfig/docker
ExecStart=/usr/bin/docker -d
Restart=on-failure
 
In /etc/sysconfig/docker, the proxy variables are set:

HTTP_PROXY=http://<IP>:<Port>                                         
http_proxy=$HTTP_PROXY
HTTPS_PROXY=$HTTP_PROXY
https_proxy=$HTTP_PROXY

export HTTP_PROXY HTTPS_PROXY http_proxy https_proxy

After a refresh of the new config with

sudo systemctl daemon-reload

and restart

sudo systemctl restart docker.service

I can install an image:

sudo docker build -rm -t ewer/MySQL .
[sudo] password for ewer:
Uploading context 55.81 kB
Uploading context
Step 0 : FROM fedora:20
Pulling repository fedora
58394af37342: Download complete
511136ea3c5a: Download complete
8abc22fbb042: Download complete
 ---> 58394af37342


Mar 7, 2014

Skype-Integration in Gnome3 / Fedora 20. with a visible state icon on the topbar

I already found this extension some time ago and attempted to install it
in $HOME/.local/share/gnome-shell/extensions/SkypeNotification@chrisss404.gmail.com

During that time I didn't get the extension visible.

Today after starting the Debug-Tool LookingGlass lg with <Alt>-<F2>, the
Extension tab showed this extensions.

Now after starting gnome-tweak-tool an enabling the skype-Extension, I got
the state-symbol.





Developertools for Gnome3 - memory management...

When you have troubles with the gnome-shell you can start the
command-prompt with the key-shortcut <Alt>-<F2> and type the
letter 'r', which restarts the shell.

I knew from long ago, that there is also something like a garbage collector
and now I've found a collection of tips here.

To get to the developer tools of gnome-shell get to the command prompt with <Alt>-<F2> and insert 'lg'.

In the appearing window you can switch over to the memory and issue a
FullGC


Jan 23, 2014

Accessing a HG ( Mercurial ) repository with git or how to convert a HG Repo to git ==> git-remote-hg is the solution.

There is a nice "plugin" for git to handle HG repositories.

This is a simple file from here. This must be stored somewhere in the
path with the name git-remote-hg.

After this you can simple clone a HG Repo with:

git clone hg::http://<server>/<repo>

The repos looks good with branches and tags.

As desccribed in the probject, there should also be a push back possible.


Jan 22, 2014

Install Windows XP as KVM guest on Fedora 20 with the VirtIO drivers from RedHat

KVM is a virtualisation environment from the Linux Kernel, which is
also ported to Illumos/OpenSolaris.

The installation of windows is straight forward from an iso-Image by using
IDE disk.

After the installation, the devices can be changed to the virtio drivers for
better performance.

Therefore the ISO for virtio can be downloaded.

After this, a tool for windows is used to mount an iso-Image as a drive.

A very good description on changing the driver is given here.


Following this description was straight forward and worked for me.

The next step is to get the network ( using a private net ) to work with
routing.


Jan 21, 2014

In the last yum updates on Fedora 20 the PRE scriptlets of same packages fail

During the last update of the Fedora 20 packages with yum the
following error occured:

Running transaction
error: %pre(initscripts-9.51-1.fc20.x86_64) scriptlet failed, exit status 127
Error in PREIN scriptlet in rpm package initscripts-9.51-1.fc20.x86_64
error: initscripts-9.51-1.fc20.x86_64: install failed
error: %pre(pcp-3.8.10-1.fc20.x86_64) scriptlet failed, exit status 127
Error in PREIN scriptlet in rpm package pcp-3.8.10-1.fc20.x86_64
error: pcp-3.8.10-1.fc20.x86_64: install failed
error: %pre(selinux-policy-targeted-3.12.1-117.fc20.noarch) scriptlet failed, ex
it status 127
Error in PREIN scriptlet in rpm package selinux-policy-targeted-3.12.1-117.fc20.
noarch
error: selinux-policy-targeted-3.12.1-117.fc20.noarch: install failed
error: %pre(nfs-utils-1:1.2.9-2.1.fc20.x86_64) scriptlet failed, exit status 127
Error in PREIN scriptlet in rpm package 1:nfs-utils-1.2.9-2.1.fc20.x86_64
Warning: scriptlet or other non-fatal errors occurred during transaction.


There was a problem in the previous selinux-policy package.

Look here for Details.

There is also the solution for the problem, which also fixed my problem

# setenforce 0
# yum clean expire-cache
# yum update selinux-policy\*
# setenforce 1

After this my system got uptodate again:

 Loaded plugins: langpacks, refresh-packagekit
No packages marked for update

Jan 2, 2014

Parsing HTML code like XML as DOMTree?? -> Use htmlcleaner

I had the problem, to parse HTML-Emails in Java, where the tags were not balanced and so on.

To get the same features with the DOMTree as with parsing of XML, I searched for a tool and found it
in htmlcleaner.

Htmlcleaner converts the HTML-Code to a DOMTree, which allows parsing and searching with XPath.

This is a nice way for extracting data from the email message. In my case there was every data in the same tag, but the signature used a different font attribute, which allowed the distinction in the XPath searching.

smime certificate management and bouncycastle S/MIME encrypted Message/EMail creation

After having difficulties with PGP encryption with the receiving side ( the key, I got is shown in 
thunderbird to miss subkeys for encryption, but the other side said, they can encrypt ??), I had to
change to S/MIME encryption.

Meaning to create a email Message in Java and encrypt the message before sending.

The basics for encryption in Java is shown in an example in bouncycastle.

But to start you need a certificate. You can create your own CA ( certificate Authority ) and create
Certificate requests, which are signed by the CA. A nice intro ( in German ) is here, which I used because
of thinking of problems with the certificate of cacert.

The other way as mentioned is cacert.org. Here you can register and create your own certificates. The
disadvantage is, that the root certificate is not contained in Firefox/Thunderbird...

To get started you need the certificate of the receiver.

This must be stored in a pkcs12 keystore, but how to create such a keystore?

I found a nice GUI for keystore handling. This tool is called Portecle.
 It is a javatool with a clean GUI.


Creating a Keystore of Type PKC12 could not import the certificate of cacert, I created.
After this I searched for a long time, but didn't find any usefull thing.

The tricky part is, to create a JKS ( Java Key Store ), import the certificate, assign an alias name you
would like to search for in the java code and change the keystore type in the Tools menu to pkcs12.
After this you can save the keystore and have a working PKCS12 keystore as requested by the
source code of bouncycastle.

The source code is quite simple:


KeyStore    ks = KeyStore.getInstance("PKCS12", "BC");
ks.load(new FileInputStream("/path/to/keystore.p12"), "KeystorePassword".toCharArray());

Enumeration e = ks.aliases();String      keyAlias = null;
while (e.hasMoreElements()){    String  alias = (String)e.nextElement();
    if (alias.equals("searchAlias"))    {        keyAlias = alias;
    }
           }

     Certificate cert = ks.getCertificate(keyAlias);
     MimeMessage m = new MimeMessage(session);

     m.setFrom(new InternetAddress("sender@adress"));
     m.setSubject("Test Mail for Enryption");
     m.setRecipient(Message.RecipientType.TO, new InternetAddress(        "receiver@adress") );
     m.setText("Test email with certifcate usage.");

        //
        // create the generator for creating an smime/encrypted message
        //
        SMIMEEnvelopedGenerator  gen = new SMIMEEnvelopedGenerator();
        gen.addRecipientInfoGenerator(new    JceKeyTransRecipientInfoGenerator((X509Certificate)cert).setProvider("BC"));

        MimeBodyPart mp = gen.generate(m, new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC).setProvider("BC").build());
m = new MimeMessage(m);
m.setContent(mp.getContent(), mp.getContentType());
m.saveChanges();
FileOutputStream fous = new FileOutputStream("email.msg");
m.writeTo(fous); 


This is a short layout without any errorhandling, but using javamail and sending the MimeMessage,
thunderbird can decrypt the message after importing the private key and the certificate.

When using cacert, you have to install the created certificate from cacert.org and backup the certificate as
a PKCS12 file in the perferences/Advanced/Certificates/View Certificates/Your Certificates path.

After saving you can import this in thunderbird  perferences/Advanced/Certificates/View Certificates/.

This allows thunderbird to decrypt S/MIME encrypted messages sent by the java code.

UPDATE: if you have more receivers, just add an RecipientInfoGenerator for each receiver with:
gen.addRecipientInfoGenerator(new    JceKeyTransRecipientInfoGenerator((X509Certificate)cert).setProvider("BC"));
 and every receiver can view the email.