Tuesday, December 30, 2014

Memory leak problem for Ubuntu 14.04 with Samba service enabled

Symptom:
- Samba service is enabled on the host
- Problem exists with fresh install of Ubuntu Server 14.04.1 with samba service checked during the installation process
- The below error message will prompt on the console when executing any command with sudo
no talloc stackframe at ../source3/param/loadparm.c:4864, leaking memory
- The same error message will prompt on the console when log-in a user in the console
- Note the error message will not prompt when:
    1. log-in from a SSH session
    2. the sudo command does not prompt for a user password (possibilities such as a modified sudoer)

Cause:
The samba package that sync system user passwords with Samba database cause the problem

Workaround:
Run "pam-auth-update" and uncheck "SMB password synchronization".

My Note:
After this change every time a new user is created, below command is required to enable Samba access for the user:
sudo smbpasswd [new username]

Reference:
https://bugs.launchpad.net/ubuntu/+source/samba/+bug/1257186

ProFTPd in standalone mode stopped unexpectedly


Symptom:
- ProFTPd service running on Ubuntu 14.04 (also with Ubuntu 14.04.1) will stop unexpectedly
- Log file will show expected shutdown message:

# tail /var/log/proftpd/proftpd.log.1
...
... ProFTPD killed (signal 15)
... ProFTPD 1.3.5rc3 standalone mode SHUTDOWN

- ProFTPd cannot be restarted by means of
# service proftpd restart
On the other hand the service can be resumed by separating the stop-start commands explicitly:
# service proftpd stop
# service proftpd start

Cause:
Some suggested that the service is not restarting after certain log rotation operations

Solution:
Edit the line found in file "/etc/init.d/proftpd"
start-stop-daemon --stop --signal $SIGNAL --quiet --pidfile "$PIDFILE"

Change to below by adding a --retry option:
start-stop-daemon --stop --signal $SIGNAL --retry 1 --quiet --pidfile "$PIDFILE"

Note there are two similar lines, I can solve the problem by only changing the first appearance of the pattern "start-stop-daemon --stop"

Reference:
http://stackoverflow.com/questions/23666697/proftpd-killed-signal-15-error-how-to-fix-logrotate-restart-error

Thursday, December 11, 2014

Ubuntu Hosts not able to ping NetBIOS hostname with Samba WINS Server configured


Symptom:
- Samba WINS Server is configured on server host
- Ubuntu client host (with Ubuntu 14.04.1 Server installed) cannot ping a target via NetBIOS name added in the WINS Server host table
- Windows client host (Windows 7 / Windows 8.x) can successfully ping a target host via NetBIOS name added in the WINS Server host tabel even when the target host is down
- In the Ubuntu client host, nmblookup cannot return the IP Address of a host up and running via NetBIOS name

Cause:
A package was missed during the installation of Winbind (seems the package will not be installed in most Ubuntu Server installation)

Solution:
Run the following command in the Ubuntu client host, rebooting is not required.

sudo apt-get install libnss-winbind

Friday, September 12, 2014

List VMs with VNC port information

Objective: Create a shell script to list all VM (both running and inactive) with VNC port information in the similar output format of the standard virsh tool.
 Id    Name                           State         Vnc
------------------------------------------------------------
 2     vm1                            running       :0
 3     vm2                            running       :1
 -     vm3                            shut off

Method 1: The dirty method (This method yields the same visual output as preferred but it takes longer time to load due to excessive "virsh" commands)

#!/bin/bash
echo " Id    Name                           State         Vnc"
echo "------------------------------------------------------------"
for guestname in $(virsh list --name); do
        printf " %-6s%-31s%-14s%-6s\n" "$(virsh domid $guestname)" "$guestname" "$(virsh domstate $guestname)" "$(virsh vncdisplay $guestname)"
done
virsh -q list --inactive

Method 2: The array method (This method minimize the number of virsh calls to enhance performance.
echo " Id    Name                           State         Vnc"
echo "------------------------------------------------------------"
declare -a fields
indx=0
# array initialization is required to format an array of strings
# the "for...do...done" loop best fit the array formation of each "cell" in the virsh list table forms a single element in the array
for guestline in $(virsh -q list); do
        fields[((indx++))]=$guestline
done
max=${#fields[@]}

for ((count=0; count<$max; count=$count+3)); do
        printf " %-6d%-31s%-14s%-6s\n" ${fields[$count]} "${fields[$((count + 1))]}" "${fields[$((count + 2))]}" "`virsh vncdisplay ${fields[$((count))]}`"
done
virsh -q list --inactive