Pages

Friday, April 25, 2014

Bash script to save user history

Hi

Please find the below script which can save each users history to a common place for security purpose. So that later admin can review the commands performed by each user on the machine. (like who has stopped some service, who reboot the machine etc)

#!/bin/bash
echo "date > date.txt" >> .bash_profile
touch .logout.sh
read -r -d '' FILECONTENT <<'ENDFILECONTENT'
#!/bin/bash
user=`whoami`
var=`cat date.txt`
echo "The user $user logged to this machine at $var"
echo "The user $user executed the below commands"
history
echo "The session completed at `date`"
history -c
history -w
ENDFILECONTENT
echo "$FILECONTENT" > .logout.sh
chmod 700 .logout.sh
echo "source .logout.sh >> /tmp/historylog" >> .bash_logout


save this content as some file.sh like history.sh
give 700 permission
chmod 700 history.sh
./history.sh

Note : it will clear the session's history each time.


Wednesday, January 8, 2014

PHP recompile to get JPEG support

How to enable JPEG support in PHP

1. Run the below command to test whether JPEG support is there or not

#php -r 'print_r(gd_info());'

Output :

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] =>
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] =>
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
)

2. rpm -qa | grep -e libjpeg

if you get output like below

libjpeg-turbo-1.2.1-3.el6_5

then go forward, otherwise install the library

3. check where the library is

find / -name libjpeg*

it may be inside /usr/lib64. Make symbollic link to /usr/lib

ln -s /usr/lib64/libjpeg.so /usr/lib/libjpeg.so
ln -s /usr/lib64/libjpeg.so.62.0.0 /usr/lib/libjpeg.so.62.0.0
ln -s /usr/lib64/libjpeg.so.62 /usr/lib/libjpeg.so.62

4. then recompile PHP

goto the php downloaded folder and do "make clean"

then

./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-zlib --enable-mbstring  --with-gd  --with-pdo-mysql --with-jpeg --with-jpeg-dir=/usr/lib

make

make install

5. Verify JPEG support as below


#php -r 'print_r(gd_info());'

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] =>
    [T1Lib Support] =>
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [JIS-mapped Japanese Font Support] =>
)