cabextract lha unzip
cabextractをつかえば キャビネットファイル(.cabまたは自己解凍形式の.exe)が解凍出来る
(はず)
$ cabextract hoge.exe $ cabextract -d hogedir hoge.exe。
うまく行かない場合はlhaやunzipも試す価値あり
$ lha -x hoge.exe $ unzip -l hoge.exe
古典的なnfsサーバの備忘録
5年ぶりぐらいにいぢった
サーバ:centos6.x 64bit
クライアント: ubuntu 12.04 32bit
として
- サーバ
[root@cent6-64-38 lpic]# cat /etc/exports /export/project 192.168.1.0/24(rw,sync,all_squash,anonuid=500,anongid=500)
500:500ってのはhirasawaのuid/gidデス
- クライアント
[hirasawa@ubuntu1204-20 HowToBuildServerCentOs]$ cat /etc/fstab | tail -1 192.168.1.38:/export/project /mnt/192.168.1.38 nfs rw,sync 0 0 [hirasawa@ubuntu1204-20 HowToBuildServerCentOs]$
インスコ(4) group user
[root@cent6-64-38 tmp]# ./create_user_ldif.sh ベースDN(例:dc=example,dc=com) : dc=hirasawa,dc=local ユーザー名(例:testuser) : testuser ユーザーID(例:1001) : 1001 グループID(例:1001) : 1001 ユーザーパスワード(例:pass) : pass Home Directory(/home/testuser) : dn: uid=testuser,ou=People,dc=hirasawa,dc=local uid: testuser cn: testuser objectClass: account objectClass: posixAccount objectClass: top objectClass: shadowAccount userPassword: {SSHA}UbmTqhAtPFBkDj1ipaLr5qozX6kYXhSf shadowLastChange: 15862 shadowMin: 0 shadowMax: 99999 shadowWarning: 7 loginShell: /bin/bash uidNumber: 1001 gidNumber: 1001 homeDirectory: [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# ls -ltr 合計 16 -rw-r--r--. 1 root root 973 1月 7 14:01 2014 base.ldif -rwxr-xr-x. 1 root root 329 1月 7 14:23 2014 create_group_idif.sh -rw-r--r--. 1 root root 111 1月 7 14:30 2014 group0001.ldif -rwxr-xr-x. 1 root root 800 1月 7 14:44 2014 create_user_ldif.sh [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# ./create_user_ldif.sh > user1001.ldif ベースDN(例:dc=example,dc=com) : dc=hirasawa,dc=local ユーザー名(例:testuser) : testuser ユーザーID(例:1001) : 1001 グループID(例:1001) : 1001 ユーザーパスワード(例:pass) : test Home Directory(/home/testuser) : /home/testuser [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# ls -ltr 合計 20 -rw-r--r--. 1 root root 973 1月 7 14:01 2014 base.ldif -rwxr-xr-x. 1 root root 329 1月 7 14:23 2014 create_group_idif.sh -rw-r--r--. 1 root root 111 1月 7 14:30 2014 group0001.ldif -rwxr-xr-x. 1 root root 800 1月 7 14:44 2014 create_user_ldif.sh -rw-r--r--. 1 root root 376 1月 7 14:47 2014 user1001.ldif [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# ldapadd -x -D 'cn=Manager,dc=hirasawa,dc=local' -W -f ./user1001.ldif Enter LDAP Password: adding new entry "uid=testuser,ou=People,dc=hirasawa,dc=local" [root@cent6-64-38 tmp]# [root@cent6-64-38 tmp]# ldapsearch -x -b 'dc=hirasawa,dc=local' 'uid=testuser' # extended LDIF # # LDAPv3 # base <dc=hirasawa,dc=local> with scope subtree # filter: uid=testuser # requesting: ALL # # testuser, People, hirasawa.local dn: uid=testuser,ou=People,dc=hirasawa,dc=local uid: testuser cn: testuser objectClass: account objectClass: posixAccount objectClass: top objectClass: shadowAccount shadowLastChange: 15862 shadowMin: 0 shadowMax: 99999 shadowWarning: 7 loginShell: /bin/bash uidNumber: 1001 gidNumber: 1001 homeDirectory: /home/testuser # search result search: 2 result: 0 Success # numResponses: 2 # numEntries: 1 [root@cent6-64-38 tmp]#
- -x Use simple authentication instead of SASL.
- -b searchbase
CentOS6 に open LDAPサーバをインスコ(2) ... basic.ldif
yum install openlda-clientsパッケージをいれないとうごかんよな
[root@cent6-64-38 tmp]# ldapadd -x -D "cn=Manager,dc=hirasawa,dc=local" -W -f /etc/openldap/tmp/base.ldif Enter LDAP Password: adding new entry "dc=hirasawa,dc=local" adding new entry "cn=Manager,dc=hirasawa,dc=local" adding new entry "ou=People,dc=hirasawa,dc=local" adding new entry "ou=Group,dc=hirasawa,dc=local"
- -D binddn
- -x Use simple authentication instead of SASL.
- -W Prompt for simple authentication. This is used instead of specifying the password on the command line.
- -f file
[root@cent6-64-38 tmp]# cat /etc/openldap/tmp/base.ldif #----------------------------------------------------------- # Domain #----------------------------------------------------------- dn: dc=hirasawa,dc=local objectClass: dcObject objectClass: organization dc: hirasawa o: hirasawa Inc. #----------------------------------------------------------- # Manager (管理者エントリ) #----------------------------------------------------------- dn: cn=Manager,dc=hirasawa,dc=local objectClass: organizationalRole cn: Manager description: Directory Manager #----------------------------------------------------------- # People (ユーザーエントリ) #----------------------------------------------------------- dn: ou=People,dc=hirasawa,dc=local objectClass: organizationalUnit ou: People #----------------------------------------------------------- # Group (グループエントリ) #----------------------------------------------------------- dn: ou=Group,dc=hirasawa,dc=local objectClass: organizationalUnit ou: Group 新しいメールが /var/spool/mail/root にあります [root@cent6-64-38 tmp]#
CentOS6 に open LDAPサーバをインスコ
めもめも
yum install openldap-servers
パッケージの中身をざっと覗いてみると
[root@cent6-64-38 ~]# rpm -ql openldap-servers | grep bin /usr/sbin/slapacl /usr/sbin/slapadd /usr/sbin/slapauth /usr/sbin/slapcat /usr/sbin/slapd /usr/sbin/slapdn /usr/sbin/slapindex /usr/sbin/slappasswd /usr/sbin/slapschema /usr/sbin/slaptest /usr/share/man/man5/slapo-pbind.5.gz [root@cent6-64-38 ~]#
オリジナルをバックアップした後、テンプレートファイル(DB_CONFIG,slapd.conf)をコピー
- slapd.confはopen LDAPの設定ファイル
- DB_CONFIGはBerkeley DBのバッファキャッシュの設定ファイル
[root@cent6-64-38 openldap-servers]# pwd /usr/share/openldap-servers [root@cent6-64-38 openldap-servers]# ls -ltr 合計 12 -rw-r--r--. 1 root root 921 4月 29 16:49 2013 DB_CONFIG.example -rw-r--r--. 1 root root 4635 4月 29 16:50 2013 slapd.conf.obsolete [root@cent6-64-38 openldap-servers]# ls -ltr /etc/openldap/ldap.conf ldap.conf ldap.conf.orig [root@cent6-64-38 openldap-servers]# cp -pr ./slapd.conf.obsolete /etc/openldap/slapd.conf [root@cent6-64-38 openldap-servers]# cp -pr DB_CONFIG.example /var/lib/ldap/DB_CONFIG [root@cent6-64-38 openldap-servers]#
slappasswdコマンドを使ってお好きなパスワードのハッシュをとり、slapd.confに貼り付ける
ちなみに slappasswdの-sのsはsecretのs
[root@cent6-64-38 openldap-servers]# slappasswd -s Yourpassword {SSHA}ou/m1Ykfg1ovoQvqMNeNrTu3leb+JVhJ [root@cent6-64-38 openldap]# cat /etc/openldap/slapd.conf | grep rootpw # rootpw secret # rootpw {crypt}ijFYNcSNctBYg rootpw {SSHA}ou/m1Ykfg1ovoQvqMNeNrTu3leb+JVhJ [root@cent6-64-38 openldap]#
[root@cent6-64-38 ~]# cat /etc/openldap/slapd.conf # # See slapd.conf(5) for details on configuration options. # This file should NOT be world readable. # #---------------------------------------------------------- # スキーマファイルの設定 #---------------------------------------------------------- include /etc/openldap/schema/corba.schema include /etc/openldap/schema/core.schema include /etc/openldap/schema/cosine.schema include /etc/openldap/schema/duaconf.schema include /etc/openldap/schema/dyngroup.schema include /etc/openldap/schema/inetorgperson.schema include /etc/openldap/schema/java.schema include /etc/openldap/schema/misc.schema include /etc/openldap/schema/nis.schema include /etc/openldap/schema/openldap.schema include /etc/openldap/schema/ppolicy.schema include /etc/openldap/schema/collective.schema #---------------------------------------------------------- # 接続プロトコル #---------------------------------------------------------- allow bind_v2 #---------------------------------------------------------- # 管理ファイル #---------------------------------------------------------- pidfile /var/run/openldap/slapd.pid argsfile /var/run/openldap/slapd.args #---------------------------------------------------------- # TLS の設定 #---------------------------------------------------------- #TLSCACertificatePath /etc/openldap/cacerts/cacert.pem TLSCertificateFile /etc/openldap/certs/server.csr TLSCertificateKeyFile /etc/openldap/certs/server.key #---------------------------------------------------------- # アクセスコントロールの設定 #---------------------------------------------------------- #--- userPassword に対するアクセス制限 # 自分自身は書き換え可能 # Manager は書き換え可能 # 匿名接続ならば、認証したときにこの属性が使える # その他のアクセスの際は何もできない access to attrs=userPassword by self write by dn="cn=Manager,dc=hirasawa,dc=local" write by anonymous auth by * none #--- その他の属性に対するアクセス制限 # 自分自身は書き換え可能 # Manager は書き換え可能 # その他のアクセスの際はread のみ可能 access to * by self write by dn="cn=Manager,dc=hirasawa,dc=local" write by * read #--- monitor データベースに対するアクセス制限 # Manager は read のみ可能 # その他のアクセスの際は何もできない # 確認コマンド ldapsearch -x -D "cn=Manager,dc=hirasawa,dc=local" -W + database monitor access to * by dn.exact="cn=Manager,dc=hirasawa,dc=local" read by * none #---------------------------------------------------------- # データーベースの設定 #---------------------------------------------------------- # database バックエンドデータベースの形式 # suffix ベースDN # checkpoint トランザクションログのチェックポイント設定 <kbyte> <min> # rootdn 管理者 # rootpw 管理者のパスワード(slappasswdコマンドで作成) # directory Database directory, Mode 700 recommended. database bdb suffix "dc=hirasawa,dc=local" checkpoint 1024 15 rootdn "cn=Manager,dc=hirasawa,dc=local" rootpw {SSHA}ou/m1Ykfg1ovoQvqMNeNrTu3leb+JVhJ directory /var/lib/ldap #---------------------------------------------------------- # indexの設定 # eq:等価性 pres:存在 sub:部分文字列 # indexの設定を変更したら、indexの再構築が必要 # slapindex -v -b "dc=hirasawa,dc=local" -f slapd.conf #---------------------------------------------------------- index objectClass eq,pres index ou,cn,mail,surname,givenname eq,pres,sub index uidNumber,gidNumber,loginShell eq,pres index uid,memberUid eq,pres,sub index nisMapName,nisMapEntry eq,pres,sub [root@cent6-64-38 ~]#
設定ファイルのテスト
- -uはドライラン
- -vはverbose
- -f slapd.conf の指定(ldap.confぢゃないのか?)
- -F conf dir
[root@cent6-64-38 certs]# slaptest -u -v -f /etc/openldap/ldap.conf config file testing succeeded [root@cent6-64-38 certs]# slaptest -f /etc/openldap/ldap.conf -F /etc/openldap/slapd.d/ config file testing succeeded [root@cent6-64-38 certs]#
/etc/の下はこんな感じになっています
[root@cent6-64-38 openldap]# pwd /etc/openldap [root@cent6-64-38 openldap]# find . . ./ldap.conf ./slapd.conf ./certs ./certs/key3.db ./certs/cert8.db ./certs/password ./certs/secmod.db ./slapd.d ./slapd.d/cn=config ./slapd.d/cn=config/olcDatabase={-1}frontend.ldif ./slapd.d/cn=config/olcDatabase={1}monitor.ldif ./slapd.d/cn=config/cn=schema ./slapd.d/cn=config/cn=schema/cn={11}collective.ldif ./slapd.d/cn=config/cn=schema/cn={10}ppolicy.ldif ./slapd.d/cn=config/cn=schema/cn={5}inetorgperson.ldif ./slapd.d/cn=config/cn=schema/cn={6}java.ldif ./slapd.d/cn=config/cn=schema/cn={4}dyngroup.ldif ./slapd.d/cn=config/cn=schema/cn={7}misc.ldif ./slapd.d/cn=config/cn=schema/cn={9}openldap.ldif ./slapd.d/cn=config/cn=schema/cn={8}nis.ldif ./slapd.d/cn=config/cn=schema/cn={0}corba.ldif ./slapd.d/cn=config/cn=schema/cn={3}duaconf.ldif ./slapd.d/cn=config/cn=schema/cn={1}core.ldif ./slapd.d/cn=config/cn=schema/cn={2}cosine.ldif ./slapd.d/cn=config/cn=schema.ldif ./slapd.d/cn=config/olcDatabase={0}config.ldif ./slapd.d/cn=config/olcDatabase={2}bdb.ldif ./slapd.d/cn=config.ldif ./ldap.conf.example ./schema ./schema/core.ldif ./schema/collective.schema ./schema/inetorgperson.ldif ./schema/nis.schema ./schema/nis.ldif ./schema/pmi.schema ./schema/duaconf.schema ./schema/ppolicy.schema ./schema/cosine.schema ./schema/samba.schema ./schema/java.schema ./schema/corba.schema ./schema/openldap.ldif ./schema/openldap.schema ./schema/core.schema ./schema/dyngroup.schema ./schema/dhcp.schema ./schema/misc.schema ./schema/inetorgperson.schema ./schema/cosine.ldif [root@cent6-64-38 openldap]#
hisotryを晒しておしまい
1003 slaptest -u -v -f /etc/openldap/slapd.conf 1012 slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d/ 1013 history
こちらを参考にさせていただきました
http://qiita.com/tags/openldap
http://qiita.com/mykysyk@github/items/25e6adbfdb313afaf339
http://www.upken.jp/kb/openldap.html
jarファイルの作り方
parentディレクトリから見て .. をパッケージのルートとして
[hirasawa@ubuntu1204-20 parent]$ pwd /home/hirasawa/step0/jar_test/parent
まずは親をつくってみる
[hirasawa@ubuntu1204-20 parent]$ cat Parent.java package parent; import parent.child.*; public class Parent { public static void main(String[] args) { Child child = new Child(); child.exec(); } } [hirasawa@ubuntu1204-20 parent]$
続いて子をつくってみる
[hirasawa@ubuntu1204-20 parent]$ cat ./child/Child.java package parent.child; public class Child { public void exec() { System.out.println("Go"); } } [hirasawa@ubuntu1204-20 parent]$
ここまでで準備は完了。
コンパイルして、実行してみる
[hirasawa@ubuntu1204-20 parent]$ javac -classpath .. Parent.java [hirasawa@ubuntu1204-20 parent]$ java -classpath .. parent.Parent Go [hirasawa@ubuntu1204-20 parent]$
よしよし。
それではjarファイルをつくってみるよ
[hirasawa@ubuntu1204-20 jar_test]$ pwd /home/hirasawa/step0/jar_test [hirasawa@ubuntu1204-20 jar_test]$ ls -ltr | grep parent drwxrwxr-x 3 hirasawa hirasawa 4096 1月 3 13:02 parent [hirasawa@ubuntu1204-20 jar_test]$ [hirasawa@ubuntu1204-20 jar_test]$ [hirasawa@ubuntu1204-20 jar_test]$ [hirasawa@ubuntu1204-20 jar_test]$ jar cvf parent.jar parent/ マニフェストが追加されました parent/を追加中です(入=0)(出=0)(0%格納されました) parent/Parent.javaを追加中です(入=152)(出=118)(22%収縮されました) parent/Parent.classを追加中です(入=330)(出=247)(25%収縮されました) parent/child/を追加中です(入=0)(出=0)(0%格納されました) parent/child/Child.classを追加中です(入=394)(出=281)(28%収縮されました) parent/child/Child.javaを追加中です(入=101)(出=92)(8%収縮されました) [hirasawa@ubuntu1204-20 jar_test]$ ls -ltr | grep jar -rw-rw-r-- 1 hirasawa hirasawa 1807 1月 3 13:15 parent.jar [hirasawa@ubuntu1204-20 jar_test]$ jar tvf parent.jar 0 Fri Jan 03 13:15:08 JST 2014 META-INF/ 68 Fri Jan 03 13:15:08 JST 2014 META-INF/MANIFEST.MF 0 Fri Jan 03 13:02:14 JST 2014 parent/ 152 Fri Jan 03 12:59:04 JST 2014 parent/Parent.java 330 Fri Jan 03 13:12:44 JST 2014 parent/Parent.class 0 Fri Jan 03 13:02:22 JST 2014 parent/child/ 394 Fri Jan 03 13:02:26 JST 2014 parent/child/Child.class 101 Fri Jan 03 13:02:22 JST 2014 parent/child/Child.java [hirasawa@ubuntu1204-20 jar_test]$
jarファイルを実行するには
java -cp parent.jar parent.Parent
ちなみは -cpは-classpathのことですね
参考
http://www.ytp.ne.jp/tech/java/sineruka/jarhowto.html
http://homepage1.nifty.com/algafield/java-programming-primer.html