end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

SMB::Client for perl で接続し、file一覧をtraverse作成

↓こう書くみたい

#!/usr/local/bin/perl
use strict;
use warnings;
use Encode;
use File::Basename;
use File::stat;
use SMB::Client;
use Data::Dumper;

my $CONF =
    {nas_smb=>
     {share_uri=>'//10.100.21.???/nas',
      options=> {
                 username => 'ないしょ',
                 password => 'ないしょ',
                 quiet    => 0,
                 verbose  => 0,
                 log_level => SMB::LOG_LEVEL_INFO}},
    };


main( @ARGV );

sub main {
    my ($parent_path ) = @_;

    if(not defined($parent_path) or length($parent_path)==0){
        $parent_path = '';
    }
    
    # NAS接続client初期化
    my $smb_tree = init_nas_smb();
    unless($smb_tree){
        my $tmp_msg = "fail init_nas_smb()";
        die "$tmp_msg $!";
    }

    traverse_smb_tree($smb_tree, $parent_path);
}

sub traverse_smb_tree {
    my ($smb_tree, $parent_path ) = @_;

    my $find_path = join('/',$parent_path,'*');
    my @file_or_dirs = $smb_tree->find( $find_path );

    for my $file_or_dir ( @file_or_dirs ){
        
        next if( $file_or_dir->{name} eq '.' or
                 $file_or_dir->{name} eq '..');

        my $full_path = join('/', $parent_path, $file_or_dir->{name});

    # dir or fileの判定をいまいち、理解していません
        if( $file_or_dir->{attributes} == 16 ){
#        if( $file_or_dir->{allocation_size} == 0 ){
            print "DIR\t$full_path\n";
            traverse_smb_tree($smb_tree,$full_path);
            next;
        }

        my $disp_cols_str =
            join("\t",
                 "FILE",
                 $full_path,
                 $file_or_dir->size_string,
                 $file_or_dir->mtime_string);
        print $disp_cols_str,"\n";

    }
}

sub init_nas_smb {

    my $client = SMB::Client->new($CONF->{nas_smb}->{share_uri},
                                  %{$CONF->{nas_smb}->{options}});
    my $tree = $client->connect_tree;
    unless( $tree ){
        my $msg = "fail SMB::Client->connect_tree $CONF->{nas_smb}->{share_uri}";
        die "$msg $!";
    }
    return $tree;
}

1;

(再)リバースプロキシで認証したREMOTE_USERを受け側のapacheに渡す

https://qiita.com/end0tknr/items/c411cd91caaf43147ac4

↑こちらのurlを再編集。

前回は、リバースプロキシ側で認証した REMOTE_USER 情報を、 バックエンドのサーバに HTTP_X_FORWARDED_USER 情報とて渡しました。 今回は、バックエンドのサーバにも REMOTE_USER 情報として渡します。

構成

上段=前回、下段=今回で、【】の部分が変更箇所

┌Apache(REVERSE PROXY) ──┐  ┌Apache(APP SERVER)──────┐
│AuthType BASIC            ├→│AuthType NONE                 │
│【env param:REMOTE_USER】 │  │【env param:X-Forwarded-User】│
└─────────────┘  └───────────────┘
┌Apache(REVERSE PROXY) ──┐  ┌Apache(APP SERVER)──────┐
│AuthType BASIC            ├→│AuthType NONE                 │
│【env param:REMOTE_USER】 │  │【env param:REMOTE_USER】     │
└─────────────┘  └───────────────┘

apache httpd.confの編集(抜粋)

# この辺りのmoduleは必要
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule headers_module modules/mod_headers.so
LoadModule rewrite_module modules/mod_rewrite.so

# frontのreverse proxyにおけるbasic認証
<LocationMatch "/reverse_from/">
 AuthType Basic
 AuthName "Member Only"
 AuthUserFile /home/end0tknr/dev/htpasswd
 require valid-user
 ErrorDocument 401 /error/authen-error.html
