#ファイルとDatabaseの書き込みの差

 

#filesystem read→write

10000ファイル

1.24ms

0.00012ms/req

 

#filesystem append

10000ファイル

0.26852 ms
3.0E-5ms/req

 

#psql insert

1000 insert

0.52306 ms
0.00052ms/req

※ ×10レコードでも大差無い

 

#psql insert

10000 insert

4.29751 ms
0.00043ms/req

wget pure-ftpd-1.0.32

※1.0.42は、configure で、autoconfでエラー

※yum install (1.0.30)でも動作

 

cd pure-ftpd-1.0.32

./configure –with-pam –with-pgsql=/var/lib/pgsql

make

make install

cp xxx /etc/init.d/pure-ftpd-src

cp xxx /etc/pure-ftpd/pure-ftpd-src.conf

PGSQLConfigFile               /etc/pure-ftpd/pureftpd-pgsql.conf

PAMAuthentication             no

UnixAuthentication            no

CreateHomeDir               yes

 

/etc/pure-ftpd/pureftpd-pgsql.conf

諸々

SELECT “Password” FROM users WHERE “User”=’\L’

ダブルクォーテーションが必要

postreqsql のインストール

yum install postgresql-server

# pam_pgsql をbuildするため

yum install postgresql-client

yum install postgresql-contrib

yum install postgresql-devel

 

pam_pgsqlのインストール

cd /usr/local/src/

wget https://github.com/pam-pgsql/pam-pgsql/archive/release-0.7.3.2.zip

unzip release-0.7.3.2.zip

cd pam-pgsql-release-0.7.3.2/

./autogen.sh

./configure –libdir=/lib64

#pamのlibが入っている

make

make install

# /usr/local/lib/security/pam_pgsql.so

 

vsftpd on postgresql

# su – postgres
-bash-4.1$ createuser vsftpd
新しいロールをスーパーユーザとしますか? (y/n)y
パスワード:

-bash-4.1$ psql -U postgres
ユーザ postgres のパスワード:

postgres=# alter user vsftpd with password ‘vsftpd’;
ALTER ROLE

-bash-4.1$ createdb vsftpd -U vsftpd
パスワード:

-bash-4.1$ psql -U vsftpd
ユーザ vsftpd のパスワード:

