Monday, February 1, 2016

ClamAV starting issue ( CentOS 7 )

Recently, I was installing and configuring squid proxy server and dansguardian for content filtering. Dansguardian has dependencies of clamav packages.

After installing and configuring the services, when I rebooted the machine, I encountered an error for clamd.dansguardian.service.

Error :

 [root@server ~]# systemctl status clamd.dansguardian.service
clamd.dansguardian.service - Clamd Dansguardian An Interface Between MTA And Content Checkers
   Loaded: loaded (/usr/lib/systemd/system/clamd.dansguardian.service; enabled)
   Active: failed (Result: exit-code) since Tue 2016-02-02 00:34:16 EST; 34s ago
  Process: 1298 ExecStart=/usr/sbin/clamd -c /etc/clamd.d/dansguardian.conf (code=exited, status=1/FAILURE)

Feb 02 00:34:00 server.linuxroot.info systemd[1]: Starting Clamd Dansguardian An Interface Between MTA And Content Checkers...
Feb 02 00:34:02 server.linuxroot.info clamd[1298]: clamd daemon 0.98.7 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)
Feb 02 00:34:02 server.linuxroot.info clamd[1298]: Running as user root (UID 0, GID 0)
Feb 02 00:34:02 server.linuxroot.info clamd[1298]: Log file size limited to 1048576 bytes.
Feb 02 00:34:02 server.linuxroot.info clamd[1298]: Reading databases from /var/lib/clamav
Feb 02 00:34:02 server.linuxroot.info clamd[1298]: Not loading PUA signatures.
Feb 02 00:34:02 server.linuxroot.info clamd[1298]: Bytecode: Security mode set to "TrustSigned".
Feb 02 00:34:06 server.linuxroot.info clamd[1298]: LibClamAV Warning: **************************************************
Feb 02 00:34:06 server.linuxroot.info clamd[1298]: LibClamAV Warning: ***  The virus database is older than 7 days!  ***
Feb 02 00:34:06 server.linuxroot.info clamd[1298]: LibClamAV Warning: ***   Please update it as soon as possible.    ***
Feb 02 00:34:06 server.linuxroot.info clamd[1298]: LibClamAV Warning: **************************************************
Feb 02 00:34:16 server.linuxroot.info clamd[1298]: Loaded 3798335 signatures.
Feb 02 00:34:16 server.linuxroot.info clamd[1298]: ERROR: LOCAL: Socket file /var/run/dansguardian/clamd.sock could not be bou...ectory
Feb 02 00:34:16 server.linuxroot.info clamd[1298]: LOCAL: Socket file /var/run/dansguardian/clamd.sock could not be bound: No ...ectory
Feb 02 00:34:16 server.linuxroot.info systemd[1]: clamd.dansguardian.service: control process exited, code=exited status=1
Feb 02 00:34:16 server.linuxroot.info systemd[1]: Failed to start Clamd Dansguardian An Interface Between MTA And Content Checkers.
Feb 02 00:34:16 server.linuxroot.info systemd[1]: Unit clamd.dansguardian.service entered failed state.
Hint: Some lines were ellipsized, use -l to show in full.



Solution :

NOTE : Before making any changes, kindly take a backup copy of all the files that are going to be modified.

I made changes in below files. 

[root@server ~]# vim /etc/clamd.d/dansguardian.conf

PidFile /var/run/clamd.pid
User root
LocalSocket /var/run/clamd.sock


[root@server ~]# vim /etc/sysconfig/clamd.dansguardian

CLAMD_SOCKET=/var/run/clamd.sock

[root@server ~]# vim /usr/lib/systemd/system/clamd.dansguardian.service

PIDFile=/var/run/clamd.pid









































Monday, September 28, 2015

BCM4313 Wireless Adaptor Error

Since many time, I was facing an issue of wireless network adapter. My wireless was working perfectly.

The error appeared at the boot time.

b43-phy0 ERROR: FOUND UNSUPPORTED PHY (Analog 10, Type 8 (LCN), Revision 1)


b43 firmware doesn't support BCM4313 wireless network adapter

root@nirav:~# lspci | grep -i network
05:00.0 Network controller: Broadcom Corporation BCM4313 802.11bgn Wireless Network Adapter (rev 01)

blacklist "b43 module"

root@nirav:~# vim /etc/modprobe.d/blacklist.conf

at the end of file