</LocationMatch>

# frontのreverse proxy設定

# reverse proxyなので、off (通常のproxyならon)
ProxyRequests Off
<Location "/reverse_from/">
 ProxyPass         http://192.168.244.101:8080/reverse_to/
 ProxyPassReverse  http://192.168.244.101:8080/reverse_to/

 # remote user情報と X-Forwarded-User として、http headerに追加
 RewriteEngine On
 RewriteCond %{LA-U:REMOTE_USER} (.+)
 RewriteRule . - [E=RU:%1,NS]
 RequestHeader add X-Forwarded-User %{RU}e
</Location>


# backendのapp server設定
<Directory "/home/end0tknr/dev/reverse_to">
  Order allow,deny
  Allow from all

  # http headerのX-Forwarded-Userを環境変数=remote userに戻す
  RewriteEngine On
  RewriteCond %{REMOTE_USER} $^
  RewriteCond %{HTTP:X-Forwarded-User} (.+) [NC]
  RewriteRule . - [E=REMOTE_USER:%1,NS]

  # 変換結果をperl cgiで確認する為、CGI有効化
  <Files "*.pl">
    Options ExecCGI
    # この部分に「+」付きで、+FollowSymLinks を指定する必要があるみたい...
    Options +FollowSymLinks
    AddHandler cgi-script .pl
  </Files>
 </Directory>
Alias /reverse_to     /home/end0tknr/dev/reverse_to

apache の起動と確認

$ cd /home/end0tknr/local/apache24
$ ./bin/apachectl -f conf/httpd_reverse_proxy.conf 

と起動し、「ないしょIP:8080/reverse_from/index.pl 」へアクセスすると、 次のように表示されます。

CONTEXT_DOCUMENT_ROOT = /home/end0tknr/dev/reverse_to
CONTEXT_PREFIX = /reverse_to
DOCUMENT_ROOT = /home/end0tknr/local/apache24/htdocs
GATEWAY_INTERFACE = CGI/1.1
HTTP_ACCEPT = text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT_LANGUAGE = ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7
HTTP_CACHE_CONTROL = max-age=0
HTTP_CONNECTION = Keep-Alive
HTTP_COOKIE = _ga=GA1.1.994183502.1540097814; __utmz=224856154.1540122275.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utma=224856154.994183502.1540097814.1540329245.1540330341.5
HTTP_HOST = 192.168.244.101:8080
HTTP_UPGRADE_INSECURE_REQUESTS = 1
HTTP_USER_AGENT = Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
HTTP_X_FORWARDED_FOR = 192.168.244.1
HTTP_X_FORWARDED_HOST = 192.168.244.101:8080
HTTP_X_FORWARDED_SERVER = cent7.a5.jp
HTTP_X_FORWARDED_USER = endou021  ★★★
LD_LIBRARY_PATH = /home/end0tknr/local/apache24/lib
PATH = /usr/local/go/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/end0tknr/.local/bin:/home/end0tknr/bin
QUERY_STRING = 
REMOTE_ADDR = 192.168.244.101
REMOTE_PORT = 44614
REMOTE_USER = endou021  ★★★
REQUEST_METHOD = GET
REQUEST_SCHEME = http
REQUEST_URI = /reverse_to/index.pl
SCRIPT_FILENAME = /home/end0tknr/dev/reverse_to/index.pl
SCRIPT_NAME = /reverse_to/index.pl
SERVER_ADDR = 192.168.244.101
SERVER_ADMIN = you@example.com
SERVER_NAME = 192.168.244.101
SERVER_PORT = 8080
SERVER_PROTOCOL = HTTP/1.1
SERVER_SIGNATURE = 
SERVER_SOFTWARE = Apache/2.4.34 (Unix) PHP/7.2.6

print_env.plの内容は、以下。

