Messages in cipher reflected in the looking glass
[ Yasuhiro Fujitsuki's Weblog ]
http://blogs.sun.com/thaniwa/date/20080123 2008年 1月 23日 水曜日

(EN) xrdp 0.4.0 on Solaris Express

http://xrdp.sourceforge.net/
Xrdp is a RDP server software for linux. In default Linux environment, we can transfer X11 application with ssh -X or X protcol. Default Windows environment has no function to display X11 application (Windows requires X11 server application like cygwin-X11, reflection X and so on). To use xrdp, Windows can connect to Linux with Windows Terminal Services client.

Xrdp is for Linux, so it is not possible to compile on Solaris without change.
I wrote patches of xrdp for Solaris Express environment.


The way to apply patches except startwm.sh is as follows . startwm.sh is a shell script, if you want to use it , please overwrite /usr/local/xrdp/startwm.sh .

# gpatch -p0 < xrdp-0.4.0-ja.gdiff

The outline of xrdp-0.4.0-sxce.gdiff is as follows.

  • Changed from 'make' to 'gmake' in all Makefile.
  • Changed 'install' to '/usr/ucb/install'
  • Deleted '-ldl' option of LIBS in libxrdp/Makefile
  • Added '-D_POSIX_PTHREAD_SEMANTICS' to DEFINES and '-lsocket' to LDFLAGS in sesman/Makefile .
  • Deleted '-lpthread' flag from LDFLAGS in sesman/libscp/Makefile .
  • Added '-lsocket' to LDFLAGS in sesman/tools/Makefile .
  • Deleted g_setenv("SHELL", pw_shell, 1); from sesman/env.c
    # Sesman get Segmentation Fault to exec this line.
  • Changed xrdp_control.sh to run on Solaris.

The way to build software is as follows. (tcsh)

# setenv PATH $PATH":/usr/sfw/bin"
# setenv LD_LIBRARY_PATH /usr/lib:/usr/ccs/lib:/usr/sfw/lib
# setenv LD /usr/sfw/bin/gld
#
# gmake 
# gmake install

To run xrdp is as follows.

# /usr/local/xrdp/xrdp_control.sh start

Connected to xrdp server with rdesktop (login screen)



After logged in.



http://blogs.sun.com/thaniwa/date/20080121 2008年 1月 21日 月曜日

(JA) xrdp : Connect CentOS on Solaris xvm via RDP


の合わせ技です。^-^;
Solaris Express の XVM上で CentOS 5.1 を起動し、その上で xrdp を起動してます。 Solaris Express からは rdesktop を利用して CentOS の GUI にアクセスしています。
この方法では gdm を必要としないので、CentOS は runlevel = 3 のままです。 ( Linux では runlevel = 5 が GUI )

意味があるかどうかはわかりませんが、ネタということで。 使う側からすると Terminal Server の接続を含め rdesktop に一本化できるというのがメリットになるのかもしれません。






http://blogs.sun.com/thaniwa/date/20080116 2008年 1月 16日 水曜日

(JA) xrdp 0.4.0

http://xrdp.sourceforge.net/
で開発されている xrdp というソフトウェアがあります。
以前、このブログで紹介した事のある rdesktop は Windows Terminal Server に接続するためのソフトウェアですが、 xrdp は linux を Terminal Server 化してしまうソフトウェアです。 (xrdp は rdesktop や vnc などの機能を内部で利用しているそうです。)
Linux や Solaris などの X-Window システムでは、 他のマシンに Xのアプリケーションを転送することなどは簡単なので、 用途は少なそうですが、xrdp を使うことにより、RDP でアクセス可能になるため、 Windows XP などのターミナルサーバ接続を利用して Linux に接続が行えるようになります。
っと、これがうれしいかどうかわかりませんが、せっかくなので試してみました。
linux用なんですけど、無謀にも Solaris Express 動かしてみようと思い、 中を除くと、autoconfを利用していないようで、Makefileしかありません。 Makefile を見ると、linux用に作り込んでいるので、Solaris用に改変が必要でした。 大まかに書くと、

  • 全部のMakefile内の make を gmake に変更、install を/usr/ucb/install に変更。
  • libxrdp/Makefile の LIBS = -ldl の -ldl を削除。
  • sesman/Makefile の DEFINES に -D_POSIX_PTHREAD_SEMANTICS を追加。LDFLAGS に -lsocket を追加。
  • sesman/libscp/Makefile の LDFLAGS の -lpthread を削除。
  • sesman/tools/Makefile の LDFLAGS に -lsocketを追加。

その後、下記の通り、環境変数をセットし、gmake を実行。

# setenv PATH $PATH":/usr/sfw/bin"
# setenv LD_LIBRARY_PATH /usr/lib:/usr/ccs/lib:/usr/sfw/lib
# setenv LD /usr/sfw/bin/gld
#
# gmake 
# gmake install

これでとりあえずビルドはなんとかなりました。 ただ、本当にこの変更が正しいのか自信はまったくありません(笑。

一応、インストールされたので、

# /usr/local/xrdp/xrdp_control.sh start

を実行して daemon を起動しようとしましたが、動きません。 中身を見てみると、一行めが #!/bin/sh になってます。 Linux の場合、sh = bash だったりするので、 #!/bin/bash に変更しました。
それ以外に、grep を利用してプロセスの存在を確認する部分があるのですが、 これも Solaris では動かないので変更しました。

  #ps u --noheading -C $XRDP | grep -q -i $XRDP
  /usr/ucb/ps auc | ggrep -v xrdp_control.sh | ggrep -q -i $XRDP

  #ps u --noheading -C $SESMAN | grep -q -i $SESMAN
  /usr/ucb/ps auc | ggrep -q -i $SESMAN

これでなんとか、起動しました。 後は rdesktop などで接続したのですが、デスクトップが英語になってしまいます。 この制御は /usr/local/xrdp/startwm.sh に書いてあります。 一応、そのままでも動きますが、先頭は #!/bin/bash に変更。 あと、LANG を日本語に変更し、gnome-session を dtlogin の実行する Xsession.jds に変更しました。こうすると ATOK の起動も全部やってくれるので楽ちんです。^-^;

export LANG=ja_JP.UTF-8

# gnome
which gnome-session
if [ $? -eq 0 ]; then
  #gnome-session
  /usr/dt/config/Xsession.jds
  exit 0
fi

これで起動してみると動きますが、Solaris Expressではなんとか動いているという感じです。不安定だったり謎の挙動もあります…。
本当はソースをちゃんと確かめないといけないのでしょうが、 今回は Makefile を適当に改変^-^;しただけなので、当然と言えば当然かもしれません。
あと、キーボードが英語キーボードの配列になってます…。
それで、
http://xrdp.sourceforge.net/documents/keymap/newkeymap.html
を見てみると、xrdp 0.4.0 では外部 keymap ファイルには対応しておらず、 内部のキーマップを参照しているとのこと。 ちょっとソースコードを調べて見たところ、xrdp/lang.c が該当するようです。
中身を見てみると、en_US, Italy, en_UK, Portuguese(Brazil), German, French と書いてあります。 ここをイジれば、なんちゃって日本語対応もできそうです。 適当にイジってみて、何となく日本語キーボードを認識するようになりました。

0.5.0では外部キーマップに対応する予定らしいので、もうちょっとまともになっていくのかもしれません。

ということで、全部パッチにしてみました。


# gpatch -p0 < xrdp-0.4.0-ja.gdiff

という感じで当ててください。 あとは上記の通り、gmake, gmake install (linuxの場合は patch, make, make install) でインストールすれば完了です。
xrdp-0.4.0-ja.gdiff は Linux でも使えると思います。

(追記 : 2008/01/23)
Solaris Express 用パッチ( xrdp-0.4.0-sxce.gdiff )に sesman/env.c に対するパッチを追加しています。
コメントアウトした部分がどうも Segmentation Fault を引き起こすみたいです。 その前に pw_shell 変数の値を取得する部分があるのですが、 ここで値がうまく取れていないみたいなので、 セットしないようにしました。

        g_clearenv();
        //g_setenv("SHELL", pw_shell, 1);
        g_setenv("PATH", "/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin", 1);
        g_setenv("USER", username, 1);
        g_sprintf(text, "%d", uid);

rdesktopでxrdpサーバに接続したところ(ログイン画面)



Solaris Express にログインしたところ (gnome)



http://blogs.sun.com/thaniwa/date/20080111 2008年 1月 11日 金曜日

(EN) Running CentOS 5.1 on Soalris xvm

I tried and success to install and run CentOS 5.1 on Solaris xvm/xen.
So, I wrote logs.
I also try to install Fedora 8 onto Solaris xvm, but I got errors when installing Fedora 8 with virt-install command. virt-install seems not to support Fedora 8.

Making A Image File of CentOS

Before installing CentOS, you have to prepare servers, nfs server or http server or ftp server. And copy all files in CentOS DVD image into [nfs, http, ftp] server's directory. In this content, I used nfs server(nfs_server:/export2/soft/CentOS).
The reason of prepairing server, virt-install command, which command is used when making guest OS images, can boot from DVD iso image of linux, but installer(up by virt-install) cannot load rpm files of DVD images. Therefore, server is needed to make guest OS images.

Use virt-install command to make guest OS images.
The parameters of this test is as follows.

  • Virtual Machine Name = centos5
  • Memory for VM = 512MB
  • Image File of guest OS = /export/centos5
  • Disk size of Image File = 4GB
  • Graphics Support = no
    *** If you want to install linux, you have to set this parameter no .
    Reference : http://in.opensolaris.org/jive/thread.jspa?threadID=45427&tstart=45
  • Installer Image = nfs:nfs_server:/export2/soft/CentOS

The execution sample is as follows.

bash-3.2# virt-install
What is the name of your virtual machine? centos5
 How much RAM should be allocated (in megabytes)? 512
 What would you like to use as the disk (path)? /export/centos5
 How large would you like the disk (/export/centos5) to be (in gigabytes)? 4
 Would you like to enable graphics support? (yes or no) no
 What is the install location? nfs:nfs_server:/export2/soft/CentOS


Starting install...
Creating storage file...  100% |=========================| 4.0 GB    00:00
Creating domain...                                                 0 B 00:16
Linux version 2.6.18-53.el5xen (mockbuild@builder6.centos.org) (gcc version 4.1.
2 20070626 (Red Hat 4.1.2-14)) #1 SMP Mon Nov 12 03:26:12 EST 2007
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000020800000 (usable)
0MB HIGHMEM available.

After setting parameters, virt-install load text installer as follows.

Welcome to CentOS

                   +---------+ Choose a Language +---------+
                   |                                       |
                   | What language would you like to use   |
                   | during the installation process?      |
                   |                                       |
                   |       Catalan                ^        |
                   |       Chinese(Simplified)    :        |
                   |       Chinese(Traditional)   #        |
                   |       Croatian               :        |
                   |       Czech                  :        |
                   |       Danish                 :        |
                   |       Dutch                  :        |
                   |       English                v        |
                   |                                       |
                   |                +----+                 |
                   |                | OK |                 |
                   |                +----+                 |
                   |                                       |
                   |                                       |
                   +---------------------------------------+

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

Select options and Install CentOS. After installation, a virtual machine reboot and appear menus.
In this menu you can set security options, SELinux and Firewall. If you want to test easily, please set disable these options. CentOS offers "system-config-securitylevel" to change security level parameters, so you can change settings later when you set enable these parameters.

xm command

xm is a command to operate virtual machines on xvm/xen.
At least, you sould know list, start, shutdown and console options to use virtual machine.

# xm start centos5

# xm list
Name                                      ID   Mem VCPUs      State   Time(s)
Domain-0                                   0   484     1     r-----    527.1
centos5                                    6   512     1     -b----     47.6

# xm console centos5
.....
CentOS release 5 (Final)
Kernel 2.6.18-53.el5xen on an i686

localhost.localdomain login:

Use X of CentOS

In default, Solaris express is not permit remote connections of X application. To change it, use svccfg command as follows.

bash-3.2# svccfg -s x11-server listprop
options                                  application
options/default_depth                    integer  24
options/server                           astring  /usr/X11/bin/Xorg
options/server_args                      astring
options/stability                        astring  Evolving
options/value_authorization              astring  solaris.smf.manage.x11
options/tcp_listen                       boolean  false
.....

bash-3.2# svccfg -s x11-server setprop options/tcp_listen = true
svc:/application/x11/x11-server

After changed, please re-start X server.
To use X application of CentOS, set DISPLAY enviromnent variable on CentOS side and run xhost command on Solaris.

# xhost + centos (on Solaris side)


# export DISPLAY=solaris:0 (on CentOS side)

Run gdm of CentOS via Xnest

The following logs are set up to use gdm of CentOS via Xnest.

At first, set parameter in /etc/gdm/custom.conf file to be able to connect gdm via network.
Red charactors in the following are added settings.
AllowRemoteRoot=true is not needed, if you do not want to log into CentOS by root user.

[daemon]
RemoteGreeter=/usr/libexec/gdmgreeter

[security]
AllowRemoteRoot=true

[xdmcp]
Enable=true

If you are using firewall, you have to change to be able to connect XDMCP(177/UDP) from other machine.

In default, CentOS run on console mode. If you want to run graphical user interface mode on default, change /etc/inittab .

[root@localhost sbin]# runlevel
N 3

[root@localhost sbin]# cat /etc/inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, 
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

Of course, you can change to graphical user mode using init command.

[root@localhost sbin]# ps -ef | grep gdm

[root@localhost sbin]# init 5
[root@localhost sbin]# Intel CPU マイクロコードアップデートを適用中: [失敗]
Starting monitoring for VG VolGroup00:   2 logical volume(s) in volume group "Vo
lGroup00" monitored
[  OK  ]
readahead をバックグランドで起動中: [  OK  ]
irqbalance を起動中: [  OK  ]
anacron を起動中: [  OK  ]
readahead をバックグランドで起動中: [  OK  ]

[root@localhost sbin]# ps -ef | grep gdm
root      2231     1  0 20:29 ?        00:00:00 /usr/sbin/gdm-binary -nodaemon
root      2260     1  0 20:29 ?        00:00:00 /usr/sbin/gdm-binary -nodaemon
root      2338  1968  0 20:30 xvc0     00:00:00 grep gdm

After up gdm, you can use with Xnest as follows.

# Xnest :1 -query centos

These are screenshots of running CentOS 5.1 on Solaris Express xvm/xen, and connecting CentOS 5.1 via Xnest.




http://blogs.sun.com/thaniwa/date/20080110 2008年 1月 10日 木曜日

(JA) Solaris Express XVM/Xen に CentOS 5.1 をインストールする

かなり久しぶりの更新です。今後もぼちぼちと更新していきたいと思います。^-^;
というのはさておき、Solaris Express(nevada) に xvm(xen) サポートが追加されて しばらく立ちますが、CentOS 5.1 のインストールをしてみたので、 そのログを残しておこうかと思います。
当初は Fedora 8 を入れてみようかと思ったのですが、 サポートされていないようで、うまくいきませんでした。

CentOS イメージの作成

Solaris Express(nevada)をxvm/xenカーネルで立ち上げた後、 ゲストOSをインストールしますが、インストール前に CentOSのインストールイメージをサーバ上に用意する必要があります。
簡単に言うと、DVD ISOの中身を展開して、 ネットワーク経由で見えるようにするだけです。 http, nfs, ftp のどれでも構いません。今回は nfs 経由(nfs_server:/export2/soft/CentOS)で見えるようにしてみました。
xvm/xen で OS イメージを作成する virt-install コマンドでは ISO イメージを直接読み込ませることが可能なんですが、 インストーラがこのイメージを認識出来ないようで、 サーバが無い場合、インストールが行えません。
ネットワーク経由で見えるようになれば、起動もそこから可能なので、 ISOイメージは不要です…。

OS イメージの作成は virt-install コマンドで行います。 オプション指定も可能ですが、 virt-install を起動すると、 設定が必要な項目を確認してくるので、それを利用するのも手です。
ここで設定しているのは

  • 仮想マシンの名前 = centos5
  • 仮想マシンのメモリ = 512MB
  • 仮想マシンのディスクイメージファイル = /export/centos5
  • ディスクイメージファイルの容量 = 4GB
  • グラフィックスを利用するか = no
    *** yes を指定するとGUIインストーラが起動するのですが、 Linux をインストールする場合は no を指定する必要があります。
    http://in.opensolaris.org/jive/thread.jspa?threadID=45427&tstart=45 にも出てますが、yes にすると virt-install が途中で終了し、 イメージ作成が行えません。
  • インストール元の場所 = nfs:nfs_server:/export2/soft/CentOS

bash-3.2# virt-install
What is the name of your virtual machine? centos5
 How much RAM should be allocated (in megabytes)? 512
 What would you like to use as the disk (path)? /export/centos5
 How large would you like the disk (/export/centos5) to be (in gigabytes)? 4
 Would you like to enable graphics support? (yes or no) no
 What is the install location? nfs:nfs_server:/export2/soft/CentOS


Starting install...
Creating storage file...  100% |=========================| 4.0 GB    00:00
Creating domain...                                                 0 B 00:16
Linux version 2.6.18-53.el5xen (mockbuild@builder6.centos.org) (gcc version 4.1.
2 20070626 (Red Hat 4.1.2-14)) #1 SMP Mon Nov 12 03:26:12 EST 2007
BIOS-provided physical RAM map:
 Xen: 0000000000000000 - 0000000020800000 (usable)
0MB HIGHMEM available.

設定が終わると、テキストインストーラが起動します。

Welcome to CentOS

                   +---------+ Choose a Language +---------+
                   |                                       |
                   | What language would you like to use   |
                   | during the installation process?      |
                   |                                       |
                   |       Catalan                ^        |
                   |       Chinese(Simplified)    :        |
                   |       Chinese(Traditional)   #        |
                   |       Croatian               :        |
                   |       Czech                  :        |
                   |       Danish                 :        |
                   |       Dutch                  :        |
                   |       English                v        |
                   |                                       |
                   |                +----+                 |
                   |                | OK |                 |
                   |                +----+                 |
                   |                                       |
                   |                                       |
                   +---------------------------------------+

  <Tab>/<Alt-Tab> between elements  | <Space> selects | <F12> next screen

テキストベースのインストーラが起動しますので、オプションを選択してインストールします。この辺はCentOSのインストールそのものです。 上記のダイアログで日本語の選択もできますが、インストーラの表示は英語のままで、インストールを日本語で行うことはできません。
インストールが終わると、再起動し、設定画面が起動しますので、適切に設定します。 この際、SELinux と ファイアウォールの設定が出てきますが、 無効にしておく方が実験するには楽です。
ファイアウォールを有効にしておいても問題はありませんが、 必要に応じて設定を変更する必要が出てきます。 CentOS では system-config-securitylevel というコマンドでこの辺の設定が行えます。

xm コマンド

仮想マシンの起動などの操作は xm コマンドを利用するようです。
list, start, shutdown, console あたりを知っていれば、 最低限は使えそうです。

# xm start centos5

# xm list
Name                                      ID   Mem VCPUs      State   Time(s)
Domain-0                                   0   484     1     r-----    527.1
centos5                                    6   512     1     -b----     47.6

# xm console centos5
.....
CentOS release 5 (Final)
Kernel 2.6.18-53.el5xen on an i686

localhost.localdomain login:

CentOS の X を使う

一応、コンソールベースで使えるようになったのですが、 Xが使える方が便利です。 ということで、Xを使えるようにします。 Solaris Express では標準ではリモートからの接続できないように なっているので、変更する必要があります。

bash-3.2# svccfg -s x11-server listprop
options                                  application
options/default_depth                    integer  24
options/server                           astring  /usr/X11/bin/Xorg
options/server_args                      astring
options/stability                        astring  Evolving
options/value_authorization              astring  solaris.smf.manage.x11
options/tcp_listen                       boolean  false
.....

bash-3.2# svccfg -s x11-server setprop options/tcp_listen = true
svc:/application/x11/x11-server

後はXを再起動し、Solaris Express側で

# xhost + centos

としておき、CentOS側で

# export DISPLAY=solaris:0

としてやれば、xtermとかXアプリをSolaris Express上に表示できるようになります。
*** 上記の solaris, centos は 実際のホスト名もしくはIPアドレス

CentOSのgdmを使う(Xnest経由で)

ここまでやったのなら、ついでに CentOS のデスクトップを表示した方が 作業が楽になるだろうということで、ついでにそこまでやってしまいます。
デフォルトでは CentOS の gdm ではリモート接続不可になっているので、 接続できるようにする必要があります。 (XDMCP接続を有効にするというやつです。)
CentOS 5.1 では /etc/gdm/custom.conf を編集します。
赤い字の部分が無い場合は追加してください。
[security]項目のAllowRemoteRoot=trueは必須ではありません。 このオプションを入れることにより root でログインが出来るようになります。 今回はテスト作業を簡単にするために追加しています。

[daemon]
RemoteGreeter=/usr/libexec/gdmgreeter

[security]
AllowRemoteRoot=true

[xdmcp]
Enable=true

gdmの設定はこれで終わりです。 ファイアウォールを有効にしている場合は XDMCP (177 UDP) に 接続できるように設定を変更してください。
xen/xvmにインストールした CentOS はデフォルトでは コンソールモードになっており、gdm は起動していません。
runlevel コマンドで確認すると下のように runlevel 3 になっています。 (linux のグラフィカルユーザモードは runlevel 5)
/etc/inittab の id:3:initdefault: の 3 を 5 に変更しておけば、グラフィカルユーザモードがデフォルトになります (次回起動時以降)。

[root@localhost sbin]# runlevel
N 3

[root@localhost sbin]# cat /etc/inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, 
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#

# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

上記のようなことはしなくても init コマンドでグラフィカルユーザモードに移行することも可能です。

[root@localhost sbin]# ps -ef | grep gdm

[root@localhost sbin]# init 5
[root@localhost sbin]# Intel CPU マイクロコードアップデートを適用中: [失敗]
Starting monitoring for VG VolGroup00:   2 logical volume(s) in volume group "Vo
lGroup00" monitored
[  OK  ]
readahead をバックグランドで起動中: [  OK  ]
irqbalance を起動中: [  OK  ]
anacron を起動中: [  OK  ]
readahead をバックグランドで起動中: [  OK  ]

[root@localhost sbin]# ps -ef | grep gdm
root      2231     1  0 20:29 ?        00:00:00 /usr/sbin/gdm-binary -nodaemon
root      2260     1  0 20:29 ?        00:00:00 /usr/sbin/gdm-binary -nodaemon
root      2338  1968  0 20:30 xvc0     00:00:00 grep gdm

後は、

# Xnest :1 -query centos

という感じで Xnest コマンドを Solaris Express 側で実行すれば、 CentOS のログイン画面が表示されます。
下図は、そのスクリーンショットと KDE にログイン後の画面です。