Monday, September 22, 2008

How to disable a specific command(s) for a certain user.

Please follow the below steps to disable a specific command(s) for a certain user.

# su - hari
$ which rm (Here rm command as an example)
$ mkdir ~/bin
$ ln -s /bin/* ~/bin/ (/bin is the PATH for rm)
$ rm -rf ~/bin/rm

Take the output of $PATH for this user

$ echo $PATH > MyPATH.txt
Edit this file and replace /bin with ~/bin

Login as root

$ su -
# cat /home/hari/MyPATH.txt >> /home/hari/.bashrc

Change the permission of /home/hari/.bashrc
# chmod 444 /home/hari/.bashrc
# chattr +i /home/hari/.bashrc


That's all.
But the user can reset the PATH variable anytime to overcome this.
Please comment with alternatives for this.

Monday, July 28, 2008

Disable Media Check for cdrom

Grub.conf
dma=off apci=off apm=off

/etc/hdparm.conf
command_line {
hdparm -d1 /dev/cdrom
}

command_line {
hdparm -d1 /dev/cdrom1
}

sysctl.conf
dev.cdrom.check_media = 0

MySQL Compilation

# groupadd mysql
# useradd -g mysql -c "MySQL Server" mysql
# tar zxf mysql-5.0.45.tar.gz
# cd /usr/local/src/ mysql-5.0.45
# .chown -R root.root *
# ./configure \--prefix=/usr/local/mysql \--localstatedir=/usr/local/mysql/data \--disable-maintainer-mode \--with-mysqld-user=mysql \--with-unix-socket-path=/tmp/mysql.sock \--without-comment \--without-debug \

# groupadd mysql
# useradd -g mysql -c "MySQL Server" mysql
# tar zxf mysql-5.0.45.tar.gz
# cd /usr/local/src/ mysql-5.0.45
# chown -R root.root *
# ./configure \--prefix=/usr/local/mysql \--localstatedir=/usr/local/mysql/data \--disable-maintainer-mode # \--with-mysqld-user=mysql \--with-unix-socket-path=/tmp/mysql.sock \--without-comment \--without-debug \--without-bench
# make && make install
# ./scripts/mysql_install_db
# chown -R root:mysql /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql/data
# cp support-files/my-medium.cnf /etc/my.cnf
# chown root:sys /etc/my.cnf
# chmod 644 /etc/my.cnf
# echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
# ldconfig
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysql
# chmod +x /etc/rc.d/init.d/mysql
# /sbin/chkconfig --level 3 mysql on
# cd /usr/local/mysql/bin
# for file in *; do ln -s /usr/local/mysql/bin/$file /usr/bin/$file;

# /etc/init.d/mysql start

Open multiple tabs with Gnome-Tminal

gnome-terminal --geometry=125x75 --tab -e "ssh
192.168.0.67 -l myuser" --tab -e "ssh
192.168.0.45 -l root" --tab -e "ssh 192.168.0.88 -l
root" --tab -e "ssh 192.168.1.145 -l root -p 22999"

Set date from CLI

# date 030710532008
date
Fri Mar 7 10:53:01 IST 2008

Tuesday, March 11, 2008

Bugzilla installation

Reference
bugzilla.org
Download the latest Stable Release
# cd /usr/local/src
# wget http://ftp.mozilla.org/pub/mozilla.org/webtools/bugzilla-3.0.3.tar.gz
# tar xzf bugzilla-3.0.3.tar.gz
# cd bugzilla-3.0.3
First,run the checksetup.pl script to check for any dependant packages that need to be installed
# ./checksetup.pl --check-modules
NOTE: You must run any commands listed below as root.
***********************************************************************
* REQUIRED MODULES *
***********************************************************************
* Bugzilla requires you to install some Perl modules which are either *
* missing from your system, or the version on your system is too old. *
* *
* The latest versions of each module can be installed by running the *
* commands below. *
***********************************************************************
COMMANDS:
/usr/bin/perl -MCPAN -e 'install "Email::Send"'
/usr/bin/perl -MCPAN -e 'install "Template"'
/usr/bin/perl -MCPAN -e 'install "Email::MIME::Modifier"'
/usr/bin/perl -MCPAN -e 'install "Date::Format"'
So run one by one
# /usr/bin/perl -MCPAN -e 'install "Email::Send"'
Fine
# /usr/bin/perl -MCPAN -e 'install "Template"'
Fine
# /usr/bin/perl -MCPAN -e 'install "Email::MIME::Modifier"'
Fine
# /usr/bin/perl -MCPAN -e 'install "Date::Format"
Fine
Now configure Database and Apache settings
# cd /usr/local/src/bugzilla-3.0.3
# vi localconfig

$create_htaccess = 1;
$webservergroup = 'nobody';
$db_driver = 'mysql';
$db_host = 'localhost';
$db_name = 'bugs';
$db_user = 'bugs';
$db_pass = 'secret';
$db_port = 3306;
$db_sock = '/tmp/mysql.sock';
$db_check = 1;
$index_html = 0;
$cvsbin = '/usr/bin/cvs';
$interdiffbin = '/usr/bin/interdiff';
$diffpath = '/usr/bin';

Re-run checksetup.pl
# ./checksetup.pl
Now it will create the database and WebServer data like .htaccess files.
MySQL
Allow large attachments
# vi /etc/my.cnf
max_allowed_packet=1M
Allow small words in full-text indexes
ft_min_word_len=2
Add a user to MySQL
# mysql -u root -pmysql
mysql> GRANT SELECT, INSERT, UPDATE, DELETE, INDEX, ALTER, CREATE, LOCK TABLES, CREATE TEMPORARY TABLES, DROP, REFERENCES ON bugs.* TO bugs@localhost IDENTIFIED BY 'secret';
Query OK, 0 rows affected (0.04 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
Configure Apache
First create a soft link to Bugzilla in your WebServer's DocumentRoot
# cd /var/www/html
# ln -s /usr/local/src/bugzilla-3.0.3 bugzilla
# vi /usr/local/apache/conf/httpd.conf

AddHandler cgi-script .cgi
Options +Indexes +ExecCGI
DirectoryIndex index.cgi
AllowOverride Limit

# /usr/local/apache/bin/apachectl restart
Now it should up at http://localhost/bugzilla

Tuesday, March 4, 2008

Log Server using Syslog-NG

Server - RHEL 5
Stop Syslog and turn it off through Run Levels

# service syslog stop
# chkconfig syslog off

Download syslog-ng
# cd /usr/local/src
# wget http://www.balabit.com/downloads/files/eventlog/0.2/eventlog-0.2.5.tar.gz

# tar xzf eventlog-0.2.5.tar.gz
# cd eventlog-0.2.5
# ./configure --prefix=/usr/local/eventlog
# make
# make install

# cd /usr/local/src
# wget http://www.balabit.com/downloads/files/libol/0.3/libol-0.3.18.tar.gz
# tar xzf libol-0.3.18.tar.gz
# cd libol-0.3.18
# ./configure --prefix=/usr/local/libol
# make
# make install

# cd /usr/local/src
# wget http://www.balabit.com/downloads/files/syslog-ng/sources/2.0/src/syslog-ng-2.0.6.tar.gz
# tar xzf syslog-ng-2.0.6.tar.gz
# cd syslog-ng-2.0.6

# export PKG_CONFIG_PATH=/usr/local/eventlog/lib/pkgconfig
# ./configure --prefix=/usr/local/syslog-ng --with-libol=/usr/local/libol/
# make
# make install

# cd /usr/local/syslog-ng
# mkdir etc
# cd etc
# vi syslog-ng.conf

### Refer http://www.campin.net/syslog-ng.conf
options {
keep_hostname(yes);
long_hostnames(off);
sync(1);
log_fifo_size(1024);
};

source src {
pipe("/proc/kmsg");
unix-stream("/dev/log");
internal();
udp();
tcp(port(5140) keep-alive(yes));
};

destination authlog { file("/var/log/syslog-ng/auth.log"); };
destination syslog { file("/var/log/syslog-ng/syslog"); };
destination cron { file("/var/log/syslog-ng/cron.log"); };
destination daemon { file("/var/log/syslog-ng/daemon.log"); };
destination kern { file("/var/log/syslog-ng/kern.log"); };
destination lpr { file("/var/log/syslog-ng/lpr.log"); };
destination user { file("/var/log/syslog-ng/user.log"); };
destination uucp { file("/var/log/syslog-ng/uucp.log"); };

destination mail { file("/var/log/syslog-ng/mail.log"); };
destination maillog { file("/var/log/syslog-ng/maillog"); };
destination mailinfo { file("/var/log/syslog-ng/mail.info"); };
destination mailwarn { file("/var/log/syslog-ng/mail.warn"); };
destination mailerr { file("/var/log/syslog-ng/mail.err"); };

destination debug { file("/var/log/syslog-ng/debug"); };
destination messages { file("/var/log/syslog-ng/messages"); };

destination console { usertty("root"); };

destination console_all { file("/dev/tty8"); };

filter f_attack_alert {
match("attackalert");
};

filter f_ssh_login_attempt {
program("sshd.*")
and match("(Failed|Accepted)")
and not match("Accepted (hostbased|publickey) for (root|zoneaxfr) from (10.4.3.1)");
};

filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { not facility(auth, authpriv) and not facility(mail); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_user { facility(user); };
filter f_uucp { facility(cron); };

filter f_news { facility(news); };

filter f_debug { not facility(auth, authpriv, news, mail); };
filter f_messages { level(info .. warn)
and not facility(auth, authpriv, cron, daemon, mail, news); };
filter f_emergency { level(emerg); };

filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };

filter f_cnews { level(notice, err, crit) and facility(news); };
filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); };

filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };

filter f_cnews { level(notice, err, crit) and facility(news); };
filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); };

log { source(src); filter(f_authpriv); destination(authlog); };
log { source(src); filter(f_syslog); destination(syslog); };
log { source(src); filter(f_cron); destination(cron); };
log { source(src); filter(f_daemon); destination(daemon); };
log { source(src); filter(f_daemon); destination(messages); };
log { source(src); filter(f_kern); destination(messages); };
log { source(src); filter(f_lpr); destination(lpr); };
log { source(src); filter(f_mail); destination(mail); };
log { source(src); filter(f_user); destination(user); };
log { source(src); filter(f_user); destination(messages); };
log { source(src); filter(f_uucp); destination(uucp); };
log { source(src); filter(f_mail); destination(maillog); };
log { source(src); filter(f_mail); filter(f_info); destination(mailinfo); };
log { source(src); filter(f_mail); filter(f_warn); destination(mailwarn); };
log { source(src); filter(f_mail); filter(f_err); destination(mailerr); };
log { source(src); filter(f_messages); destination(messages); };
log { source(src); filter(f_emergency); destination(console); };

destination HOSTBASED {
file("/var/log/syslog-ng/HOSTBASED/$HOST/$YEAR/$MONTH/$DAY/$FACILITY_$HOST_$YEAR_$MONTH_$DAY"
owner(root) group(root) perm(0600) dir_perm(0700) create_dirs(yes)
);
};

log {
source(src);
destination(HOSTBASED);
};


# mkdir /var/log/syslog-ng

Started syslog-ng daemon
# /usr/local/syslog-ng/sbin/syslog-ng

Client - RHEL 5

Stop Syslog and turn it off through Run Levels

# service syslog stop
# chkconfig syslog off

Download syslog-ng
# cd /usr/local/src
# wget http://www.balabit.com/downloads/files/eventlog/0.2/eventlog-0.2.5.tar.gz
# tar xzf eventlog-0.2.5.tar.gz
# cd eventlog-0.2.5
# ./configure --prefix=/usr/local/eventlog
# make
# make install

# cd /usr/local/src
# wget http://www.balabit.com/downloads/files/libol/0.3/libol-0.3.18.tar.gz
# tar xzf libol-0.3.18.tar.gz
# cd libol-0.3.18
# ./configure --prefix=/usr/local/libol
# make
# make install

# cd /usr/local/src
# wget http://www.balabit.com/downloads/files/syslog-ng/sources/2.0/src/syslog-ng-2.0.6.tar.gz
# tar xzf syslog-ng-2.0.6.tar.gz
# cd syslog-ng-2.0.6

# export PKG_CONFIG_PATH=/usr/local/eventlog/lib/pkgconfig
# ./configure --prefix=/usr/local/syslog-ng --with-libol=/usr/local/libol/
# make
# make install

# cd /usr/local/syslog-ng
# mkdir etc
# cd etc
# vi syslog-ng.conf

Reference - http://www.campin.net/syslog-ng.conf

options {
keep_hostname(yes);
long_hostnames(off);
sync(1);
log_fifo_size(1024);
};

source src {
pipe("/proc/kmsg");
unix-stream("/dev/log");
internal();
udp();
tcp(port(5140) keep-alive(yes));
};

destination loghost { tcp("192.168.0.111" port(5140)); };

filter f_attack_alert {
match("attackalert");
};

filter f_ssh_login_attempt {
program("sshd.*")
and match("(Failed|Accepted)")
and not match("Accepted (hostbased|publickey) for (root|zoneaxfr) from (10.4.3.1)");
};

filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { not facility(auth, authpriv) and not facility(mail); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_user { facility(user); };
filter f_uucp { facility(cron); };

filter f_news { facility(news); };

filter f_debug { not facility(auth, authpriv, news, mail); };
filter f_messages { level(info .. warn)
and not facility(auth, authpriv, cron, daemon, mail, news); };
filter f_emergency { level(emerg); };

filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };

filter f_cnews { level(notice, err, crit) and facility(news); };
filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); };
filter f_emergency { level(emerg); };

filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };

filter f_cnews { level(notice, err, crit) and facility(news); };
filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); };

log { source(src); filter(f_authpriv); destination(loghost); };
log { source(src); filter(f_syslog); destination(loghost); };
log { source(src); filter(f_daemon); destination(loghost); };
log { source(src); filter(f_kern); destination(loghost); };
log { source(src); filter(f_lpr); destination(loghost); };
log { source(src); filter(f_mail); destination(loghost); };
log { source(src); filter(f_user); destination(loghost); };
log { source(src); filter(f_uucp); destination(loghost); };
log { source(src); filter(f_mail); destination(loghost); };
log { source(src); filter(f_mail); filter(f_info); destination(loghost); };

filter f_emergency { level(emerg); };

filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };

filter f_cnews { level(notice, err, crit) and facility(news); };
filter f_cother { level(debug, info, notice, warn) or facility(daemon, mail); };

log { source(src); filter(f_authpriv); destination(loghost); };
log { source(src); filter(f_syslog); destination(loghost); };
log { source(src); filter(f_daemon); destination(loghost); };
log { source(src); filter(f_kern); destination(loghost); };
log { source(src); filter(f_lpr); destination(loghost); };
log { source(src); filter(f_mail); destination(loghost); };
log { source(src); filter(f_user); destination(loghost); };
log { source(src); filter(f_uucp); destination(loghost); };
log { source(src); filter(f_mail); destination(loghost); };
log { source(src); filter(f_mail); filter(f_info); destination(loghost); };
log { source(src); filter(f_mail); filter(f_warn); destination(loghost); };
log { source(src); filter(f_mail); filter(f_err); destination(loghost); };
log { source(src); filter(f_messages); destination(loghost); };
log { source(src); filter(f_emergency); destination(loghost); };

destination std {
file("/var/log/HOSTS/$HOST/$YEAR/$MONTH/$DAY/$FACILITY_$HOST_$YEAR_$MONTH_$DAY"
owner(root) group(root) perm(0600) dir_perm(0700) create_dirs(yes)
);
};

log {
source(src);
destination(std);
};


# mkdir /var/log/syslog-ng

Started syslog-ng daemon
# /usr/local/syslog-ng/sbin/syslog-ng

AT&T USA | Internet not working | Fix by custom APN

If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...