blacklist b43

root@nirav:~# rmmod b43


root@nirav:~# lsmod | grep b43


I restarted the system to ensure the b43 module is not loaded.

root@nirav:~# reboot 

Wednesday, August 12, 2015

Linux GPT Partitioning

In linux, for MBR disk the partition size can only go upto maximum 0f 2TB.

To solve this problem use GNU parted command with GPT ( GUID Partition Table format). It supports Intel EFI/GPT partition tables. (GPT) is a standard for the layout of the partition table on a physical hard disk.

Create a new GPT disklabel

root@nirav:~# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands


Create a new GPT disklabel

(parted) mklabel gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes

set the default unit to TB

(parted) unit TB


Make a partition of 4TB

(parted) mkpart primary 0.00TB 4.00TB


Print the partition table

(parted) print

Model: ATA WDC WD40PURX-64G (scsi)
Disk /dev/sdb: 4.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  4.00TB  4.00TB  ext4         primary


(parted) quit

Information: You may need to update /etc/fstab.

root@nirav:~# mkfs.ext4 /dev/sdb1
 


Thursday, August 6, 2015

Boot Partition Full ( CentOS 7 )

root@nirav:~# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root   96G   15G   77G  16% /
devtmpfs              3.8G     0  3.8G   0% /dev
tmpfs                 3.8G  152K  3.8G   1% /dev/shm
tmpfs                 3.8G  9.1M  3.8G   1% /run
tmpfs                 3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda1             283M  270M     0 100% /boot
/dev/mapper/vg0-home  577G  124G  424G  23% /home


Limit to only 2 kernels.

root@nirav:~# vim /etc/yum.conf

installonly_limit=2

Below command will remove all the old kernels keeping the recent 2 kernels.

root@nirav:~# package-cleanup --oldkernels --count=2
Loaded plugins: fastestmirror, langpacks
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-123.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-229.1.2.el7 will be erased
---> Package kernel.x86_64 0:3.10.0-229.4.2.el7 will be erased
---> Package kernel-devel.x86_64 0:3.10.0-229.1.2.el7 will be erased
---> Package kernel-devel.x86_64 0:3.10.0-229.4.2.el7 will be erased
--> Finished Dependency Resolution
base/7/x86_64                              | 3.6 kB  00:00:00    
epel/x86_64/metalink                       | 3.2 kB  00:00:00    
extras/7/x86_64                            | 3.4 kB  00:00:00    
google-chrome                              | 951 B   00:00:00    
nux-dextop/x86_64                          | 2.9 kB  00:00:04    
updates/7/x86_64                           | 3.4 kB  00:00:00    

Dependencies Resolved

=====================================================================
 Package        Arch       Version          Repository      Size
=====================================================================
Removing:
 kernel        x86_64   3.10.0-123.el7       @anaconda      127 M
 kernel        x86_64   3.10.0-229.1.2.el7   @updates       131 M
 kernel        x86_64   3.10.0-229.4.2.el7   @updates       131 M
 kernel-devel  x86_64   3.10.0-229.1.2.el7   @updates       32 M
 kernel-devel  x86_64   3.10.0-229.4.2.el7   @updates       32 M

Transaction Summary
=====================================================================
Remove  5 Packages

Installed size: 453 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : kernel-devel.x86_64                           1/5
  Erasing    : kernel.x86_64                                 2/5
warning: file /lib/modules/3.10.0-229.1.2.el7.x86_64/weak-updates: remove failed: No such file or directory
warning: file /lib/modules/3.10.0-229.1.2.el7.x86_64/modules.softdep: remove failed: No such file or directory
warning: file /lib/modules/3.10.0-229.1.2.el7.x86_64/modules.devname: remove failed: No such file or directory
  Erasing    : kernel-devel.x86_64                           3/5
  Erasing    : kernel.x86_64                                 4/5
warning: file /lib/modules/3.10.0-123.el7.x86_64/modules.softdep: remove failed: No such file or directory
warning: file /lib/modules/3.10.0-123.el7.x86_64/modules.devname: remove failed: No such file or directory
  Erasing    : kernel.x86_64                                 5/5