vsftpd=# CREATE TABLE “accounts”(
vsftpd(# “i_id” SERIAL,
vsftpd(# “s_username” VARCHAR(30) NOT NULL,
vsftpd(# “s_password” VARCHAR(50),
vsftpd(# “b_expired” BOOLEAN DEFAULT false,
vsftpd(# CONSTRAINT “accounts_s_username_key” UNIQUE(“s_username”)
vsftpd(# );
NOTICE: CREATE TABLEはシリアル列”accounts.i_id”用に暗黙的なシーケンス”accounts_i_id_seq”を作成します。
NOTICE: CREATE TABLE / UNIQUEはテーブル”accounts”に暗黙的なインデックス”accounts_s_username_key”を作成します
CREATE TABLE

vsftpd=# insert into accounts(s_username, s_password) values(‘xxxx’,md5(‘yyyyy’));

 

vsftpd設定

vi /etc/vsftpd/vsftpd.conf

pam_service_name=vsftpd

anonymous_enable=NO

virtual_use_local_privs=YES
guest_enable=YES
local_root=/home/nilesflow/vsftpd_root/$USER
hide_ids=YES
guest_username=nilesflow
user_sub_token=$USER

chroot_local_user=YES

dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
log_ftp_protocol=YES

 

vsftpd pam設定

vi /etc/pam.d/vsftpd

auth required pam_pgsql.so config_file=/etc/pam_pgsql_vsftpd.conf
account required pam_pgsql.so config_file=/etc/pam_pgsql_vsftpd.conf

 

vsftpd pam postgresql 設定

vi /etc/pam_pgsql_vsftpd.conf

debug
pw_type = md5
connect = hostaddr=127.0.0.1 port=5432 dbname=xxxxx user=xxxxx password=xxxxx connect_timeout=15
auth_query = select s_password from accounts where s_username = %u
acct_query = select b_expired as acc_expired, 0 as acc_new_pwreq, (s_password ISNULL OR s_password = ”) as user_password from accounts where s_username = %u

 

ディレクトリ作成

mkdir /home/nilesflow/vsftpd_root/nilesflow

 

local_rootでディレクトリ自動作成できないのが。。。

 

ディレクトリ作成できないのは、直接 secutil.c をいじればできるが(以下適当)

retval = str_mkdir(p_ext_dir_str, 0775);
chmod(str_getbuf(p_ext_dir_str), 0775);
retval = chown(str_getbuf(p_ext_dir_str), 0, 0);

foreverをサービスとして起動

CentOS6.6、CentOS7.1

 

init.dの起動スクリプト+logrotate設定

https://github.com/nilesflow/centosetc

 

ログは、/var/log/foreverd.log

Node.jsログは、指定の場所に。

start の2重起動防止。

注意点は、foreverのHOMEディレクトリ。

HOME=xxxxxx

daemonの場合、ログインユーザでないため、/var/forever/.forever

ログインユーザの場合、/home/xxxxx/.forever

となる。

 

コマンドラインからの場合は、以下で参照可能。

HOME=xxxxxx forever list

※通常ユーザの場合、不要。

 

起動ユーザは、ログインユーザとdaemonに対応

forever-service はログ出力が制御できなかった。

initd-forever は、少し不足

 

以下のスクリプトを流用させてもらった

http://multix.jp/daemon-nodejs/

クライアント証明書にパスフレーズが含まれていると、

curlがエラーとなる

openssl pkcs12 -in client.pfx -out client.cert.pem -clcerts

curl https://xxxxx/ –cacert /etc/pki/CA/cacert.pem -E /etc/pki/CA/client/private/client.cert.pem
curl: (58) Unable to load client key -8178

curl https://xxxxx/ –cacert /etc/pki/CA/cacert.pem –cert /etc/pki/CA/client/certs/client.crt
curl: (58) Unable to load client key -8178.

curl https://xxxxx/ –cacert /etc/pki/CA/cacert.pem –cert /etc/pki/CA/client/certs/client.crt –key /etc/pki/CA/client/private/client.key
curl: (58) Unable to load client key -8178.

 

以下参照。

http://hogem.hatenablog.com/entry/2015/09/28/233000

http://stackoverflow.com/questions/20969241/curl-58-unable-to-load-client-key-8178

 

パスフレーズを外すと成功した

openssl rsa -in myclient.dev.furoom.net.key -out client.key.nopass
curl https://xxxxx/ –cacert /etc/pki/CA/cacert.pem –cert /etc/pki/CA/client/certs/client.crt –key /etc/pki/CA/client/private/client.key.nopass
→OK

 

wgetはパスフレーズ有りで成功した

wget -O – https://xxxxx/ –ca-certificate /etc/pki/CA/cacert.pem –certificate /etc/pki/CA/client/private/client.cert.pem

 

 

 

#2016/03/14

うまく認識されないみたいなのでexeは非公開に

 

Becky!でIMAP使用時に振り分けが動かないので、プラグインを作った。

リモートフォルダの受信箱に触ると、新着メールを振り分け

BkImapFilter(※非公開)

タスクが終わったら振り分けを想定する事が有る気がしたけど、
POPだと振り分けだし・・ThnderbirdだとIMAPでも振り分けされるし・・。

ソース

https://github.com/nilesflow/BkImapFilter

Visual Studio 2010

あと、IMAPで
・Becky!上でのフォルダの移動
・メール本文の自動受信
ができたらいいんだけど・・

2015/5/18追記

Windowsでインストーラを起動してもインストールされない現象

エクスプローラから「管理者として実行」で実行