[root@rrd chroot]# /etc/init.d/mysqld start
Starting MySQL [ OK ]
[root@rrd chroot]# ps -ef|grep mysqld
root 12784 1 0 22:22 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/rrd.pid
mysql 12886 12784 0 22:22 pts/0 00:00:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql --log-error=/usr/local/mysql/data/rrd.err --pid-file=/usr/local/mysql/data/rrd.pid --socket=/usr/local/mysql/tmp/mysql.sock --port=3306
root 12901 3265 0 22:22 pts/0 00:00:00 grep mysqld
[root@rrd chroot]# killall mysqld
[root@rrd chroot]# killall mysqld
[root@rrd chroot]# killall mysqld
[root@rrd chroot]# cp -a /usr/local/mysql/ .
[root@rrd chroot]# find / -name mysqld
/etc/rc.d/init.d/mysqld
/usr/local/mysql/libexec/mysqld
/home/lincong/tools/mysql-5.1.52/sql/mysqld
/chroot/mysql/usr/local/mysql/libexec/mysqld
/var/chroot/mysql/libexec/mysqld
[root@rrd chroot]# /var/chroot/mysql/libexec/mysqld ##启动时有错误
120831 22:29:51 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
120831 22:29:51 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
120831 22:29:51 [ERROR] Aborting
120831 22:29:51 [Note] /var/chroot/mysql/libexec/mysqld: Shutdown complete
解决办法:
[root@rrd chroot]# vim etc/my.cnf
[mysqld]
#skip-locking##注释掉
skip-external-locking ##添加这行
[root@rrd chroot]# /var/chroot/mysql/libexec/mysqld ##还有错误
120831 22:38:50 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!
120831 22:38:50 [ERROR] Aborting
120831 22:38:50 [Note] /var/chroot/mysql/libexec/mysqld: Shutdown complete
解决办法:
[root@rrd chroot]# vim /etc/my.cnf
[mysqld]
user = mysql
[root@rrd chroot]# cp /etc/my.cnf etc/my.cnf
[root@rrd chroot]# /var/chroot/mysql/libexec/mysqld
120831 22:44:27 InnoDB: Started; log sequence number 0 44233
120831 22:44:27 [Note] Event Scheduler: Loaded 0 events
120831 22:44:27 [Note] /var/chroot/mysql/libexec/mysqld: ready for connections.
Version: '5.1.52' socket: '/usr/local/mysql/tmp/mysql.sock' port: 3306 Source distribution
Last login: Fri Aug 31 18:32:41 2012 from 172.16.0.132
[root@rrd ~]# netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:686 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 :::80 :::* LISTEN
tcp 0 0 :::22 :::* LISTEN
[root@rrd ~]# ps -ef|grep mysqld
mysql 12987 1 0 22:44 ? 00:00:00 /var/chroot/mysql/libexec/mysqld
root 13041 13011 0 22:50 pts/1 00:00:00 grep mysqld
[root@rrd ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.52 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
[root@rrd ~]# chroot /var/chroot/
bash-3.2# ls
apache2.2.21 bin dev etc home lib lib64 mysql proc tmp usr var
######################################################################################
[root@rrd src]# /usr/local/jail/bin/addjailsw /var/chroot/
或
[root@rrd src]# /usr/local/jail/bin/addjailsw /var/chroot/ -D
或
[root@rrd src]# /usr/local/jail/bin/addjailsw /var/chroot/ -P bash "--version"
addjailsw
A component of Jail (version 1.9 for linux)
http://www.jmcresearch.com/projects/jail/
Juan M. Casillas <juanm.casillas@jmcresearch.com>
Guessing mv args()
Guessing ls args()
Guessing ln args()
Guessing grep args()
Guessing cat args()
Guessing rmdir args()
Guessing vi args(-c q)
Guessing tail args()
Guessing sh args()
Guessing id args()
Guessing rm args()
Guessing head args()
Guessing cp args()
Guessing pwd args()
Guessing mkdir args()
Guessing touch args()
Guessing more args()
还记得这步吧!所以chroot /var/chroot/后的bash-3.2#运行命令是有限的
bash-3.2# whoami##就算是root用户执行的命令也是有限的
root