warning: file /lib/modules/3.10.0-229.4.2.el7.x86_64/weak-updates: remove failed: No such file or directory
warning: file /lib/modules/3.10.0-229.4.2.el7.x86_64/modules.softdep: remove failed: No such file or directory
warning: file /lib/modules/3.10.0-229.4.2.el7.x86_64/modules.devname: remove failed: No such file or directory
  Verifying  : kernel-3.10.0-229.4.2.el7.x86_64              1/5
  Verifying  : kernel-3.10.0-123.el7.x86_64                  2/5
  Verifying  : kernel-devel-3.10.0-229.4.2.el7.x86_64        3/5
  Verifying  : kernel-3.10.0-229.1.2.el7.x86_64              4/5
  Verifying  : kernel-devel-3.10.0-229.1.2.el7.x86_64        5/5

Removed:
kernel.x86_64 0:3.10.0-123.el7
kernel.x86_64 0:3.10.0-229.1.2.el7
kernel.x86_64 0:3.10.0-229.4.2.el7    
kernel-devel.x86_64 0:3.10.0-229.1.2.el7
kernel-devel.x86_64 0:3.10.0-229.4.2.el7    

Complete!

root@nirav:~# df -h

Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg0-root   96G   15G   77G  16% /
devtmpfs              3.8G     0  3.8G   0% /dev
tmpfs                 3.8G  152K  3.8G   1% /dev/shm
tmpfs                 3.8G  9.1M  3.8G   1% /run
tmpfs                 3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda1             283M  142M  123M  54% /boot
/dev/mapper/vg0-home  577G  124G  424G  23% /home

Monday, August 3, 2015

Setup Samba4 AD DC ( CentOS 7 )

[root@server ~]# vim /etc/hosts

192.168.0.162   server.linuxroot.info   server

Disable SELinux and Firewall

[root@server ~]# vim /etc/sysconfig/selinux

From SELINUX=enforcing to SELINUX=disabled

[root@server ~]# systemctl stop firewalld.service

[root@server ~]# systemctl disable firewalld.service
 
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

Install all the required libraries and programs

[root@server ~]# yum install perl gcc libacl-devel libblkid-devel gnutls-devel readline-devel python-devel gdb pkgconfig krb5-workstation zlib-devel setroubleshoot-server libaio-devel setroubleshoot-plugins policycoreutils-python libsemanage-python setools-libs-python setools-libs popt-devel libpcap-devel sqlite-devel libidn-devel libxml2-devel libsepol-devel libattr-devel keyutils-libs-devel cyrus-sasl-devel cups-devel bind-utils libxslt docbook-style-xsl openldap-devel

Download the lastest samba 4 tar from https://www.samba.org/

[root@server ~]# wget https://download.samba.org/pub/samba/stable/samba-4.3.4.tar.gz

[root@server ~]# tar -xvf samba-4.3.4.tar.gz

[root@server ~]# cd samba-4.3.4/

Now configure,build and install Samba4.

By default, the Samba4 will be installed in /usr/local/samba/ directory.

[root@server samba-4.3.4]#./configure --enable-selftest --enable-debug --prefix=/opt/samba/ --sysconfdir=/etc/samba/ --includedir=/usr/include/samba4/ --bindir=/bin/ --sbindir=/sbin/ --mandir=/usr/share/man/


--prefix        : installation directory
--sysconfdir    : smb.conf should be places
--includedir    : includes the header files for C compilers
--bindir        : user executables
--sbindir       : system admin executables
--mandir        : man pages to be placed


'configure' finished successfully (1m56.738s)

[root@server samba-4.3.4]# make

'build' finished successfully (18m28.484s)

[root@server samba-4.3.4]# make install

'install' finished successfully (4m56.944s)

[root@server samba-4.3.4]# vim /etc/resolv.conf

domain    linuxroot.info
nameserver 192.168.0.162

[root@server samba-4.3.4]# samba-tool domain provision
Realm [LINUXROOT.INFO]: Press Enter
 Domain [LINUXROOT]: Press Enter
 Server Role (dc, member, standalone) [dc]: Press Enter
 DNS backend (SAMBA_INTERNAL, BIND9_FLATFILE, BIND9_DLZ, NONE) [SAMBA_INTERNAL]: Press Enter
 DNS forwarder IP address (write 'none' to disable forwarding) [192.168.0.162]: 8.8.8.8