#!/usr/local/bin/perl
use strict;
use warnings;
use CGI;
use Encode;
use Data::Dumper;

main();

sub main {
    my $q = CGI->new();
    print STDERR Dumper($q);

    print CGI::header(-type=>'text/plain',-charset=>'UTF-8');

    for my $env_key (sort keys %ENV){
        print "$env_key = $ENV{$env_key}\n";
    }
}

その他 - access_logの出力項目に X-Forwarded-For と X-Forwarded-User を追加

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T  %{X-Forwarded-For}i %{X-Forwarded-User}i" combined

httpd.conf のLogFormatを↑このように編集すれば、↓こう出力されます。

192.168.244.101 - - [23/Dec/2018:09:14:25 +0900] "GET /reverse_to/index.pl HTTP/1.1" 200 1620 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" 0  192.168.244.1 endou021
192.168.244.1 - endou021 [23/Dec/2018:09:14:25 +0900] "GET /reverse_from/index.pl HTTP/1.1" 200 1620 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" 0  - endou021

%{X-Forwarded-User}i は、%{REMOTE_USER}i と記載したかったのですが、その場合、上手く出力されませんでした。

go言語 ( golang ) オレオレ入門 - ほんの触りだけ

特徴 (自分の理解)

単一fileの実行可能file作成が容易

install

ソースからのGo言語インストール - golang.jp

上記urlのようにsrcからのinstallもありますが、今回は、downloadして解凍するだけ。

$ sudo su -
$ cd /usr/local
$ wget https://dl.google.com/go/go1.11.2.linux-amd64.tar.gz
$ tar -xvf go1.11.2.linux-amd64.tar.gz

$ vi /etc/profile

PATH=/usr/local/go/bin:$PATH  ## <-- L.53付近にadd
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

作業環境の準備 ( $GOHOME )

$GOHOME 以下にpackageのsrcや実行fileが集約されます。

$ vi ~/.bash_profile
export GOHOME=$HOME/go
#↑追加. package等のinstall先

emacsでのgo-mode

私の環境のemacs for winでは、package installできなかったので、 以下のように手作業でinstall

