2011-01-01から1年間の記事一覧

現在開いているファイルの関数一覧

「:!コマンド」とするとvimからコマンドが打てるのでfunctionをgrep(-nで行も表示) :!grep -n function %%と打つと、現在開いているファイルパスに展開されるので以下のようになる :!grep -n function /var/www/.../actions/actions.class.php 18: public …

sfFormでvalidateエラーを洗い出す

isValid()が偽になった時、などにtemplateにて getErrorSchema() as $key => $err) { echo $key.'='.$err.'<br />'; } ?> ↓↓↓ //name=入力してください。 //email=入力してください。 //password=入力してください。 //password_confirmation=入力してください。 /…

最後にログインした時間を確認

特定のユーザが見たい場合は以下 $ lastlog | grep ユーザ名例)ユーザhogeの最終ログイン時刻 $ lastlog | grep hoge hoge pts/1 xxx.xxx.xxx.xxx 月 6月 20 22:39:33 +0900 2011

procmailでフィルタリング

例)ユーザhogeに対し、件名にSPAMを含んでいたらspam@example.comへ転送あらかじめ.forwardに以下を設定した後、.procmailrcにレシピを書きます ~/.forward "|IFS=' ' && exec /usr/bin/procmail -f- || exit 75 #hoge"~/.procmailrc :0 * ^Subject:.*SPAM.…

フィンガープリント確認

# ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub 2048 88:e6:**:91:53:**:a7:04:**:3f:64:69:**:89:**:18 /etc/ssh/ssh_host_rsa_key.pubあらかじめフィンガープリントを入手しておけば、初回接続時に表示される「RSA key fingerprint is ...」と照合する…

mydestinationとvirtual設定時の送信先

例)サブドメイン(***@staging.example.com)を切った場合でメール配信検証 main.cf mydomain = example.com mydestination = $mydomain, staging.$mydomainローカル配送を行なうドメインに追加すれば/etc/aliasesにそって配信される/etc/aliases test: tes…

行指定でヤンク、削除

vim

例)4行目から24行目までをヤンク :4,24y「Enter」例)2行目から5行目までを削除 :2,5d「Enter」

ハードウェアの性能評価

読み込み速度を計測 # hdparm -tT /dev/sda1 /dev/sda1: Timing cached reads: 1892 MB in 2.00 seconds = 945.29 MB/sec Timing buffered disk reads: 100 MB in 1.71 seconds = 58.65 MB/sec -t: バッファキャッシュを使わず読み込み速度を計測 -T: バッフ…

sf test 結果をカラー表示

new lime_test(null, array('force_colors'=>true))を追加 //$browser = new sfTestFunctional(new sfBrowser()); $browser = new sfTestFunctional(new sfBrowser(), new lime_test(null, array('force_colors'=>true)));$ php hogeActionsTest.php # get /…

.forward転送の拡張

/home/ に.forwardファイルを置くとユーザ宛のメールの転送設定ができますが、.forward+xxxとすると、+xxx@example.comのような拡張アドレスで個別に振り分ける事も出来ます。例)user+hoge@example.comへメール /home/user/.forward+hoge で転送処理例)use…

真偽値をecho

[user@xxx ~]$ echo $((1 > 2)) 0 [user@xxx ~]$ echo $((1 < 2)) 1

svn upで.mineが消える

コンフリクトを起こしたファイルを削除し、再度svn up ⇒ ローカル変更追加の流れで対処しようとしたら、.mineがなくなっていた。。。 $ ll $ -rw-rw-r-- ... conflict.txt.r1243 $ -rw-rw-r-- ... conflict.txt.r1245 $ -rw-rw-r-- ... conflict.txt.mine $ …

yamlの{}と[]の違い

all: hoge: type-a: { hoge: 123, fuga: 456 } type-b: [ hoge: 123, fuga: 456 ]Array ( [type-a] => Array ( [hoge] => 123 [fuga] => 456 ) ) Array ( [type-b] => Array ( [0] => Array ( [hoge] => 123 ) [1] => Array ( [fuga] => 456 ) ) )

メールのサブドメイン対応

例)@example.com と同様に @staging.example.comでもメールを受け付けるまずはMXレコードをセットしておく staging.example.com. 147 IN MX 10 mail.example.com./etc/postfix/main.cf にて mydomain = example.com mydestination = $myhostname, localhost…

デフォルトでエスケープしている場合のタグ除去

タグを除去して出力したい、と思いpreg_replace()であれこれやろうと考えたが、strip_tags()という便利な関数があった。しかし、templateで strip_tags($class->getHoge());と、やってもタグが消えない。。。。こうやったらOKでした↓↓↓ strip_tags($class->g…

nmapを使ってみた

まずはインストール [root@xxx:~]# yum install nmap[root@xxx:~]# nmap example.com Starting Nmap 4.11 ( http://www.insecure.org/nmap/ ) at 2011-05-17 23:10 JST Interesting ports on xxx.xxx.xxx.xxx.example.com (xxx.xxx.xxx.xxx): Not shown: 167…

ドットコマンドと直接スクリプトを実行した時の違い

直接実行した場合、別シェルが呼び出されますが、ドットコマンドでは実行したシェル(カレントシェル)から呼び出されます例)test.sh hoge=123 echo $hoge直接実行 [user@system work]$ ./test.sh 123 [user@system work]$ echo $hoge →シェル変数の設定値…

