2020/10/23

NeoMuttでS/MIMEを使用する

試したのはPlamo Linux 7.xです。

mutt の S/MIME 機能の利用法 を参考にしました。

以下はmuttもインストールしている環境で行っています。

まず、NeoMuttのソースに含まれるsmime.rcの記述をNeoMuttの設定ファイルに記述します。

$ cat neomutt-20200925/contrib/smime.rc >> ~/.muttrc


次にmuttに含まれるsmime_keys initを実行します。

$ smime_keys init


証明書を取得します。
私は下記のサイトを参考にしました。
最後に証明書を追加するためのパスワードが表示されますので、必ず控えておきます。
忘れた場合、取得した証明書をREVOKEして再度取得し直す必要があるようです。

取得できるファイルはpfxファイルです。
一応p12にリネームしてから追加します。

$ mv PKCS12_Credential_xxx.pfx PKCS12_Credential_xxx.p12
$ smime_keys add_p12 PKCS12_Credential_xxx.p12

ここで上で控えておいたパスワードが必要になります。
さらに新しいパスワードの追加と、覚えやすいラベルを設定します。

最後に
added private key: /home/takahiro/.smime/keys/12345678.0 for xxx@xxx
のように表示されますので、.0がついた数字部分を覚えておきます。


NeoMuttの設定ファイルでsmime_sign_asを設定します。

$ vim .muttrc
$ cat .muttrc |grep smime_sign_as
set smime_sign_as="12345678.0"


ルート証明書をインポートします。
こちらはNeoMuttのソースには見当たらなかったのでMuttからいただきました。

$ smime_keys add_root mutt-1.14.7/contrib/ca-bundle.crt 


メール送信時にエラーになる場合はunset crypt_use_gpgmeをNeoMuttの設定ファイルに記述します。

$ cat .muttrc |grep crypt_use_gpgme
unset crypt_use_gpgme


以上で私の環境ではNeoMuttでS/MIMEが使えるようになりました。

2020/10/21

Plamo Linux 7.xでsnapper

Plamo Linux 7.xにsnapperをインストールしてみました。

私の環境では他に必要なものは特になくインストールできました。
Plamo Linux 7.xに色々インストールしていますので、他の環境では必要なライブラリなどがあるかもしれません。

/homeにファイルシステムbtrfsを使っています。

# df -Th /home
ファイルシス   タイプ サイズ  使用  残り 使用% マウント位置
/dev/sda10     btrfs    145G   20G  125G   14% /home

/home/takahiro がsubvolumeです。


Arch Linuxのサイトを参考にしました。


まず新しい設定を作成しようとしましたが、失敗します。

# snapper -v -c takahiro create-config /home/takahiro
失敗しました (org.freedesktop.DBus.Error.NoReply) 。
#


/var/log/snapper.logを見ると

# less /var/log/snapper.log 

~省略~

2020-10-21 21:15:37 WAR libsnapper(6499) AsciiFile.cc(AsciiFileReader):66 - open for '/e
tc/sysconfig/snapper' failed
2020-10-21 21:15:37 WAR libsnapper(6499) AsciiFile.cc(AsciiFileReader):67 - THROW: file not found
2020-10-21 21:15:37 WAR libsnapper(6499) Snapper.cc(getConfigs):300 - THROW: sysconfig-file not found

~省略~

よく分からないですが、とりあえずtouchでファイルを作成してみます。

# touch /etc/sysconfig/snapper
# snapper -v -c takahiro create-config /home/takahiro
#

成功しました。


一般ユーザーでもスナップショットを確認できるようにします。

# vim /etc/snapper/configs/takahiro 
# cat /etc/snapper/configs/takahiro |grep ALLOW_USERS
   ALLOW_USERS="takahiro"
   # sync users and groups from ALLOW_USERS and ALLOW_GROUPS to .snapshots

一般ユーザが所属しているグループにグループ所有権を変更します。

# cd /home/takahiro/
# chmod a+rx .snapshots
# chown :users .snapshots


GUIフロントエンドのsnapper-guiをインストールしました。

使用するのに必要なものはgithubのページに書いてあります。
私の環境ではgtksourceviewをインストールする必要がありました。

下のような感じです。


2020/10/13

Plamo Linux 7.2でLXCを使ってみる (その3)

前回までに作ったコンテナではパスワードを変更できません。
そこで新しくPlamo-6.xのコンテナを作成してみて比較してみます。


takahiro@plamovaio:~$ lxc-create --name plamolxc03 --template download -- --dist plamo --release 6.x --arch amd64
Setting up the GPG keyring
Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs

---
You just created an Plamolinux 6.x x86_64 (20201013_01:33) container.

takahiro@plamovaio:~$ lxc-start -n plamolxc03