$ cd c:/emacs-24.5-IME-patched/share/emacs/site-lisp/
$ wget https://raw.githubusercontent.com/dominikh/go-mode.el/master/go-mode.el
$ vi ~/.emacs
(autoload 'go-mode "go-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.go\\'" . go-mode))

packageの取得とbuild

以下の通り。

ただ、ローカル環境のbuildはどうするんでしょ? ちょっとしたcodeも GOHOME/src 以下に書くべきなんですかね?

# 「go get -d 」で $GOHOME/src以下に downloadのみ行います。
# 依存packageもdownloadする為、時間を要します。
# 「-d」がない場合、「go install」も行われます。
$ go get -d github.com/kahing/goofys

# 「go install」で実行fileが$GOHOME/src以下に作成されます。
$ go install github.com/kahing/goofys

# その他(参考)「go install」の場合、
# カレントディレクトリに作成されます。

php で、環境変数?(REMOTE_USER)やリクエストパラメータを取得後、ファイルを開いて内容を返す

次のような感じ?

<?php
$data_type = $_REQUEST['data_type'];
$user_id = $_SERVER['REMOTE_USER'];

$filename = '/home/end0tknr/dev/Test/'. $data_type .'/'. $user_id .'.txt';

if(! file_exists($filename) ) {
    header("HTTP/1.0 404 Not Found");
    return;
}

$filecontent = file_get_contents($filename);
header("Content-Type: text/plain; charset=utf-8");
echo($filecontent);

?>

fuse (fuse-utils) + goofys を srcから install し、aws s3をlocalにmount

2018/11/9 追記

ここでinstall手順をあれやこれや記載していますが http://bit.ly/goofys-latest から、 linuxバイナリ( https://github.com/kahing/goofys )も配布されています。

はじめに

s3fs は知っていましたが、goofys の選択肢もあり、それが s3fs より高速らしい。 (Goで書かれていて、POSIXに完全には準拠していないせいでしょうか?)

更にこれらは、fuseという仮想?ファイルシステムを作成できる機能を利用しているらしい。

と言う訳で、今回は fuse (libspectrum) や goofys を installしてみます。

http://fuse-emulator.sourceforge.net

https://github.com/kahing/goofys

ライブラリの依存関係

goofys や fuse-utils には、以下のような依存ライブラリ(パッケージ)がありますので、 順にinstallします。

goofys
└ fuse-utils
   └ fuse (libspectrum)
      ├ libgcrypt
      │  └ libgpg-error
      └ audiofile
          └ alsa-lib

fuse の依存libraryのinstall

libgcrypt が、libgpg-error を見つけてくれない為、 それぞれの configure時に --prefix や --with-libgpg-error-prefix を 指定しています。

これらの configure optionを付けない場合、 libgcryptのmake check時に、このエントリの下部にあるエラーが表示されました。

$ wget https://www.gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.32.tar.bz2
$ tar -xvf libgpg-error-1.32.tar.bz2
$ cd libgpg-error-1.32
$ ./configure --prefix=/usr/local/libgpg-error  #### ココ
$ make
$ make check
$ make install
$ sudo make install
$ wget https://www.gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.8.4.tar.bz2
$ tar -xvf libgcrypt-1.8.4.tar.bz2
$ cd libgcrypt-1.8.4
$ ./configure --with-libgpg-error-prefix=/usr/local/libgpg-error  #### ココ
$ make
$ make check
$ make install
$ sudo make install
$ ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.1.7.tar.bz2
$ tar -xvf alsa-lib-1.1.7.tar.bz2
$ cd alsa-lib-1.1.7
$ ./configure
$ make
$ make check
$ make install
$ sudo make install
# ftp://ftp.alsa-project.org/pub/utils/alsa-utils-1.1.7.tar.bz2
$ wget https://audiofile.68k.org/audiofile-0.3.6.tar.gz
$ tar -xvf audiofile-0.3.6.tar.gz
$ cd audiofile-0.3.6
$ ./configure
$ make
$ make check
$ make install
$ sudo make install

fuse (libspectrum)や fuse-utils の install

fusefuse-utilsのbuildの場合、 「use option -std=c99 or -std=gnu99 to compile your code」や 「No package 'libspectrum' found」とエラーになった為、 Makefileを編集したり、 LIBSPECTRUM_LIBS や LIBSPECTRUM_CFLAGS の環境変数を設定しています。

$ wget https://sourceforge.net/projects/fuse-emulator/files/libspectrum/1.4.4/libspectrum-1.4.4.tar.gz
$ tar -xvf libspectrum-1.4.4.tar.gz
$ cd libspectrum-1.4.4
$ ./configure --prefix=/usr/local/libspectrum
$ make
$ make check
 :
test/szx.c:135:7: error: ‘for’ loop initial declarations are only allowed in C99 mode
       for( size_t i = expected_length; i < total_length; i++ ) {
       ^
test/szx.c:135:7: note: use option -std=c99 or -std=gnu99 to compile your code
make[2]: *** [test/test_test-szx.o] Error 1
make[2]: Leaving directory `/home/end0tknr/tmp/libspectrum-1.4.4'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/home/end0tknr/tmp/libspectrum-1.4.4'
make: *** [check] Error 2

$ vi Makefile
  old) CFLAGS = -g -O2 -Wall -Wwrite-strings
  new) CFLAGS = -g -O2 -Wall -Wwrite-strings -std=c99

$ make
$ make check
$ sudo make install
$ wget https://sourceforge.net/projects/fuse-emulator/files/fuse-utils/1.4.3/fuse-utils-1.4.3.tar.gz
$ tar -xvf fuse-utils-1.4.3.tar.gz
$ cd fuse-utils-1.4.3
$ ./configure
  :
checking pkg-config is at least version 0.9.0... yes
checking for LIBSPECTRUM... no
configure: error: Package requirements (libspectrum >= 1.4.3) were not met:

No package 'libspectrum' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables LIBSPECTRUM_CFLAGS
and LIBSPECTRUM_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


$ export LIBSPECTRUM_LIBS=/usr/local/libspectrum/lib/libspectrum.so
$ export LIBSPECTRUM_CFLAGS=/usr/local/libspectrum

$ ./configure
$ make
$ make check
$ sudo make install

goofysのinstall

$ export GOPATH=/home/end0tknr/go
#### go get はプロンプトが返るまで、少々、時間を要します
$ go get github.com/kahing/goofys
$ go install github.com/kahing/goofys

goofysによるaws s3のmount

$ mkdir ~/tmp/mount_goofys
$ ~/go/bin/goofys --debug_fuse end0tknr-test-bucket ~/tmp/mount_goofys

参考 - libgcrypt における make check エラー

make[1]: Entering directory `/home/end0tknr/tmp/libgcrypt-1.8.4/tests'
make  check-TESTS
make[2]: Entering directory `/home/end0tknr/tmp/libgcrypt-1.8.4/tests'
./version: /lib64/libgpg-error.so.0: no version information available (required by ./version)
./version: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./version: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: version
./t-secmem: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-secmem: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-secmem
./mpitests: /lib64/libgpg-error.so.0: no version information available (required by ./mpitests)
./mpitests: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./mpitests: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: mpitests
./t-sexp: /lib64/libgpg-error.so.0: no version information available (required by ./t-sexp)
./t-sexp: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-sexp: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_lock_lock, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-sexp
./t-convert: /lib64/libgpg-error.so.0: no version information available (required by ./t-convert)
./t-convert: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-convert: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-convert
./t-mpi-bit: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-mpi-bit: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-mpi-bit
./t-mpi-point: /lib64/libgpg-error.so.0: no version information available (required by ./t-mpi-point)
./t-mpi-point: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-mpi-point: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-mpi-point
./curves: /lib64/libgpg-error.so.0: no version information available (required by ./curves)
./curves: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./curves: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: curves
./t-lock: /lib64/libgpg-error.so.0: no version information available (required by ./t-lock)
./t-lock: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-lock: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-lock
./prime: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./prime: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: prime
./basic: /lib64/libgpg-error.so.0: no version information available (required by ./basic)
./basic: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./basic: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: basic
./keygen: /lib64/libgpg-error.so.0: no version information available (required by ./keygen)
./keygen: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./keygen: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: keygen
./pubkey: /lib64/libgpg-error.so.0: no version information available (required by ./pubkey)
./pubkey: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./pubkey: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: pubkey
./hmac: /lib64/libgpg-error.so.0: no version information available (required by ./hmac)
./hmac: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./hmac: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: hmac
./hashtest: /lib64/libgpg-error.so.0: no version information available (required by ./hashtest)
./hashtest: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./hashtest: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: hashtest
./t-kdf: /lib64/libgpg-error.so.0: no version information available (required by ./t-kdf)
./t-kdf: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-kdf: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-kdf
./keygrip: /lib64/libgpg-error.so.0: no version information available (required by ./keygrip)
./keygrip: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./keygrip: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: keygrip
./fips186-dsa: /lib64/libgpg-error.so.0: no version information available (required by ./fips186-dsa)
./fips186-dsa: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./fips186-dsa: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: fips186-dsa
./aeswrap: /lib64/libgpg-error.so.0: no version information available (required by ./aeswrap)
./aeswrap: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./aeswrap: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: aeswrap
./pkcs1v2: /lib64/libgpg-error.so.0: no version information available (required by ./pkcs1v2)
./pkcs1v2: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./pkcs1v2: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: pkcs1v2
./random: /lib64/libgpg-error.so.0: no version information available (required by ./random)
./random: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./random: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: random
./dsa-rfc6979: /lib64/libgpg-error.so.0: no version information available (required by ./dsa-rfc6979)
./dsa-rfc6979: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./dsa-rfc6979: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: dsa-rfc6979
./t-ed25519: /lib64/libgpg-error.so.0: no version information available (required by ./t-ed25519)
./t-ed25519: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-ed25519: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-ed25519
./t-cv25519: /lib64/libgpg-error.so.0: no version information available (required by ./t-cv25519)
./t-cv25519: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./t-cv25519: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: t-cv25519
      now running 'basic' test with all hardware features disabled.
./basic: /lib64/libgpg-error.so.0: no version information available (required by ./basic)
./basic: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./basic: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: basic-disable-all-hwf
./benchmark: /lib64/libgpg-error.so.0: no version information available (required by ./benchmark)
./benchmark: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./benchmark: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: benchmark
./bench-slope: /lib64/libgpg-error.so.0: no version information available (required by ./bench-slope)
./bench-slope: /lib64/libgpg-error.so.0: no version information available (required by /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20)
./bench-slope: relocation error: /home/end0tknr/tmp/libgcrypt-1.8.4/src/.libs/libgcrypt.so.20: symbol gpgrt_get_syscall_clamp, version GPG_ERROR_1.0 not defined in file libgpg-error.so.0 with link time reference
FAIL: bench-slope
SKIP: hashtest-256g
======================================
27 of 27 tests failed
(1 test was not run)
Please report to http://bugs.gnupg.org
======================================
make[2]: *** [check-TESTS] Error 1
make[2]: Leaving directory `/home/end0tknr/tmp/libgcrypt-1.8.4/tests'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `/home/end0tknr/tmp/libgcrypt-1.8.4/tests'
make: *** [check-recursive] Error 1
$ 

install mod_dosdetector to apache 2.4

https://github.com/stanaka/mod_dosdetector

参考にさせて頂きました → http://blog.prophet.jp/1175

$ wget https://github.com/stanaka/mod_dosdetector/archive/master.zip
$ unzip mod_dosdetector-master.zip
$ cd mod_dosdetector-master
$ vi Makefile
  old) APXS=/usr/sbin/apxs
  new) APXS=/home/end0tknr/local/apache24/bin/apxs

