OpenSUSE 12.3 checkpassword-pam 失效?!

從 OpenSUSE 12.2 升級至 OpenSUSE 12.3 後
不知為何原本正常的 Apache + NIS Authentication 居然
一直出現密碼錯誤無法登入

[Thu Apr 11 18:33:55 2013] [error] [client 192.168.103.1] AuthExtern checkpassword-pam [/usr/local/bin/checkpassword-pam -H --noenv --debug --stdout -s httpd -- /bin/true]: Failed (2) for user steve
[Thu Apr 11 18:33:55 2013] [error] [client 192.168.103.1] user steve: authentication failure for "/svn/": Password Mismatch

似乎是 checkpassword-pam 出了問題
重新下載 checkpassword source re-compile and re-install 也無效
大膽假設 checkpassword 在 OpenSUSE 12.3 有相容性問題 無法工作
無計可施的情況下,只好尋求其他的 Apache + NIS Authentication 的方案
最後找到另一個 solution : http://www.yolinux.com/TUTORIALS/LinuxTutorialApacheAddingLoginSiteProtection.html#NIS

Step.1 Install Perl Modules: ExtUtils-AutoInstall, Net-NIS, Apache2-AuthenNIS

$ perl -MCPAN -e shell 
  ... (Answer no)
install ExtUtils::AutoInstall
install Net::NIS
install Apache2::AuthenNIS
quit

Step.2 Test if perl modules installed correct

$ vi testApache2AuthenNIS.pl
#!/usr/bin/perl
BEGIN{push @INC, "/usr/lib/perl5/site_perl/5.16.2/Apache2";}
eval "use Apache2::AuthenNIS"; $hasApacheAuth = $@ ? 0 : 1;
printf "Apache2::AuthenNIS". ($hasApacheAuth ?  "" : " not") . " installed";
printf "n";
$ sudo perl testApache2AuthenNIS.pl
Apache2::AuthenNIS installed

Step.3 Modify subversion.conf

$ vi /etc/apache2/conf.d/subversion.conf
        <Location /svn/>
                DAV svn
                SVNParentPath /svn/repos
                SVNListParentPath on
                # Limit write permission to list of valid users.

                # Require SSL connection for password protection.
                # SSLRequireSSL

                AuthType Basic
                AuthName "Subversion Server"
                PerlAuthenHandler Apache2::AuthenNIS
                PerlSetVar AllowAlternateAuth no
                #AuthExternal checkpassword-pam
                #AuthBasicProvider external
                Require valid-user
                AuthzSVNAccessFile /svn/svnaccess.conf
        </Location>

Step.5 restart Apache2

Done!

OpenSUSE: 修復 GRUB

今日將兩台工作站從 OpenSUSE 12.2 升級至 12.3
不料其中一台在升級完成後卻無法開機
研判似乎是 GRUB 損毀了
動作:使用 OpenSUSE 12.3 Rescue CD 修復 GRUB

Step.1 Download OpenSUSE 12.3 Rescue CD ISO file and burn.

Step.2 Boot using rescue CD

Step.3 Check & active LVM

$ vgscan
$ vgchange -ay system    # system is my volume group name

Step.4 mount original OS

$ mount /dev/mapper/system-root /mnt
$ mount /dev/sda1 /mnt/boot
$ mount --bind /dev /mnt/dev
$ mount --bind /proc /mnt/proc

Step.5 chroot and rebuild GRUB

$ chroot /mnt
$ yast bootloader

Step.6 using yast-bootloader to rebuild GRUB

Step.7 reboot

Done!

OpenVPN and NAT

在公司用 OpenSuSE 架設了一個 OpenVPN Server
做好之後,發現從家裡除了 VPN Server 之外
其他與 VPN Server 同一網段的機器都連不上
後來發現,原來還需要設定 NAT!
首先編輯 NAT 設定擋

$ vi /root/openvpn_nat.sh
#! /bin/bash

# 清除所有規則
iptables -F
iptables -X
iptables -Z
iptables -t nat -F
iptables -t nat -X
iptables -t nat -Z
iptables -t mangle -F
iptables -t mangle -X
iptables -t mangle -Z

# 定義防火牆政策
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT

# 讓 OpenVPN 能進去 LAN
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -s 10.8.0.0/24 -j MASQUERADE

測試OK,其他的機器都可以連上了!
接下來更改設定擋,以後不需要在手動啟動了

$ vi /etc/init.d/boot.local
# NAT for OpenVPN
/root/openvpn_nat.sh

重新開機後,測試OK!
搞定,收工!

安裝 SystemC and TLM on OpenSuSE 12.1 (64-bit Linux)

Setup Environment Variable
edit .cshrc by adding:

setenv SYSTEMC_HOME /opt/systemc/systemc-2.2.0
setenv TLM_HOME     /opt/systemc/TLM-2009-07-15