takahiro@plamovaio:~$ lxc-attach -n plamolxc03
bash-4.3# passwd
新しい UNIX パスワードを入力してください:
新しい UNIX パスワードを再入力してください:
passwd: パスワードは正しく更新されました
 
 
呆気なくパスワードの変更ができました。
 
Plamo-7.xとPlamo-6.xでは何か違うのでしょうか? 

Plamo-MLの[plamo:33410] pkgtools7でPlamo-7.xのコンテナが動かないってあるけれど、これが原因なのでしょうか。

Plamo Linux 7.2でLXCを使ってみる その2(失敗)

(2020年10月27日追記)
Plamo LinuxのMLで下記のパスワード変更ができない問題について修正されたとありました。

takahiro@plamovaio:~$ lxc-create -n plamolxc -t download -- --flush-cache -d plamo -r 7.x -a amd64
Flushing the cache...
Setting up the GPG keyring
Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs

---
You just created an Plamolinux 7.x x86_64 (20201027_01:33) container.
takahiro@plamovaio:~$ lxc-start -n plamolxc
takahiro@plamovaio:~$ lxc-attach -n plamolxc
bash-4.4# passwd
新しいUNIXパスワード:
新しいUNIXパスワードを再入力してください:
passwd: パスワードは正しく更新されました

パスワードの変更が問題なくできました。

以下の文章は古いです。

(2020年10月27日追記 終わり)

こちらの続きです。
 
コンテナとやらが起動したので使ってみます。
 
$ lxc-attach -n plamolxc02
bash-4.4# id
uid=0(root) gid=0(root) groups=0(root) 
bash-4.4# hostname
plamolxc02

 
無事起動はしているようです…が、パスワードの変更ができません。

bash-4.4# passwd
パスワード: 認証トークン操作エラー
passwd: パスワードは変更されませんでした

こういう時は英語でググってみた方が良いと思うのでLANG=Cの時の
# LANG=C passwd
passwd: Authentication token manipulation error
passwd: password unchanged

ググってみたらこちらの記事を見つけました。
 
pwconvコマンドを実行すれば良いとありますが、コンテナ上のPlamo Linuxにはpwconvコマンドがありません。
母艦のPlamo-7.xにはあります。
 
そこで、Plamo-7.xの shadow-4.8.1-x86_64-B1.txzをコンテナ上のPlamo Linuxにコピーしてインストールしてみます。

母艦上で下記のようにLXCのrootユーザのホームディレクトリにコピーしました。
takahiro@plamovaio:~$ sudo cp shadow-4.8.1-x86_64-B1.txz  ~/.local/share/lxc/plamolxc02/rootfs/root/
 
そしてコンテナ上でインストールします。
 
bash-4.4# cd /root
bash-4.4# ls
shadow-4.8.1-x86_64-B1.txz
bash-4.4# /sbin/installpkg shadow-4.8.1-x86_64-B1.txz
bash: /sbin/installpkg: /sbin/installer/sh: 誤ったインタプリタです: そのようなファイルやディレクトリはありません

エラーになってインストールできない…。
仕方ないので手動でインストールします。

bash-4.4# tar xvf shadow-4.8.1-x86_64-B1.txz -C /
bash-4.4# /usr/sbin/pwconv
bash-4.4# passwd
パスワード: 認証トークン操作エラー
passwd: パスワードは変更されませんでした

駄目でした。

Plamo Linux 7.2でLXCを使ってみる

よく分からずやっています。
真似しないでください
 
とりあえず実行してみた備忘録です。
これから色々調べます。
 
こちらを参考にしました。 
Ubuntu 14.04 LTS での非特権コンテナ
 
 
Plamo Linux 7.x
lxc-4.0.4
という環境です。
 
 
takahiroユーザで非特権コンテナを作成します。
 
まず/etc/subuidと/etc/subgidを作成しるため、以下コマンドを実行しました。

takahiro@plamovaio:~$ sudo usermod -v 100000-165535 -w 100000-165535 takahiro

takahiro@plamovaio:~$ cat /etc/subuid /etc/subgid
takahiro:100000:65536
takahiro:100000:65536

takahiro@plamovaio:~$ echo "takahiro veth lxcbr0 10" | sudo tee -a /etc/lxc/lxc-usernet
takahiro veth lxcbr0 10

takahiro@plamovaio:~$ echo "session optional        pam_cgfs.so -c all" | sudo tee -a /etc/pam.d/system-session 
session optional        pam_cgfs.so -c all

ここで再起動しました。ログアウトしてログインだとだめでした。


次に$HOME/.config/lxc/default.confを作成します。
参考にしたサイトではlxc.id_mapになっていましたが、これだとlxc-create実行時にエラーになってしまいます。
 
