2012年5月3日 星期四

CENTOS 使用 OpenLDAP PAM

參見

yum install openldap-servers openldap-clients  nss-pam-ldapd
** 單純 client 只要  openldap-clients  nss-pam-ldapd 就可以了


cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
vi /etc/openldap/ldap.conf
加入
URI ldap://127.0.0.1

BASE  o=XXX, c=XXX 

cp /usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

slappasswd

New password:
Re-enter new password:
{SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

vi /etc/openldap/slapd.conf

:%s/dc=my-domain/dc=mycompany/g
rootpw {SSHA}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

vi /root/root.ldif


rm -rf /etc/openldap/slapd.d/*

slapadd -n 2 -l /root/root.ldif

slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d

chown -R ldap:ldap /var/lib/ldap
chown -R ldap:ldap /etc/openldap/slapd.d

chkconfig slapd on
service slapd start

日後若變更 slapd.conf 內容, 則:

rm -rf /etc/openldap/slapd.d/*
slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d
chown -R ldap:ldap /etc/openldap/slapd.d
service slapd restart






***** CENTOS6 要求 LDAP 要 TLS
vim /etc/sysconfig/authconfi
FORCELEGACY=yes

***** geocs 無法使用中文

主因是schema中定義
attributetype ( 1.3.6.1.1.1.1.2 NAME 'gecos'
        DESC 'The GECOS field; the common name'
        EQUALITY caseIgnoreIA5Match
        SUBSTR caseIgnoreIA5SubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
只要改成
attributetype ( 1.3.6.1.1.1.1.2 NAME 'gecos'
        DESC 'The GECOS field; the common name'
        EQUALITY caseIgnoreMatch
        SUBSTR caseIgnoreSubstringsMatch
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
就可以了。
依照RFC 2252原本的gecos定義1.3.6.1.4.1.1466.115.121.1.26是IA5 String,改成1.3.6.1.4.1.1466.115.121.1.15的Directory String。
RFC中6.10. Directory String提到Directory String是使用UTF-8編碼的字串。但是6.15. IA5 String指出IA5 String只能使用字串本身的編碼,也就是ASCII 0-127。可參考維基上的IA5STRING。

Ref



*****
DB_KEYEXIST: Key/data pair already exists (-30995)
rm -rf /var/lib/ldap/*

warning - no DB_CONFIG file found in directory /var/lib/ldap: (2).
cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG




*****
(1) Geographic naming,例:suffix "o=組織名稱, c=國家名稱簡寫"
(2) Domain-based Naming,例:suffix "dc=組織名稱(簡稱), dc=網路域名"
RFC 2253 LDAPv3 Distinguished Names
dn: distinguished name
cn: common name
l: locality name
st: state or provinceName
o: organizationalName
ou: organizationalUnitName
c: countryName
street: streetAddress
dc: domain component
uid: user id

2012年4月30日 星期一

JNI字段描述符

參見




JavaNative Interface FieldDescriptors 



在JNI里,一个类的表示,不再是使用句点来表示,而使用斜杠来表示的,比如类 java.lang.String 表示为java/lang/String的样子。
一个数组int[],就需要表示为这样"[I"。如果多个数组double[][][]就需要表示为这样 "[[[D"。也就是说每一个方括号开始,就表示一个数组维数。多个方框后面,就是数组 的类型。



字段描述符
Java语言类型
Z
boolean
B
byte
C
char
S
short
I
int
J
long
F
float
D
double




如果以一个L开头的描述符,就是类描述符,它后紧跟着类的字符串,然后分号“;”结束。
比如"Ljava/lang/String;"就是表示类型String;
"[I"就是表示int[];
"[Ljava/lang/Object;"就是表示Object[]。

JNI方法描述符,主要就是在括号里放置参数,在括号后面放置返回类型,如下:
(参数描述符)返回类型
当一个函数不需要返回参数类型时,就使用”V”来表示。
比如"()Ljava/lang/String;"就是表示Stringf();
"(ILjava/lang/Class;)J"就是表示longf(int i, Class c);
"([B)V"就是表示voidString(byte[] bytes);

perl 單行程式


http://fecbob.pixnet.net/blog/post/38616105-perl%E4%B9%8B%E5%96%AE%E8%A1%8C%E5%91%BD%E4%BB%A4%E7%89%B9%E6%8A%80

參照

---base64
編碼: perl -MMIME::Base64 -e 'print encode_base64("XXX");'
解碼: perl -MMIME::Base64 -e 'print decode_base64("XXX");'

--- iconv
perl -e 'for $file (<*.sh>){$e=`iconv -f big5 -t utf8 $file > $file.utf8`;unlink $file;rename "$file.utf8",$file;}'

--單行替換
perl -p -i.bak -e 's#/usr/IBM/#/opt/IBM/#g' *.sh

2012年4月27日 星期五

python 相關



******** python web framework
Python Web frameworks, Part 1: Develop for the Web with Django and Python

perl 各種呼叫外部程式的方式

參見

system() 會另開一個 shell

`` 會使用當下的 shell

exec() 是把當下的shell直接改成執行指定的指令