пятница, 23 апреля 2010 г.

pipe status return code

$ set -o pipefail
$ grep steve /etc/passwd | cut -f5 -d: --bogus-option | tr '[a-z]' '[A-Z]'
cut: unrecognized option `--bogus-option'
Try `cut --help' for more information.
$ echo $?
1

Example of using the PIPESTATUS variable, and referencing all elements of the array using ${PIPESTATUS[@]}:
$ grep steve /etc/passwd | cut -f5 -d: --bogus-option | tr '[a-z]' '[A-Z]'
cut: unrecognized option `--bogus-option'
Try `cut --help' for more information.
$ echo ${PIPESTATUS[@]}
141 1 0

Оригинал
http://phpsuxx.blogspot.com/2010/04/blog-post_2624.html

четверг, 22 апреля 2010 г.

ssl key and crt verify

echo -n test | /usr/bin/openssl rsautl -sign -inkey localhost.key | /usr/bin/openssl rsautl -verify -inkey localhost.crt -certin

среда, 21 апреля 2010 г.

arpsend

arpsend -c 1 -w 1 -U -i 192.168.1.10 -e 192.168.1.10 eth0

arpsend sends ARP packets on device interface to detect or update neighbours ARP caches with a given IP.

executed by /usr/lib64/vzctl/scripts/vps-functions

remove ip from interface on linux

ip address del 192.168.8.9/24 brd + dev eth0

вторник, 20 апреля 2010 г.

install mod_fakephp on debian

svn co http://svn.dmi.me.uk/mod_fakephp/trunk mod_fakephp
cd mod_fakephp/src/
apxs2 -i -c -n mod_fakephp.so mod_fakephp.c


cd /etc/apache2/mods-available/
echo "LoadModule fakephp_module /usr/lib/apache2/modules/mod_fakephp.so" > fakephp.load

cd ../mods-enabled/
ln -s ../mods-available/fakephp.load fakephp.load
/etc/init.d/apache restart

понедельник, 5 апреля 2010 г.

.htaccess php_flag with fastcgi on debian

apt-get source apache2
cd apache2-2.2.9/
vi dummy_php_options.patch


--- httpd-2.0.59/server/core.c 2006-07-12 07:40:55.000000000 +0000
+++ httpd-2.0.59/server/core.c 2006-12-20 16:54:16.000000000 +0000
@@ -1638,6 +1638,11 @@
"> directive missing closing '>'", NULL);
}

+static const char *php_dummy_handler(cmd_parms *cmd, void *dummy, const char *name, const char *value)
+{
+ return NULL;
+}
+
static const char *dirsection(cmd_parms *cmd, void *mconfig, const char *arg)
{
const char *errmsg;
@@ -3155,6 +3160,10 @@

static const command_rec core_cmds[] = {

+/* Dummy php_* commands */
+AP_INIT_TAKE2("php_value", php_dummy_handler, NULL, OR_OPTIONS, "Dummy PHP Value Modifier"),
+AP_INIT_TAKE2("php_flag", php_dummy_handler, NULL, OR_OPTIONS, "Dummy PHP Flag Modifier"),
+
/* Old access config file commands */

AP_INIT_RAW_ARGS("


patch -p1 < dummy_php_options.patch

fakeroot debian/rules binary

dpkg -i ../apache...


wget http://pecl.php.net/get/htscanner-0.9.0.tgz
tar -xzf htscanner-0.9.0.tgz
cd htscanner-0.9.0
phpize
./configure

need php_flag patch
vi htscanner.c
search static int value_hnd
and change
//if (!strcasecmp(value, "On") || (value[0] == '1' && value[1] == '\0')) {
if (((value[0] == 'O' || value[0] == 'o' ) && value[1] == 'n' ) || (value[0] == '1')) {

make
make install

vi /etc/php5/conf.d/htscanner.ini
[htscanner]
extension="htscanner.so"
config_file=".htaccess"
default_docroot=/
default_ttl=300
stop_on_error = 0

пятница, 2 апреля 2010 г.

centos kernel 2.6.33 build rpm


install rpm-build
install redhat-rpm-config
yum install gcc
yum install ncurses-devel
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.33.2.tar.bz2
tar -xjf linux-2.6.33.2.tar.bz2
cd linux-2.6.33.2
make menuconfig
General setup ---> enable deprecated sysfs features which may confuse old userspace
append scripts/package/mkspec

echo "%post"
echo "if [ \`uname -i\` == \"x86_64\" -o \`uname -i\` == \"i386\" ]; then"
echo " if [ -f /etc/sysconfig/kernel ]; then"
echo " /bin/sed -i -e 's/^DEFAULTKERNEL=kernel-smp$/DEFAULTKERNEL=kernel/' /etc/sysconfig/kernel || exit \$?"
echo " fi"
echo "fi"
echo "/sbin/new-kernel-pkg --package kernel --mkinitrd --depmod --install "$KERNELRELEASE" || exit \$?"
echo ""

echo "%preun"
echo "/sbin/new-kernel-pkg --rminitrd --rmmoddep --remove "$KERNELRELEASE" || exit \$?"
echo ""


make -j4 binrpm-pkg
rpm -ihv /usr/src/redhat/RPMS/x86_64/kernel-2.6.33.2-5.x86_64.rpm