$ make install


$ vi /home/end0tknr/local/apache24/conf/httpd.conf

  LoadModule rewrite_module modules/mod_rewrite.so
  LoadModule dosdetector_module modules/mod_dosdetector.so

  <IfModule mod_dosdetector.c>
  DoSDetection on
  DoSPeriod 30
  DoSThreshold 30
  DoSHardThreshold 60
  DoSBanPeriod 60
  DoSTableSize 100
  DoSForwarded on
  DoSIgnoreContentType ^(image/|application/javascript|text/css)
  DoSIgnoreIpRange 10.82.96.129
  </IfModule>
  
  RewriteEngine On
  RewriteCond %{ENV:SuspectHardDoS} =1
  RewriteRule .*  - [R=503,L]
  ErrorDocument 503 "Server is busy."

厚生労働省の「こころの耳」と「ストレスチェック実施プログラム」

メンタルヘルス」や「ワークライフ・バランス」に関し、 流石によくできていますが、 ストレスチェックwindowsアプリまで配布していることには驚きました。

https://stresscheck.mhlw.go.jp/

https://kokoro.mhlw.go.jp/

厚生省とは関係ありませんが、 次のurlの『仕事が「つまんない」ままでいいの?』も、 とっても分かりやすくまとめられています。

www.atmarkit.co.jp