こちらを見たところlxc.idmapになっていたので、私の方もそうしましたところエラーにはならなくなりました。
lxcのバージョンによって違うのでしょうか?
まだ調べていません。
 
takahiro@plamovaio:~$ cd
takahiro@plamovaio:~$ mkdir -p .config/lxc
takahiro@plamovaio:~$ cp /etc/lxc/default.conf .config/lxc/
takahiro@plamovaio:~$ vim .config/lxc/default.conf
takahiro@plamovaio:~$ cat .config/lxc/default.conf
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx

lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536


コンテナを作成します。

takahiro@plamovaio:~$ lxc-create --name plamolxc02 --template download -- --dist plamo --release 7.x --arch amd64
Setting up the GPG keyring
Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs

---
You just created an Plamolinux 7.x x86_64 (20201013_01:33) container.
 
takahiro@plamovaio:~ lxc-ls --fancy
NAME       STATE   AUTOSTART GROUPS IPV4 IPV6 UNPRIVILEGED
plamolxc02 STOPPED 0         -      -    -    true         


コンテナを起動します…が、エラーに。

takahiro@plamovaio:~$ lxc-start -n plamolxc02
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/lxccontainer.c: wait_on_daemonized_start: 849 Received container state "ABORTING" instead of "RUNNING"
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 308 The container failed to start
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 311 To get more details, run the container in foreground mode
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 313 Additional information can be obtained by setting the --logfile and --logpriority options

takahiro@plamovaio:~$ sudo /etc/rc.d/init.d/lxc start
  *  Starting LXC autoboot containers: 
takahiro@plamovaio:~$ lxc-start -n plamolxc02
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/lxccontainer.c: wait_on_daemonized_start: 849 Received container state "ABORTING" instead of "RUNNING"
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 308 The container failed to start
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 311 To get more details, run the container in foreground mode
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 313 Additional information can be obtained by setting the --logfile and --logpriority options

takahiro@plamovaio:~$ sudo /etc/rc.d/init.d/lxcfs start
  *  Starting... LXCFS
takahiro@plamovaio:~$ lxc-start -n plamolxc02
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/lxccontainer.c: wait_on_daemonized_start: 849 Received container state "ABORTING" instead of "RUNNING"
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 308 The container failed to start
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 311 To get more details, run the container in foreground mode
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 313 Additional information can be obtained by setting the --logfile and --logpriority options

takahiro@plamovaio:~$ sudo /etc/rc.d/init.d/cgroupfs-mount start
     Mounting cgroupfs hierarchymount: /sys/fs/cgroup/systemd: cgroup は /sys/fs/cgroup にマウント済みです.
takahiro@plamovaio:~$ lxc-start -n plamolxc02
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/lxccontainer.c: wait_on_daemonized_start: 849 Received container state "ABORTING" instead of "RUNNING"
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 308 The container failed to start
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 311 To get more details, run the container in foreground mode
lxc-start: plamolxc02: /Plamo-src/plamo/16_virtualization/lxc/lxc-4.0.4/src/lxc/tools/lxc_start.c: main: 313 Additional information can be obtained by setting the --logfile and --logpriority options

ここでやっとログファイルを見てみようという気に。
takahiro@plamovaio:~ lxc-start -n plamolxc02 --logfile /tmp/lxc-start.log --logpriority DEBUG


/tmp/lxc-start.logを見ると、次のようなエラーがあります。
 
lxc-4.0.4/src/lxc/start.c:print_top_failing_dir:98 - Permission denied - Could not access /home/takahiro/.local/share. Please grant it x access, or add an ACL for the container root

良いのか分かりませんが、chmod +x しろというエラーのようです。
してみます。

takahiro@plamovaio:~$ ls -l /home/takahiro/.local/
合計 8,192
drwxr-xr-x  3 takahiro users 4,096 10月  6日  22:19 lib/
drwx------ 11 takahiro users 4,096 10月 13日  18:58 share/

takahiro@plamovaio:~$ chmod +x /home/takahiro/.local/share
 
takahiro@plamovaio:~$ ls -l /home/takahiro/.local/
合計 8,192
drwxr-xr-x  3 takahiro users 4,096 10月  6日  22:19 lib/
drwx--x--x 11 takahiro users 4,096 10月 13日  18:58 share/

再度lxc-startを実行します。
takahiro@plamovaio:~$ lxc-start -n plamolxc02
takahiro@plamovaio:~$

何のエラーもなく起動しました。

takahiro@plamovaio:~$ lxc-ls --fancy
NAME       STATE   AUTOSTART GROUPS IPV4      IPV6 UNPRIVILEGED
plamolxc02 RUNNING 0         -      10.0.3.66 -    true