Archive for the ‘Notes’ Category

Mailman: how to set moderated flag on for all

Wednesday, November 4th, 2020

Mailman  is an old and well known free software for managing electronic mail discussion and e-newsletter lists.
Recently i had to put as active the “moderated” flag for all the people in a very big mailing list.
To do this, first I loaded this python script, then I exported all the list members into a file

/usr/lib/mailman/bin/list_members mylistname  > /tmp/mylistnameusers.txt

and finally I applied the withlist command for all:

for ADDR in $(cat /tmp/mylistnameusers.txt) ; do
/usr/lib/mailman/bin/withlist -l -r du.setMemberModeratedFlag mylistname  $ADDR 0
done

Iptables rules loaded every time after a reboot

Thursday, November 7th, 2019

Even if it has been disabled firewalld and iptables, some iptables rules could be activated after a reboot. It’s due to libvirtd .

I’ve just read a good post here where it’s fully explained why even though iptables is turned OFF, after every boot the command iptables -L -n still displays some rules to be activated.

Execute Windows Commands from Linux using winexe

Tuesday, September 10th, 2019

I’ve just found a good tutorial to compile winexe.
My host was a CentOS 7 box and I followed the instruction of this link:

Execute Windows Commands from Linux using winexe. Connect from Linux to Windows without SSH

In order to have git working, I opened the outgoing connection of 9418 TCP port on my firewall.

a nagios check to remind me the SSL certificate expiration

Monday, March 3rd, 2014

I wrote a quite unuseful check for nagios to remind me to renew my SSL certificate. This is the definition in commands.cfg file

define command{
        command_name check_ssl_expiration
        command_line /usr/lib/nagios/plugins/check_ssl_expiration.sh $ARG1$ $ARG2$ $ARG3$ $ARG4$
}

and this the check_ssl_expiration.sh script

#!/bin/bash
# input parameters
MYSRV=$1
MYPORT=$2
DAYWARN=$3
DAYCRIT=$4
# return values
RET_OK=”0″
RET_WARN=”1″
RET_CRIT=”2″
RET_UNKN=”3″
TEMPFILE=/tmp/.$$certtest.pem

# check data input
checkdata () {
        VAL=`echo $2 | wc | awk ‘{print $2}’`
        if [ $VAL -eq 0 ]; then
                echo $1 is not set
                exit $RET_UNKN
        fi
}

checkdata “HTTPS server name” $MYSRV
checkdata “HTTPS PORT” $MYPORT
checkdata “warning threshold” $DAYWARN
checkdata “critical error threshold” $DAYCRIT

echo | openssl s_client -connect $MYSRV:$MYPORT  2> /dev/null | sed -ne ‘/-BEGIN CERT/,/-END CERT/p’ > $TEMPFILE 2>/dev/null
EXPDATE=`openssl x509 -noout -in $TEMPFILE -dates|grep notAfter|sed -e “s/.*notAfter=//”`
rm $TEMPFILE

EXPSEC=`date “+%s” –date=”$EXPDATE”`
NOWSEC=`date “+%s”`
DAYLEFT=`expr \( $EXPSEC – $NOWSEC \) / 86400`

# $DAYLEFT days left to SSL certificate expiration

if [ $DAYLEFT -le $DAYCRIT ]; then
        echo “ERROR – $DAYLEFT days left to SSL certificate expiration for $MYSRV:$MYPORT”
        exit $RET_CRIT
fi

if [ $DAYLEFT -le $DAYWARN ]; then
        echo “WARNING – $DAYLEFT days left to SSL certificate expiration for $MYSRV:$MYPORT”
        exit $RET_WARN
fi

echo “$DAYLEFT days left to SSL certificate expiration for $MYSRV:$MYPORT”
exit $RET_OK

Off course I scheduled this check once a day.

How to remove the NameVirtualHost *:80 has no VirtualHosts warning

Monday, February 17th, 2014

I had a debian squeeze webserver showing me this strange warning at statrup

root@web:/etc/apache2# /etc/init.d/apache2 restart
Restarting web server: apache2[Mon Feb 17 10:27:43 2014] [warn] NameVirtualHost *:443 has no VirtualHosts
[Mon Feb 17 10:27:43 2014] [warn] NameVirtualHost *:80 has no VirtualHosts
 … waiting [Mon Feb 17 10:27:44 2014] [warn] NameVirtualHost *:443 has no VirtualHosts
[Mon Feb 17 10:27:44 2014] [warn] NameVirtualHost *:80 has no VirtualHosts

This was due to a duplicated couple of lines in configuration.

NameVirtualHost *:80
NameVirtualHost *:443

in the /etc/apache2/port.conf and in /etc/apache2/conf.d/virtual.conf too. Commenting out the last file I removed the warning.

x2go

Friday, May 3rd, 2013

Thanks to a Sebastian’s post here, I noticed the existence of  x2go. I’ve just tested it and I liked it a lot. X2go is a very nice way to access my linux desktop.

In order to install x2go server-side, on a Centos 6.4 I only needed theese commands:

yum update
wget -O /etc/yum.repos.d/x2go.repo http://download.opensuse.org/repositories/X11:/RemoteDesktop:/x2go/RHEL_6/X11:RemoteDesktop:x2go.repo
yum update
yum install x2goserver

then

vi /etc/group

to add the guys to be allowed to connect to their desktop. E.g.

x2gouser:x:298:joe,jane,jack,jasmine

The x2go windows client can be downloaded from http://code.x2go.org/releases/binary-win32/x2goclient/releases/.

migrating from Microsoft DHCP to ISC

Thursday, February 23rd, 2012

I’ve just finished a quick and dirty perl script to help me in moving my DHCP server from a Micro$oft 2003 Server to Linux.

This script reads the dump file created by netsh and writes a dhcpd.conf file.
First step, on the Microsoft DHCP host, dump the configuration:

C:\temp>netsh dhcp server \\servername dump > dhcp.dump

Second step, use the perl script:

perl ./w2ldhcpcfg.txt -i dhcp.dump -o dhcpd.conf

On the net, there is a rexx script too. It can be found here.

set default Openoffice format to Micro$oft

Friday, February 10th, 2012

To set Openoffice default file format, just go to
Options -> Load/Save -> General
and change the “Always save as” value.