Teiid Designer は、Eclipse Marketplace からinstall OK

「Teiid」で検索すると、「Red Hat Developer Studio Integration」と表示され、「おや?」と思いますが、その内容を展開すると、「JBoss Data Virtualization Development (Teiid Designer)」が見つかります。

f:id:end0tknr:20181022093700p:plain

installが完了すると、eclipseのメニューバーのwindow → perspective → open perspective → other から Teiid を見つけることができます。

f:id:end0tknr:20181022212536p:plain

f:id:end0tknr:20181022212539p:plain

jboss ( wildfly ) とsampleアプリのdeploy

javaのアプリサーバは、不慣れなので、練習。

jboss community editionの名称が、wildfly になっていることすら知りませんでした。

jboss ( wildfly ) のinstall

といっても、download して、解凍するだけ

$ wget http://download.jboss.org/wildfly/14.0.1.Final/wildfly-14.0.1.Final.tar.gz
$ tar -xvf wildfly-14.0.1.Final.tar.gz

jboss ( wildfly ) の設定

設定fileの編集と、ユーザの追加を行います。

$ vi wildfly-14.0.1.Final/standalone/configuration/standalone.xml

old) <inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
new) <inet-address value="${jboss.bind.address.management:192.168.244.101}"/>
old) <inet-address value="${jboss.bind.address:127.0.0.1}"/>
new) <inet-address value="${jboss.bind.address:192.168.244.101}"/>