Administrator password: provide password
Retype password: re-type password
Looking up IPv4 addresses
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up share.ldb
Setting up secrets.ldb
Setting up the registry
Setting up the privileges database
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
Adding DomainDN: DC=linuxroot,DC=info
Adding configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Modifying display specifiers
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up well known security principals
Setting up sam.ldb users and groups
Setting up self join
Adding DNS accounts
Creating CN=MicrosoftDNS,CN=System,DC=linuxroot,DC=info
Creating DomainDnsZones and ForestDnsZones partitions
Populating DomainDnsZones and ForestDnsZones partitions
Setting up sam.ldb rootDSE marking as synchronized
Fixing provision GUIDs
A Kerberos configuration suitable for Samba 4 has been generated at /opt/samba/private/krb5.conf
Once the above files are installed, your Samba4 server will be ready to use
Server Role:           active directory domain controller
Hostname:              server
NetBIOS Domain:        LINUXROOT
DNS Domain:            linuxroot.info
DOMAIN SID:            S-1-5-21-1623651871-590293421-3205222097


[root@server samba-4.3.4]# cp -p /etc/krb5.conf /etc/krb5.conf.orig

[root@server samba-4.3.4]# cp -p /opt/samba/private/krb5.conf /etc/
cp: overwrite ‘/etc/krb5.conf’? y

Now make an init script for Samba4 to start the service automatically at boot time.

[root@server samba-4.3.4]# vim  /etc/rc.d/init.d/samba4
#!/bin/bash
#
# samba4        This shell script takes care of starting and stopping
#               samba4 daemons.
#
# chkconfig: - 58 74
# description: Samba 4.0 will be the next version of the Samba suite
# and incorporates all the technology found in both the Samba4 alpha
# series and the stable 3.x series. The primary additional features
# over Samba 3.6 are support for the Active Directory logon protocols
# used by Windows 2000 and above.

### BEGIN INIT INFO
# Provides: samba4

# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Should-Start: $syslog $named
# Should-Stop: $syslog $named
# Short-Description: start and stop samba4
# Description: Samba 4.0 will be the next version of the Samba suite
# and incorporates all the technology found in both the Samba4 alpha
# series and the stable 3.x series. The primary additional features
# over Samba 3.6 are support for the Active Directory logon protocols
# used by Windows 2000 and above.
### END INIT INFO

# Source function library.
. /etc/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

prog=samba
prog_dir=/sbin/
lockfile=/var/lock/subsys/$prog

start() {
        [ "$NETWORKING" = "no" ] && exit 1
#       [ -x /usr/sbin/ntpd ] || exit 5
                # Start daemons.
                echo -n $"Starting samba4: "
                daemon $prog_dir/$prog -D
        RETVAL=$?
                echo
        [ $RETVAL -eq 0 ] && touch $lockfile
        return $RETVAL
}

stop() {
        [ "$EUID" != "0" ] && exit 4
                echo -n $"Shutting down samba4: "
        killproc $prog_dir/$prog
        RETVAL=$?
                echo
        [ $RETVAL -eq 0 ] && rm -f $lockfile
        return $RETVAL
}

# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
status)
        status $prog
        ;;
restart)
        stop
        start
        ;;
reload)
        echo "Not implemented yet."
        exit 3
        ;;
*)
        echo $"Usage: $0 {start|stop|status|restart|reload}"
        exit 2
esac

[root@server samba-4.3.4]# chmod +x /etc/rc.d/init.d/samba4

[root@server samba-4.3.4]# chkconfig --add /etc/rc.d/init.d/samba4

[root@server samba-4.3.4]# chkconfig samba4 on

[root@server samba-4.3.4]# service samba4 start
Starting samba4 (via systemctl):                           [ OK ]





Thursday, July 23, 2015

Hide users list from login screen Ubuntu 10.04 ( The Lucid Lynx )

  

root@nirav:~# vim /etc/gdm/gdm.schemas
 
Look for “greeter/Exclude” section 
you will see <default> tags

<default>bin,root,daemon,adm,lp,sync,shutdown,halt,mail,news,uucp,operator,nobody,nobody4,noaccess,postgres,pvm,rpm,nfsnobody,pcap</default>

Add users you wish not to be seen in the user list from login screen. 

I Added the users user1,user2,user3 between the default tags

<default>bin,root,daemon,adm,lp,sync,shutdown,halt,mail,news,uucp,operator,nobody,nobody4,noaccess,postgres,pvm,rpm,nfsnobody,pcap,user1,user2,user3</default>

root@nirav:~# reboot