2013年6月14日 星期五

開啟NetworkManager可自動註冊hostname進公司windows domain

CentOS 6預設安裝桌面時才會安裝Network Manger,只安裝純文字介面預設不會安裝NetworkManager但可在手動安裝。
用Webmin改hostname之後重開機hostname就可ping的到了

2013年6月6日 星期四

httpd 403 Forbidden

1. set Alias in httpd.conf
Alias /download /opt/download

2. add directory in httpd.conf

    AllowOverride All
    AcceptPathInfo On
    Options Indexes SymLinksIfOwnerMatch FollowSymLinks


http://server/download may return 403 cause selinux

3. set selinux setting
# chcon -tR httpd_sys_content_t /opt/download


Reference:
http://www.mikehomme.com/node/16

2013年5月14日 星期二

Linux SUID, SGID, Sticky bit

當SUID (set user id):chmod u+s file
  • 被設定在檔案上時,檔案的執行者會以檔案的擁有者的身分來執行
當SGID (set group id):chmod g+s file 或是 chmod g+s directory
  • 被設定在檔案上時,檔案的執行者會以檔案的擁有群組的身分來執行
  • 當設定在目錄上時,在此目錄下新建的檔案群組會被自動套用此目錄的群組 
Sticky bit:chmod +t directory
  • 當設定在目錄上時,以下的檔案只有該擁有者才能刪除或更名( /tmp )
http://en.wikipedia.org/wiki/Setuid
http://en.wikipedia.org/wiki/Sticky_bit

2013年5月13日 星期一

compile ipmitool 1.8.13

  1. remove freeipmi first
    # make uninstall (from freeipmi-1.4.9) don't know why
    # make clean 
  2. yum install ncurses-* readline-* openssl-*
  3. tar xvjf ipmitool-1.8.13.tar.bz2; cd ipmitool-1.8.13
  4. ./configure && make
  5. make install
  6. Enter freeipmi source code folder (need install libgcrypt-devel before compiler freeipmi)
    # ./configure
    # make
    # make install
Do build freeipmi
# yum install libgcrypt-devel

2013年5月7日 星期二

cntlm

讓Linux可透過Windows Server的Proxy (NTLM) 連到外面去
Cntlm
設定檔
/etc/cntlm.conf

restart the system and cntlm will run automatically
執行檔
/usr/sbin/cntlm

set http_proxy variable
# export http_proxy=http://127.0.0.1:3128

iptables 開通port 80

# iptables -I INPUT -p tcp ––dport 80 -j ACCEPT

2012年12月22日 星期六

Ascii hex (IEEE754) 轉成 flaot in python

import sys
form binascii import unhexlify
s = unhexlify(sys.argv[1]) + unhexlify(sys.argv[2]) \
+ unhexlify(sys.argv[3]) + unhexlify(sys.argv[4])
import struct
result = struct.unpack_from('f', s)
print result[0]