jbossは、port=8080でサービス、port=9990で管理を行います。 私の環境では、vmにinstallしていることもあり、上記でipを 192.168.244.101 に変更しています。

wildfly-14.0.1.Final/standalone/configuration 以下には、 standalone-full-ha.xml や standalone-full.xml , standalone-ha.xml 等の 設定サンプルもあります。

https://access.redhat.com/documentation/ja-jp/red_hat_jboss_enterprise_application_platform/7.0/html-single/configuration_guide/index#standalone_server_configuration_files

jboss には、standalone の他に、domainもあるようですが、違いは理解していません。

次は、ユーザの追加です。

Management User と Application User の違いは理解していませんが、 「Management User」で追加しています。

$ wildfly-14.0.1.Final/bin/add-user.sh 

What type of user do you wish to add? 
 a) Management User (mgmt-users.properties) 
 b) Application User (application-users.properties)
(a): a

Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
Username : end0tknr
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
   :
<以降、略> 

sampleアプリのbuildの前に、maven の install

[WARNING] Rule 0: org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
To build this project Maven 3.2.5 (or greater) is required. Please install it.

古いmavenでbuildすると、上記のようなerrorとなるので、mavenからinstallします。

$ cd ~/local/
$ wget http://ftp.meisei-u.ac.jp/mirror/apache/dist/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
$ tar -xvf ~/tmp/apache-maven-3.5.4-bin.tar.gz 
$ ln -s apache-maven-3.5.4 maven

sampleアプリのbuild

$ ~/tmp/
$ git clone https://github.com/jboss-developer/jboss-eap-quickstarts.git
$ cd jboss-eap-quickstarts/helloworld
$ ~/local/maven/bin/mvn clean install

上記を実行すると、jboss-eap-quickstarts/helloworld/target/helloworld.war ができます。

「mvn clean install wildfly:deploy」と実行すると、wildfly へのデプロイまで 行ってくれるようですが、 先程、「jboss.bind.address.management:192.168.244.101」のように変更していることもあり、「wildfly:deploy」なしでbuildしています。

sampleアプリ (helloworld)のdeploy

後は、http://192.168.244.101:9990 から管理画面に入り、 先程の helloworld.war を uploadすれば、完了です。

emacs for win → spacemacs の移行とりやめ

自分用メモ

thinkpad x1 carbon (英語キーボード) + windows 10で、 emacs-24.5-IME-patched for win を使用していますが、 google日本語入力の変換候補のwindowsが表示されません。

そこで、試しに spacemacs をinstallしてみました。 spacemacsは、確かに多機能ですが、先程のgoogle日本語入力問題は解消されない為、 移行とりやめにしました。

http://spacemacs.org/

