Templateを多用するコードのインデント
Emacs 22.1になっても、Templateを多用するコードをcc-modeできれいに整形してくれません。
Boostのメーリングリストを検索していたら、Dave Abrahamsさんの.emacsが公開されていたので、流用しみました。もともとはhttp://www.boost-consulting.com/.emacsとして公開されていたのですが、現在消えてしまっています。Template周りのコードは、以下のとおりです。
;; ;; C++ template indentation code by Dave Abrahams ;; (defun my-c-leading-comma-p () (save-excursion (beginning-of-line) (c-forward-token-2 0 nil (c-point 'eol)) (eq (char-after) ?,))) (defun my-c-namespace-indent (langelem) "Used with c-set-offset, indents namespace scope elements 2 spaces from the namespace declaration iff the open brace sits on a line by itself." (save-excursion (if (progn (goto-char (cdr langelem)) (setq column (current-column)) (end-of-line) (while (and (search-backward "{" nil t) (assoc 'incomment (c-guess-basic-syntax)))) (skip-chars-backward " \t") (bolp)) 2))) (defun my-c-backward-template-prelude () "Back up over expressions that end with a template argument list. Examples include: typename foo<bar>::baz::mumble foo(bar, baz).template bing " (while (save-excursion ;; Inspect the previous token or balanced pair to ;; see whether to skip backwards over it (c-backward-syntactic-ws) (or ;; is it the end of a nested template argument list? (and (eq (char-before) ?>) (c-backward-token-2 1 t) ;; skips over balanced "<>" pairs (eq (char-after) ?<)) (and (c-backward-token-2 1 t) (looking-at "[A-Za-z_\\[(.]\\|::\\|->")))) (c-backward-token-2 1 t))) (defun my-c-namespace-open-indent (langelem) "Used with c-set-offset, indents namespace opening braces to the same indentation as the line on which the namespace declaration starts." (save-excursion (goto-char (cdr langelem)) (let ((column (current-column))) (beginning-of-line) (skip-chars-forward " \t") (- (current-column) column)))) (defun my-lineup-first-template-args (langelem) "Align lines beginning with the first template argument. To allow this function to be used in a list expression, nil is returned if we don't appear to be in a template argument list. Works with: template-args-cont." (let ((leading-comma (my-c-leading-comma-p))) (save-excursion (c-with-syntax-table c++-template-syntax-table (beginning-of-line) (backward-up-list 1) (if (eq (char-after) ?<) (progn (my-c-backward-template-prelude) (vector (+ (current-column) (if leading-comma (/ c-basic-offset 2) c-basic-offset))))))))) (defun my-lineup-more-template-args (langelem) "Line up template argument lines under the first argument, adjusting for leading commas. To allow this function to be used in a list expression, nil is returned if there's no template argument on the first line. Works with: template-args-cont." (let ((result (c-lineup-template-args langelem))) (if (not (eq result nil)) (if (my-c-leading-comma-p) (vector (- (aref result 0) (/ c-basic-offset 2))) result)))) (defun my-lineup-template-close (langelem) (save-excursion (c-with-syntax-table c++-template-syntax-table (beginning-of-line) (c-forward-syntactic-ws (c-point 'eol)) (if (and (eq (char-after) ?>) (progn (forward-char) (c-backward-token-2 1 t) (eq (char-after) ?<))) (progn (my-c-backward-template-prelude) (vector (current-column))))))) (defun my-c++-mode-hook () (setq c-default-style "bsd" c-backspace-function 'backward-delete-char c-basic-offset 4 c-tab-always-indent t) ;; Add 2 spaces of indentation when the open brace is on a line by itself (c-set-offset 'innamespace 'my-c-namespace-indent) ;; indent solo opening braces to the same indentation as the line on ;; which the namespace starts (c-set-offset 'namespace-open 'my-c-namespace-open-indent) ;; indent access labels public/private/protected by 1 space, as in 'M'. I ;; kinda like that. (c-set-offset 'access-label -3) ;; ;;fixup template indentation ;; (c-set-offset 'template-args-cont (quote (my-lineup-more-template-args my-lineup-template-close my-lineup-first-template-args +))) (set-variable 'c-backslash-max-column 200) (show-paren-mode t) (make-local-variable 'parens-require-spaces) (setq parens-require-spaces nil) )
研究室のSolarisサーバ設定覚書part 5
ZFS関係の設定をします。
ZFS poolの作成
zfspoolという名前のストレージプールの名前とします。マウントはしないようにします。
# /usr/sbin/zpool create -f zfspool c0t2d0s7 # /usr/sbin/zfs unmount zfspool # /usr/sbin/zfs set mountpoint=none zfspool
ZFSでswapパーティションの作成
Solaris ZFS 管理ガイドのままですが、次のようにして、8GBのswapパーティションを管理できます。ただし、ダンプデバイスにはできません。
# /usr/sbin/zfs create -V 8gb zfspool/swap # /usr/sbin/swap -a /dev/zvol/dsk/zfspool/swap
/optをZFSに移行
とりあえず、圧縮は行わないことにします。
# /usr/sbin/zfs create zfspool/opt # /usr/sbin/zfs set mountpoint=/export/opt zfspool/opt # /usr/bin/cd /opt # /usr/bin/find . -print -depth | /usr/bin/cpio -pdm /export/opt # /usr/sbin/zfs set mountpoint=legacy zfspool/opt # mv /opt /opt_orig # /usr/bin/echo 'zfspool/opt - /opt zfs - yes -' >> /etc/vfstab # /usr/bin/mkdir /opt # /usr/sbin/mount /opt (rm -r /opt_orig)
ZFSでユーザのホームディレクトリを作成
ユーザごとにファイルシステムを作成し、NFSで共有できるようにします。
# /usr/sbin/zfs create zfspool/home # /usr/sbin/zfs set mountpoint=/export/home zfspool/home # /usr/sbin/zfs set sharenfs=on zfspool/home # /usr/sbin/zfs share zfspool/home
次にユーザのファイルシステムを作成します。ユーザのファイルシステムには、10GBのquotaをかけ、毎日スナップショットをとり、.zfsのスナップショットを可視にして、ユーザ自身で復活できるようにします。
以下のようなスクリプトを書いて、ユーザごとに実行しました*1。
#!/bin/sh /usr/sbin/zfs create zfspool/home/$1 /usr/bin/chown $1:$1 /export/home/$1 /usr/bin/chmod g+s /export/home/$1 /usr/sbin/zfs set quota=10GB zfspool/home/$1 /usr/sbin/zfs set compression=on zfspool/home/$1 /usr/sbin/zfs set snapdir=visible zfspool/home/$1
*1:研究室注: 完成版は/net/lucifer/export/opt/sbin/useradd.scriptを見てください
研究室のSolarisサーバ設定覚書part 4
の続きになります。今回はクライアント側の設定その1です。
Solaris 10のLDAPクライアントとしての設定
前回までの準備で、LDAPのサーバ側の準備が整ったので、これからクライアント側の設定をします。
まず、SSL certificateの準備です*1。
# certutil -A -n "Example CA Certificate" -i /root/cacertdb/cacert.pem -a -t CT -d /var/ldap # chmod 444 /var/ldap/*.db
これで、ldapclientを動かす準備ができました。
# ldapclient init -a profileName=default -a proxyDN=cn=proxyagent,ou=profile,dc=example,dc=com -a proxyPassword=XXXXXX 192.168.0.1
この状態では、LDAPにない情報までLDAPを参照してしまったり、hosts検索でDNSを見てくれなかったりするので、/etc/nsswitch.confを編集します*2。
# cat /etc/nsswitch.conf (略) # the following two lines obviate the "+" entry in /etc/passwd and /etc/group. passwd: files ldap group: files ldap # consult /etc "files" only if ldap is down. hosts: ldap dns [NOTFOUND=return] files # Note that IPv4 addresses are searched for in all of the ipnodes databases # before searching the hosts databases. ipnodes: ldap dns [NOTFOUND=return] files networks: files protocols: files rpc: files ethers: files netmasks: files bootparams: files publickey: files netgroup: ldap automount: ldap [NOTFOUND=return] files (略)
次に、ログインのためにPAMエントリを修正します。とりあえず、sshとpasswdコマンドのみがきちんと動けばいいので、他の項目の変更は必要ないです*3。
# cat /etc/pam.conf (略) # # login service (explicit because of pam_dial_auth) # login auth requisite pam_authtok_get.so.1 login auth required pam_dhkeys.so.1 login auth required pam_unix_cred.so.1 login auth sufficient pam_unix_auth.so.1 login auth required pam_ldap.so.1 login auth required pam_dial_auth.so.1 (略) # # Default definitions for Authentication management # Used when service name is not explicitly mentioned for authentication # other auth requisite pam_authtok_get.so.1 other auth required pam_dhkeys.so.1 other auth required pam_unix_cred.so.1 other auth sufficient pam_unix_auth.so.1 other auth required pam_ldap.so.1 # # passwd command (explicit because of a different authentication module) # passwd auth binding pam_passwd_auth.so.1 server_policy passwd auth required pam_ldap.so.1
研究室のSolarisサーバ設定覚書part 3
の続きになります。LDAP関係の設定をします。多くがDSCCにログインしての作業です。
Solarisクライアントでは、ユーザ、グループ、オートマウント、ホスト情報をLDAPで管理することにします。
新規サーバの作成
次の設定でサーバを作成します。後にSolarisをクライアントにするのですが、SolarisのLDAPクライアントの制限からLDAPセキュアポートは636でないといけません*1。
項目 | 設定値 |
---|---|
ホスト | ldap.example.com |
LDAPポート | 389 |
LDAPセキュアポート | 636 |
インスタンスのパス | /var/opt/SUNWdsee/dsinsX |
Directory Manager DN | cn=Directory Manager |
パスワードなどは適当に設定します。
SSLの証明書の設定
ディレクトリサーバ->ldap:389->セキュリティ->証明書->その他の証明書の操作->インポートと選択して、前に作ったldap.p12ファイルをインポートします。
インポートが終了したら、サーバを再起動してください。再起動後、ディレクトリサーバ->ldap:389->セキュリティで、証明書を利用予定のものに変更、保存をクリック、サーバ再起動してください。
新規サフィックスの設定
ディレクトリサーバ->ldap:389->サフィックス->新規サフィックスと選択して、サフィックスを作成します。
項目 | 設定値 |
---|---|
dn | dc=example,dc=com |
レプリケート | しない |
サーバ選択 | そのまま |
設定 | デフォルト |
場所 | デフォルト |
データオプション | サフィックスをそのまま初期化しないでおく |
新規スキーマのインストール
Solaris 10のネームサービスをLDAPに対応させるには、RFC 2307bis対応が必要です。しかしながら、このRFCはもともとdraftであり、かなり昔にexpireされています。
DSEE 6.1にはRFC 2307bisは登録されていません。また、RFC 4876も必要です。そこで、この2つのschemaを登録する必要があります。
(なお、/usr/lib/ldap/idsconfigスクリプトは、このschema登録も自動で行っています。)
# ldapmodify -c -D "cn=Directory Manager" -f rfc2307bis.ldif -h ldap.example.com # ldapmodify -c -D "cn=Directory Manager" -f rfc4876.ldif -h ldap.example.com
rfc2307bis.ldifの内容は、以下の通りです。どうやらschemaが足りないようで、登録できないattributeTypesなどがありますが、-cにより先に進めます。
特に問題なく動きます。
# Full rfc2307 Draft Schema # 7/17/2007 Added Edirectory Containment rules for automount to be contained within automountMap # 7/17/2007 Added cn to (may) automount for greater flexibility with autofs # version: 1 dn: cn=schema changetype: modify add: attributetypes attributeTypes: ( 1.3.6.1.1.1.1.0 NAME 'uidNumber' DESC 'An integer uniquely identifying a user in an administrative domain' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.1 NAME 'gidNumber' DESC 'An integer uniquely identifying a group in an administrative domain' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.2 NAME 'gecos' DESC 'The GECOS field; the common name' EQUALITY caseIgnoreIA5Match SUBSTRINGS caseIgnoreIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.3 NAME 'homeDirectory' DESC 'The absolute path to the home directory' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.4 NAME 'loginShell' DESC 'The path to the login shell' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.5 NAME 'shadowLastChange' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.6 NAME 'shadowMin' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.7 NAME 'shadowMax' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.8 NAME 'shadowWarning' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.9 NAME 'shadowInactive' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.10 NAME 'shadowExpire' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.11 NAME 'shadowFlag' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.12 NAME 'memberUid' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributeTypes: ( 1.3.6.1.1.1.1.13 NAME 'memberNisNetgroup' EQUALITY caseExactIA5Match SUBSTRINGS caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.14 NAME 'nisNetgroupTriple' DESC 'Netgroup triple' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.15 NAME 'ipServicePort' DESC 'Service port number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.12 NAME 'memberUid' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributeTypes: ( 1.3.6.1.1.1.1.13 NAME 'memberNisNetgroup' EQUALITY caseExactIA5Match SUBSTRINGS caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.14 NAME 'nisNetgroupTriple' DESC 'Netgroup triple' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.15 NAME 'ipServicePort' DESC 'Service port number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.16 NAME 'ipServiceProtocol' DESC 'Service protocol name' SUP name X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.17 NAME 'ipProtocolNumber' DESC 'IP protocol number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.18 NAME 'oncRpcNumber' DESC 'ONC RPC number' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.19 NAME 'ipHostNumber' DESC 'IPv4 addresses as a dotted decimal omitting leading zeros or IPv6 addresses as defined in RFC2373' SUP name X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.20 NAME 'ipNetworkNumber' DESC 'IP network as a dotted decimal, eg. 192.168, omitting leading zeros' SUP name SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.21 NAME 'ipNetmaskNumber' DESC 'IP netmask as a dotted decimal, eg. 255.255.255.0, omitting leading zeros' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.2 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.22 NAME 'macAddress' DESC 'MAC address in maximal, colon separated hex notation, eg. 00:00:92:90:ee:e2' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.23 NAME 'bootParameter' DESC 'rpc.bootparamd parameter' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.24 NAME 'bootFile' DESC 'Boot image name' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.26 NAME 'nisMapName' DESC 'Name of a A generic NIS map' SUP name X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.27 NAME 'nisMapEntry' DESC 'A generic NIS entry' EQUALITY caseExactIA5Match SUBSTRINGS caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.28 NAME 'nisPublicKey' DESC 'NIS public key' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.29 NAME 'nisSecretKey' DESC 'NIS secret key' EQUALITY octetStringMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.40 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.30 NAME 'nisDomain' DESC 'NIS domain' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.31 NAME 'automountMapName' DESC 'automount Map Name' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.32 NAME 'automountKey' DESC 'Automount Key value' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) attributetypes: ( 1.3.6.1.1.1.1.33 NAME 'automountInformation' DESC 'Automount information' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE X-ORIGIN 'draft-howard-rfc2307bis' ) dn: cn=schema changetype: modify add: objectClasses objectClasses: ( 1.3.6.1.1.1.2.0 NAME 'posixAccount' SUP top AUXILIARY DESC 'Abstraction of an account with POSIX attributes' MUST ( cn $ uid $ uidNumber $ gidNumber $ homeDirectory ) MAY ( authPassword $ userPassword $ loginShell $ gecos $ description ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.1 NAME 'shadowAccount' SUP top AUXILIARY DESC 'Additional attributes for shadow passwords' MUST uid MAY ( authPassword $ userPassword $ description $ shadowLastChange $ shadowMin $ shadowMax $ shadowWarning $ shadowInactive $ shadowExpire $ shadowFlag ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.2 NAME 'posixGroup' SUP top AUXILIARY DESC 'Abstraction of a group of accounts' MUST gidNumber MAY ( authPassword $ userPassword $ memberUid $ description ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.3 NAME 'ipService' SUP top STRUCTURAL DESC 'Abstraction an Internet Protocol service. Maps an IP port and protocol (such as tcp or udp) to one or more names; the distinguished value of the cn attribute denotes the canonical name of the service' MUST ( cn $ ipServicePort $ ipServiceProtocol ) MAY description X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.4 NAME 'ipProtocol' SUP top STRUCTURAL DESC 'Abstraction of an IP protocol. Maps a protocol number to one or more names. The distinguished value of the cn attribute denotes the canonical name of the protocol' MUST ( cn $ ipProtocolNumber ) MAY description X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.5 NAME 'oncRpc' SUP top STRUCTURAL DESC 'Abstraction of an Open Network Computing (ONC) [RFC1057] Remote Procedure Call (RPC) binding. This class maps an ONC RPC number to a name. The distinguished value of the cn attribute denotes the canonical name of the RPC service' MUST ( cn $ oncRpcNumber ) MAY description X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.6 NAME 'ipHost' SUP top AUXILIARY DESC 'Abstraction of a host, an IP device. The distinguished value of the cn attribute denotes the canonical name of the host. Device SHOULD be used as a structural class' MUST ( cn $ ipHostNumber ) MAY ( authPassword $ userPassword $ l $ description $ manager ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' SUP top STRUCTURAL DESC 'Abstraction of a network. The distinguished value of the cn attribute denotes the canonical name of the network.' MUST ipNetworkNumber MAY ( cn $ ipNetmaskNumber $ l $ description $ manager ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.8 NAME 'nisNetgroup' SUP top STRUCTURAL DESC 'Abstraction of a netgroup. May refer to other netgroups' MUST cn MAY ( nisNetgroupTriple $ memberNisNetgroup $ description ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.9 NAME 'nisMap' SUP top STRUCTURAL DESC 'A generic abstraction of a NIS map' MUST nisMapName MAY description X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.10 NAME 'nisObject' SUP top STRUCTURAL DESC 'An entry in a NIS map' MUST ( cn $ nisMapEntry $ nisMapName ) MAY description X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.11 NAME 'ieee802Device' SUP top AUXILIARY DESC 'A device with a MAC address; device SHOULD be used as a structural class' MAY macAddress X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.12 NAME 'bootableDevice' SUP top AUXILIARY DESC 'A device with boot parameters; device SHOULD be used as a structural class' MAY ( bootFile $ bootParameter ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.14 NAME 'nisKeyObject' SUP top AUXILIARY DESC 'An object with a public and secret key' MUST ( cn $ nisPublicKey $ nisSecretKey ) MAY ( uidNumber $ description ) X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.15 NAME 'nisDomainObject' SUP top AUXILIARY DESC 'Associates a NIS domain with a naming context' MUST nisDomain X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.16 NAME 'automountMap' SUP top STRUCTURAL MUST ( automountMapName ) MAY description X-ORIGIN 'draft-howard-rfc2307bis' ) objectClasses: ( 1.3.6.1.1.1.2.17 NAME 'automount' SUP top STRUCTURAL DESC 'Automount information' MUST ( automountKey $ automountInformation ) MAY ( description $ cn ) X-ORIGIN 'draft-howard-rfc2307bis' X-NDS_CONTAINMENT ('organization' 'organizationalUnit' 'domain' 'locality' 'automountMap') ) # End of LDIF File
rfc4876.ldifファイルの中身も、以下の通りです。ldifファイル中のコメントのように、RFCのテキストを、ldifファイルとしてまとめなおしたものです。
# objectIdentifier DUAConfSchemaOID 1.3.6.1.4.1.11.1.3.1 # Updated to match RFC 4876 2007-2007 # http://www.rfc-editor.org/rfc/rfc4876.txt version: 1 dn: cn=schema changetype: modify add: attributetypes attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.0 NAME 'defaultServerList' DESC 'List of default servers' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.1 NAME 'defaultSearchBase' DESC 'Default base for searches' EQUALITY distinguishedNameMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.2 NAME 'preferredServerList' DESC 'List of preferred servers' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.3 NAME 'searchTimeLimit' DESC 'Maximum time an agent or service allows for a search to complete' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.4 NAME 'bindTimeLimit' DESC 'Maximum time an agent or service allows for a bind operation to complete' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.5 NAME 'followReferrals' DESC 'An agent or service does or should follow referrals' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.6 NAME 'authenticationMethod' DESC 'Identifies the types of authentication methods either used, required, or provided by a service or peer' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.7 NAME 'profileTTL' DESC 'Time to live, in seconds, before a profile is considered stale' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.9 NAME 'attributeMap' DESC 'Attribute mappings used, required, or supported by an agent or service' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.10 NAME 'credentialLevel' DESC 'Identifies type of credentials either used, required, or supported by an agent or service' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.11 NAME 'objectclassMap' DESC 'Object class mappings used, required, or supported by an agent or service' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.12 NAME 'defaultSearchScope' DESC 'Default scope used when performing a search' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.13 NAME 'serviceCredentialLevel' DESC 'Specifies the type of credentials either used, required, or supported by a specific service' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.14 NAME 'serviceSearchDescriptor' DESC 'Specifies search descriptors required, used, or supported by a particular service or agent' EQUALITY caseExactMatch SUBSTR caseExactSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.15 NAME 'serviceAuthenticationMethod' DESC 'Specifies types authentication methods either used, required, or supported by a particular service' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 ) attributeTypes: ( 1.3.6.1.4.1.11.1.3.1.1.16 NAME 'dereferenceAliases' DESC 'Specifies if a service or agent either requires, supports, or uses dereferencing of aliases.' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE ) dn: cn=schema changetype: modify objectClasses: ( 1.3.6.1.4.1.11.1.3.1.2.5 NAME 'DUAConfigProfile' SUP top STRUCTURAL DESC 'Abstraction of a base configuration for a DUA' MUST ( cn ) MAY ( defaultServerList $ preferredServerList $ defaultSearchBase $ defaultSearchScope $ searchTimeLimit $ bindTimeLimit $ credentialLevel $ authenticationMethod $ followReferrals $ dereferenceAliases $ serviceSearchDescriptor $ serviceCredentialLevel $ serviceAuthenticationMethod $ objectclassMap $ attributeMap $ profileTTL ) ) # end of file for http://www.rfc-editor.org/rfc/rfc4876.txt schema
LDAPディレクトリ構造の作成
次に、LDAPのディレクトリ構造を作成します。proxyagentに必要なACIもここで設定します。
# ldapmodify -a -c -D "cn=Directory Manager" -f directorysetup.ldif -h ldap.example.com
directorysetup.ldifの中身は、次のようなものを用います。注意点としては、aciの書式は間違っておらず、DSEEはこれできちんと動作するのですが、あとでDSCC上から設定変更をしようとすると、改行が含まれているせいで、再登録できません。その際は、DSEEのエディタで、aciが1行になるようにしてください。
ersion: 1 dn: dc=example,dc=com aci: (target = "ldap:///dc=example,dc=com") (targetscope = subtree) (targetattr = "cn||uid||uidNumber||gidNumber||homeDirectory||shadowLastChange||shadowMin||shadowMax||shadowWarning||shadowInactive||shadowExpire||shadowFlag||memberUid") (version 3.0; acl "Deny Write access from Self for Naming Services"; deny (write) (userdn = "ldap:///self");) aci: (target = "ldap:///dc=example,dc=com") (targetscope = subtree) (targetattr != "userPassword") (version 3.0; acl "Allow Read,Search,Compare access from Anyone"; allow (read, search, compare) (userdn = "ldap:///anyone");) aci: (target = "ldap:///dc=example,dc=com") (targetscope = subtree) (targetattr = "*") (version 3.0; acl "Allow Write access from Proxyagents"; allow (write) (userdn = "ldap:///cn=proxyagent,ou=Profile,dc=example,dc=com");) objectClass: top objectClass: domain objectclass: nisDomainObject dc: example nisdomain: example.com dn: ou=People,dc=example,dc=com objectClass: top objectClass: organizationalUnit ou: People dn: ou=Groups,dc=example,dc=com objectClass: top objectClass: organizationalUnit ou: Groups dn: ou=Hosts,dc=example,dc=com objectclass: top objectclass: organizationalUnit ou: Hosts dn: ou=Profile,dc=example,dc=com objectclass: top objectclass: organizationalUnit ou: Profile dn: automountMapName=auto_master,dc=example,dc=com objectclass: top objectclass: automountMap automountmapname: auto_master dn: automountKey=/home,automountMapName=auto_master,dc=example,dc=com objectclass: top objectclass: automount automountinformation: auto_home -nobrowse automountkey: /home dn: automountMapName=auto_home,dc=example,dc=com objectclass: top objectclass: automountMap automountmapname: auto_home dn: cn=proxyagent,ou=Profile,dc=example,dc=com objectClass: top objectClass: person sn: proxyagent cn: proxyagent userPassword: {crypt}dWdK5RanhBZYM dn: cn=default,ou=Profile,dc=example,dc=com objectclass: top objectclass: DUAConfigProfile authenticationmethod: tls:simple bindtimelimit: 10 cn: ogatalab credentiallevel: proxy defaultsearchbase: dc=example,dc=com defaultsearchscope: one defaultserverlist: 192.168.0.1 followreferrals: TRUE profilettl: 43200 searchtimelimit: 30 servicesearchdescriptor: group:ou=Groups,dc=example,dc=com?one servicesearchdescriptor: passwd:ou=People,dc=example,dc=com?one serviceSearchDescriptor: shadow:ou=People,dc=example,dc=com?one
Sun Java System Identity Managerのインストール
SunのサイトからIDM_7_1_0.zipとIDM_7-1_L10n_ja.zipをダウンロードします。
# mkdir /root/java_es-5_idm # cd /root/java_es-5_idm # unzip /tmp/IDM_7_1_0.zip # unzip /tmp/IDM_7-1_L10n_ja.zip # sh installer
IDM_7_1_0.zipはカレントディレクトリにファイルを展開してしまうので、注意しましょう。なお、/opt/SUNWidmにインストールすることにします。Setupは後で手動で実行します。
次にL10nのデータをコピーします。日本語以外が必要なら、同様にコピーします。
# cp /root/java_es-5_idm/IDM_7-1_L10n_ja/idm_l10n_ja_JP.jar /opt/SUNWidm/WEB-INF/lib/
Application ServerにDeployするためのwarファイルを作ります。
# cd /opt/SUNWidm/ # jar cvf ../idm.war *
Sun Java System Access Manager
研究室のサーバでは、結局Access Managerは利用しないことになったのですが、調べた内容についてメモを残しておきます。
Sun Java System Access Managerの設定
まず、SolarisをLDAP clientにするために必要なDUAConfigProfileを準備します。2007年5月にRFC 4876になったみたいです。DUA Config ProfileからDUAConfigProfile.schema.ldif]をダウンロードして、サーバにインポートします。なお、上記ファイルの下のほうにスペースだけの行があるので、適当に編集してください*1。
# ldapmodify -D "cn=Directory Manager" -f DUAConfigProfile.schema.ldif
Access Managerでのアカウントを、UNIXアカウントとして使うためにはいくつかの設定の変更が必要です。
http://www.c.csce.kyushu-u.ac.jp/kb/wiki/index.php?cmd=read&page=%A5%BD%A5%D5%A5%C8%A5%A6%A5%A8%A5%A2%2FSolaris%2FOpenLDAP%A5%AF%A5%E9%A5%A4%A5%A2%A5%F3%A5%C8が参考になります。
研究室のSolarisサーバ設定覚書part 2
d:id:rigarash:20070807の続きです。
SSL! SSL!
TLSでの運用のために、CAを作らなければなりません。
OpenSSL―暗号・PKI・SSL/TLSライブラリの詳細―の3.3に基づいて作成します。
まず、CAのためのディレクトリ構造を作り、適当な/root/cacertdb/openssl.cnfを作成します*1。
# mkdir -p /root/cacertdb/certs # mkdir -p /root/cacertdb/private # chmod 700 /root/cacertdb/private # echo 01 > /root/cacertdb/serial # touch /root/cacertdb/index.txt # OPENSSL_CONF=/root/cacertdb/openssl.cnf; export OPENSSL_CONF
次に、自己署名ルート証明書(オレオレ証明書)の作成をします。
# cd /root/cacertdb # openssl req -x509 -newkey rsa:2048 -days 365 -out cacert.pem -outform PEM
さて、CSR(Client Signing Request; 証明書要求)の生成ですが、DSCCからでもできるのですが、ここでは、OpenSSLの練習もかねて、OpenSSLを用いて行いました。
流れとしては、
- CSR(証明書要求)生成
- 証明書発行
- pkcs12形式への変更
となります。
# unset OPENSSL_CONF # mkdir -p /root/csrs/ldap # cd /root/csrs/ldap # openssl req -newkey rsa:2048 -keyout ldap_key.pem -keyform PEM -out ldap_req.pem -outform PEM
ここまででCSR(証明書要求)の生成です。CAの情報は不要なので、$OPENSSL_CONFをunsetしてます。
# OPENSSL_CONF=/root/cacertdb/openssl.cnf; export OPENSSL_CONF # openssl ca -in ldap_req.pem -notext -out ldap.pem # openssl pkcs12 -export -in ldap.pem -inkey ldap_key.pem -certfile /root/cacertdb/cacert.pem -name "LDAP certificate" -out ldap.p12
CAの情報をもう一度読みこんで、署名して、PKCS#12形式に変更します。
あとは、ldap.p12をサーバ証明書、cacert.pemをCA証明書としてインポートすればよいことになります。(DSCCからインポートしても大丈夫です)
# /opt/SUNWdsee/ds6/bin/dsadm import-cert /var/opt/SUNWdsee/dsins1 /root/csrs/ldap/ldap.p12
あとは、DSCCからだいたいのことはできます。
d:id:rigarash:20070813に続きます。
*1:内部向け: star:/home/dataにバックアップあり