Multiple DITs on OpenLDAP

March 17, 2013 in Debian, Linux


Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: file(http://svn.wp-plugins.org/devformatter/branches/langs/ldif.php) [function.file]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: implode() [function.implode]: Invalid arguments passed in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 100

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

昨天自己在EC2上架了一个slapd服务器。由于这个服务器需要处理两个RootDN(dc=freebear,dc=net和dc=moonclaw,dc=org),因此需要设定多DIT。
在Debian Squeeze之后,自带的slapd就已经都是cn=config形式了,网上看到的很多slapd.conf文件的配置方法不再可以直接拿来使用。具体的配置过程如下:

1. 执行 dpkg-reconfigure slapd 重新配置一下slapd。在这里,我们可以设定slapd的一个RootDN,以及对应的admin帐号和密码。设定完成后,这个slapd实例就可以立刻使用了
2. 编写 tls.ldif

 ldif |  copy code |? 
01
02
dn: cn=config
03
add: olcTLSCACertificateFile
04
olcTLSCACertificateFile: /etc/ssl/certs/cacert.pem
05
-
06
add: olcTLSCertificateKeyFile
07
olcTLSCertificateKeyFile: /etc/ssl/private/server-key.pem
08
-
09
add: olcTLSCertificateFile
10
olcTLSCertificateFile: /etc/ssl/certs/server-cert.pem
11

 bash |  copy code |? 
1
2
sudo ldapmodify -Y EXTERNAL H ldapi:/// -f tls.ldif
3

执行。这将开启 slapd 的 StartTLS 支持
3. 修改 /etc/default/slapd ,在 SLAPD_SERVICES 中添加 ldaps:///
这将开启slapd的SSL支持(端口636)
4. 重启slapd
5. dpkg-reconfigure 会将 slapd 的RootDN数据库保存在 /var/lib/ldap 下,我们需要创建
/var/lib/ldap/freebear.net
/var/lib/ldap/moonclaw.org
两个目录。其中 freebear.net 是我们在 dpkg-reconfigure 时配置的 RootDN ,因此需要将 /var/lib/ldap 下所有的文件都移动到 /var/lib/ldap/freebear.net 下。注意,这两个目录的所有者应当是 openldap:openldap
6. 重启slapd,此时尝试连接slapd,不应当出现任何错误或者不同
7. 编写 moonclaw-db.ldif 用于创建 moonclaw.org 域的数据库

 ldif |  copy code |? 
01
02
dn: olcDatabase=hdb,cn=config
03
objectClass: olcHdbConfig
04
olcDatabase: hdb
05
olcDbDirectory: /var/lib/ldap/moonclaw.org
06
olcSuffix: dc=moonclaw,dc=org
07
olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymous auth by dn="cn=admin,dc=moonclaw,dc=org" write by * none
08
olcAccess: {1}to dn.base="" by * read
09
olcAccess: {2}to * by self write by dn="cn=admin,dc=moonclaw,dc=org" write by * read
10
olcRootDN: cn=admin,dc=moonclaw,dc=org
11
olcRootPW:: XXXXXXXXXXXXXXXXXXXXXXX
12

其中 XXX 可以从已有的 /etc/ldap/slapd.d/cn=config/olcDatabase={1}hdb.ldif 文件中抄过来,这样新域的admin密码就和之前系统创建的域一样了

8. 编写 moonclaw-org.ldif 用于创建RootDN

 ldif |  copy code |? 
01
02
version: 1
03
04
dn: dc=moonclaw,dc=org
05
description: Moonclaw
06
objectClass: dcObject
07
objectClass: organization
08
objectClass: top
09
o: Moonclaw
10

9. 编写 moonclaw-admin.ldif 用于创建cn=admin,dc=moonclaw,dc=org

 ldif |  copy code |? 
01
02
version: 1
03
04
dn: cn=admin,dc=moonclaw,dc=org
05
objectClass: organizationalRole
06
objectClass: simpleSecurityObject
07
cn: admin
08
userPassword:: XXXXXXXXXXXXXXXXXXXXXXXXXX
09
description: LDAP administrator
10

密码部分和创建数据库的时候设置的RootDN一样就好了
10. 通过

 bash |  copy code |? 
1
2
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f xxxx.ldif
3

命令依次执行 moonclaw-db.ldif , moonclaw-org.ldif , moonclaw-admin.ldif
BTW: 其实可以把这三个文件放在一起变成一个文件的 = =!!
11.现在通过 Apache Directory Studio 或者类似工具连接LDAP服务器的时候,应当可以看到两个 RootDN ,即 dc=freebear,dc=net 和 dc=moonclaw,dc=org 。这两个 RootDN 的管理帐号是分开独立的

参考资料:
Chapter 6: OpenLDAP using OLC (cn=config)

Share

bundler在构建native extensions时指定include/lib路径的方法

February 17, 2013 in Debian, Linux


Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

Warning: fopen(/home/fblog_whitebear/whitebear.freebearblog.org/wp-content/plugins/devformatter/geshi/geshi/bash.php) [function.fopen]: failed to open stream: Permission denied in /home/moonclaw_www/moonclaw.org/wp-content/plugins/devformatter/devgeshi.php on line 103

前几天在 Dreamhost 上用 rvm 自己装了一个 ruby1.9 。在安装 GitLab 的时候,需要构建 charlock_holmes 的 native extension ,但是由于 Dreamhost 没有提供 libicu 的 dev 包,所以需要自己先编译一个 icu 。
编译完之后,在执行 bundle install 之前还需要设置一下才能够让 bundle 知道去哪儿找这个自己安装的 icu 。方法是:

 bash |  copy code |? 
1
bundle config build.charlock_holms --with-icu-dir=/home/xxxxx/libicu

Share

FreeBSD 9 架设 NFS Server

January 13, 2013 in FreeBSD, FreeBSD Server

好久没碰FreeBSD了……
今天需要在我的FreeBSD 9虚拟机和实体机(Win8)之间共享点文件。考虑到Win 8/2012已经支持NFS Client了,所以也没必要在FreeBSD上安装什么samba。在配置FreeBSD的NFS Server过程中,发现它和Linux的区别还真不小……
首先, NFS 是属于 base system 的,不需要安装,直接在 /etc/rc.conf 里写入 nfs_server_enable=”YES” 即可启用。同时,其 /etc/exports 文件默认不存在,需要自己建立。
另外, FreeBSD 的 exports 文件的配置语法与 Linux 完全不同。
在 Linux 下,我们可以这样写:
/home *(rw,no_root_squash)
FreeBSD 下会直接报语法错误。
正确的写法是:
/home -rw -alldirs -mapall=1001 -network=192.168.1 -mask 255.255.255.0
第一段指定了需要 export 的目录。这个目录可以有多个。 -rw 表示读写, -alldirs 表示任意一个子目录均可以被 mount ,这在 Linux 下是默认行为。 -mapall=UID 表示 mount 这个目录的所有操作都视为 UID 这个用户进行的。 -network 和 -mask 表示允许 mount 的计算机。注意, -network 不是 192.168.1.0 。
但这样写是没办法 mount 成功的, FreeBSD 日志里会写 Mount request Denied 。这是因为 FreeBSD 的 NFS 默认不允许 symbolic link 到非 export 目录,而 /home 其实是 symbolic link 到 /usr/home 的。所以只需要把 export 路径改为 /usr/home 即可。

Share