Log::Log4perl におけるバッファリング防止は、log4perl.appender.Logfile.autoflush=1

メモ

use strict;
use warnings;
use Date::Calc;
use Log::Log4perl;
   

my $CONF =
    {log=>
     {
#      'log4perl.rootLogger'=> 'INFO, LOGFILE',
      'log4perl.rootLogger'=> 'DEBUG, LOGFILE, CONSOLE',
      'log4perl.appender.LOGFILE'=>'Log::Log4perl::Appender::File',
      #↓ココ。「1」でバッファリング防止
      'log4perl.appender.Logfile.autoflush' => 1,
      'log4perl.appender.LOGFILE.dir'=> $APP_ROOT,
      'log4perl.appender.LOGFILE.filename'=> $APP_ROOT. 'migrate.log',
      'log4perl.appender.LOGFILE.mode'=>'append',
      'log4perl.appender.LOGFILE.layout'=>'Log::Log4perl::Layout::PatternLayout',
      'log4perl.appender.LOGFILE.layout.ConversionPattern'=>'%d [%p] %m %n',

      'log4perl.appender.CONSOLE'=> 'Log::Log4perl::Appender::Screen',
      'log4perl.appender.CONSOLE.layout' => 'Log::Log4perl::Layout::PatternLayout',
      'log4perl.appender.CONSOLE.layout.ConversionPattern' => '%d [%p] %m %n'},
    };
my $LOGGER;


sub do_main {
    my ($self ) = @_;
    $LOGGER = init_logger();

    $LOGGER->error($tmp_msg);
}

sub init_logger {

    Log::Log4perl::init($CONF->{log});
    my $logger = Log::Log4perl::get_logger("rootLogger");
    unless($logger){
        die "fail init_logger() $!";
    }
    return $logger;
}

コーチング手法。超・抜粋

コーチング ≠ ティーチング

コミュニケーションの方向
ティーチング 一方向。教え込む、指示
コーチン 双方向。働きかけ、提案、引き出す

委任 ≠ 放任

責任は、委任した側(上司)にある

コーチングにおける3つのマインド

内容
Interactive 双方向コミュニケーション
on going 継続的コミュニケーション
tailor made 相手に合わせたコミュニケーション

オープン/クローズ x 事実/意見 の質問順序

クローズ オープン
事実 1番目 2番目
意見 3番目 4番目
  • クローズ質問:Yes/Noで答えられる質問
  • オープン質問:Why/What/Howでの質問

その他、聞く側に回る。(聞く:話す=5:5 では話しすぎ)

質問 / 詰問

  • 質問:事に着目。例:できなかった原因は何だろう?
  • 詰問:人に着目。例:どうして、君はできなかったんだ?

DiSC理論と、接し方

長所 短所
D(主導) 行動力が高い。
意思決定が速い。
人に対しはっきり言う
ルールやチームワークに関心なし
i(感化) 人と接する事が好き。
ムードメーカ。楽観的。
緻密さに欠け、成果や人に対して厳しさに欠ける
S(安定) 協調性があり、人に対し協力的。 今の環境を好み変化を嫌う。
自ら考え行動する事が苦手。
C(慎重) 論理的、整合性を重視。
物事に対し細部まで納得しないと行動しない。
自分の考え、アイディアを批判されると防御的になる。

apache 2.4で ある拡張子のファイルをダウンロードさせる

とある拡張子を持つファイル(例: .xyz)をブラウザで開くと、 google chromeではファイルダウンロードしてくれますが、 ie11では、ブラウザで開いてしまう現象が発生。

そこで、httpd.confに

AddType application/octet-stream .xyz

を追加し、解消したかと思ったら、 同じ拡張子で、ファイルダウンロードとなる場合とブラウザで開いてしまう場合が発生。

なので、

<FilesMatch "\.(xyz)$">
    Header set Content-Disposition attachment
</FilesMatch>

を更に追加することで、解消。