Install SystemC-2.2.0

照例,要先修改 ./systemc-2.2.0/src/sysc/utils/sc_utils_ids.cpp
加上下列兩行

#include "string.h"
#include "cstdlib"

開始編譯

% cd systemc-2.2.0
% mkdir objdir
% cd objdir
% ../configure --prefix=/opt/systemc/systemc-2.2.0
% make

嗯,跟之前安裝時不一樣,這次跑出來以下錯誤訊息:

../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:716:16: error: reference ‘m_obj’ cannot be declared ‘mutable’ [-fpermissive]
../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:1193:18: error: reference ‘m_left’ cannot be declared ‘mutable’ [-fpermissive]
../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:1194:18: error: reference ‘m_right’ cannot be declared ‘mutable’ [-fpermissive]
../../../../systemc-2.2.0/src/sysc/datatypes/bit/sc_bit_proxies.h:1196:18: error: reference ‘m_refs’ cannot be declared ‘mutable’ [-fpermissive]

Google 一下之後,找到解法,將 src/sysc/datatypes/bit/sc_bit_proxies.h 中的 mutable 都去除
重新 compile

% ../configure --prefix=/opt/systemc/systemc-2.2.0
% make
% sudo make install

最後可以做一下測試

$ make check

Install TLM-2.0.1
Step.1 將 TLM-2.0.1 解到 /opt/systemc/systemc-2.2.0

sudo tar -C /opt/systemc -zxvf ~/work/SystemC/SystemC.org/download/TLM-2.0.1.tgz

Spte.2 修改 systemc-2.2.0/include/sysc/packages/boost/bind/placeholders.hpp

LINE.28 #if defined(__BORLANDC__) || defined(__GNUC__)

Spte.3 修改 systemc-2.2.0/include/sysc/datatypes/bit/sc_lv_base.h

LINE.309     return sc_logic_value_t( (m_data[wi] >> bi & SC_DIGIT_ONE) |
LINE.310                              (m_ctrl[wi] >> bi << 1 & SC_DIGIT_TWO) );

Run TLM-2.0.1 examples
Step.1 修改 TLM-2009-07-15/examples/tlm/build-unix/Makefile.config

LINE.2  DEFAULT_TARGET_ARCH  = linux64

Step.2 執行 examples

% cd TLM-2009-07-15/examples/tlm/build-unix
% make
% make run

Run TLM-2.0.1 unit_test
Step.1 修改 TLM-2009-07-15/unit_test/tlm/build-unix/Makefile.config

LINE.2  DEFAULT_TARGET_ARCH  = linux64

Step.2 執行 examples

$ cd TLM-2009-07-15/unit_test/tlm/build-unix
$ make
$ make run

Oh no! Something has gone wrong.

今天發現 OpenSuSE 12.1 有一些更新,其中包含 Nvidia Driver 的更新
做完更新,重新開機後,發現無法 login 進 GNOME 了
會出現 : “Oh no! Something has gone wrong.” 並要求 logout 的訊息
做了很多嘗試後發現:

1. 重新安裝 GNOME 沒用
2. NIS Account 才會有這問題
3. Local Account and root 不會有這問題

後來查 ~/.xsession-errors 發現

NVIDIA: could not open the device file /dev/nvidiactl (Permission denied).

檢查 Nvidia Driver 的屬性發現

crw-rw---- 1 root video 195,   0  2月  1 15:42 /dev/nvidia0
crw-rw---- 1 root video 195, 255  2月  1 15:42 /dev/nvidiactl

嗯,只有 root 以及 video group 的 account 才能使用 Nvidia Driver
難怪 NIS account 無法使用
既然如此,就用最簡單的方法:改變 driver 的屬性

% chmod 0666 /dev/nvidia*

結果:沒用!Nvidia Driver 的屬性 又自動變回來了,真是奇怪!

換另外一招,手動編輯 /etc/group ,將NIS Account 都加進 video group 裡

% vi /etc/group 
...
video:x:33:xxx,...,NIS_Users...
...

結果:OK! yes!
搞定,收工….

OpenSuSE 11.1 上的 TCL Library

閒閒沒事
把之前在 Mac OS 上 跑的 NAND Flash Static Wear Leveling 的 EV程式
拿到 SuSE 上跑,結果居然 Compile 不起來
發現是 “-ltcl” 無法 link 到 正確的 TCL Library
若將之改為 “-ltcl8.5” 就 OK

好像是 TCL Library 在 Install 時有問題
自己動手修正:

$ (cd /usr/lib; sudo ln -s libtcl8.5.o libtcl.o)
$ (cd /usr/lib64; sudo ln -s libtcl8.5.o libtcl.o)

這樣 “-ltcl” 就 OK 了。