ssh_exchange_identification: Connection closed by remote host

ssh接続できなかった場合の対処 $ ssh xxx.xxx.xxx.xxx ssh_exchange_identification: Connection closed by remote host接続先で禁止されているっぽいので、接続先サーバの設定を修正/etc/hosts.allow でssh許可 sshd: xxx.xxx.xxx.xxx ←接続しに行く側のIP…

ifconfigでeth0が表示されない

/etc/sysconfig/network-scripts/ifcfg-eth0 にて ONBOOTがnoになっていたのでyesに変更 #ONBOOT=no ONBOOT=yes BOOTPROTO=static DEVICE=eth0 IPADDR=xxx.xxx.xxx.xxx NETMASK=255.255.255.0 IPV6ADDR= IPV6INIT=yesnetworkを再起動 service network restar…

client denied by server configuration:

なぜか::1からアクセスがあってエラーが出ていた。 error.log [Tue May 10 21:20:33 2011] [error] [client ::1] client denied by server configuration: /var/www/default/html/*access.log ::1 - - [10/May/2011:21:52:26 +0900] "OPTIONS * HTTP/1.0" 20…

virtualに無いユーザの転送

>example.comがメールサーバのvirtual_alias_domainsに設定されているとして、virtualに無いユーザ「test」で送信した場合、/etc/aliasesの「test」ユーザへ転送されます。virtual user@example.com aaa #test@example.com bbbtest@example.comでメール送信 …

Relay access denied (in reply to RCPT TO command)

メールサーバ exapmle.netにvirtualでtest@example.comを追加したが「Undelivered Mail Returned to Sender」メールが戻ってきたケース <test@example.com>: host mail.exapmle.net[xxx.xxx.xxx.xxx] said: 554 5.7.1 <test@example.com>: Relay access denied (in reply to RCPT TO command)バー</test@example.com></test@example.com>…

hostsファイルの場所

WindowsXPにて、hostsファイルを修正したけれど反映されない。。。こちらではなく、、、 C:\WINDOWS\I386\HOSTSこちらでした。 C:\WINDOWS\system32\drivers\etc\hosts

SSL証明書が正しく設定されているか確認

curlコマンドで簡単に確認できます。 たまたまブラウザで見れてても、curl使うようなAPI叩く時にエラー出て、実はおかしかったとか...そんな事にならないように。中間証明書がおかしいとこんな感じ↓↓↓ $ curl https://example.com/ url: (60) SSL certificat…

memcachedのキャッシュ内容確認

memcached-toolのdumpで確認できる [root@rp1]# memcached-tool 10.0.0.5:11211 dump Dumping memcache contents Number of buckets: 5 Number of items : 14 Dumping bucket 10 - 1 total items add 235452e7f4463926276bca314f6704f4:177cb5b9dc3d4675edf8…

特定のユーザに絞ってユーザ変更

例)hogeユーザを全てfugaグループのfugaユーザに変更 find ./ -user hoge -print0 | xargs -0 chown fuga:fugaただし、シンボリックリンクは変更できませんでした ...と思ったら「-h」オプションをつければシンボリックリンクも変更できました find ./ -use…

踏み台サーバを利用して直接アクセス

開発サーバ等、とあるサーバから別サーバへの直接アクセスが許可されていない場合、通常ならば、まず踏み台サーバに接続し、2段階で接続する必要があります 開発サーバより ssh example.comexample.comにて ssh web1.example.localそんな手間が、.ssh/config…

名前解決せずにIP一致で接続

user情報にないホスト名をIP一致のみで許可する方法下のようなuser設定の場合、例えばホストxxx.local(IPは「10.100.200.1」とする)で接続しようとした場合、IPとしては問題ないが、xxx.localがhostに登録されていないのではじかれる mysql> select host,use…

リバースプロキシ経由のアクセス元IPを直す

リバース経由したWebサーバのaccess.logが全てプロキシのIPになってしまっていたので、Webサーバのrpaf.confのRPAFproxy_ipsのIPを修正 これで本来のリクエスト元IPがわかるようになる LoadModule rpaf_module modules/mod_rpaf.so RPAFenable on #RPAFproxy…

パスワードオプションの設定

「-p」とパスワードの間にスペースを入れるとダメらしい [user@web1.aaa ~]$ mysql -uadmin -h db1m -p 'パスワード'Enter password: ERROR 1045 (28000): Access denied for user 'admin'@'xxx.xxx.xxx.xxx' (using password: YES)間を詰めると入れました […