CentOS-5.2上使用源碼安裝SystemTap-1.1遇到的問題及解決辦法
使用源碼編譯安裝 SystemTap 的步驟見文章:
【SystemTap
】 Linux下安裝使用SystemTap
源碼安裝SystemTap
文章中是在 CentOS-5.4 中編譯安裝 SystemTap,之前一直沒有發現,原來新版本的SystemTap(1.1)需要相關包的支援,
例如我在 CentOS-5.2 中編譯安裝 SystemTap時出現了如下錯誤,經過查閱資料,這個錯誤是由於 nss 包比較老的緣故,
下面對錯誤進行分析,並且給出解決辦法。
[root@hdfs03 systemtap-1.1]# make
/bin/sh ./git_version.sh -k -s . -o git_version.h
git_version.sh: Not a git repo, keeping existing git_version.h
make all-recursive
make[1]: Entering directory `/local/zkl/SystemTap/systemtap-1.1'
Making all in doc
make[2]: Entering directory `/local/zkl/SystemTap/systemtap-1.1/doc'
Making all in SystemTap_Tapset_Reference
make[3]: Entering directory `/local/zkl/SystemTap/systemtap-1.1/doc/SystemTap_Tapset_Reference'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1/doc/SystemTap_Tapset_Reference'
Making all in beginners
make[3]: Entering directory `/local/zkl/SystemTap/systemtap-1.1/doc/beginners'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1/doc/beginners'
make[3]: Entering directory `/local/zkl/SystemTap/systemtap-1.1/doc'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1/doc'
make[2]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1/doc'
Making all in grapher
make[2]: Entering directory `/local/zkl/SystemTap/systemtap-1.1/grapher'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1/grapher'
make[2]: Entering directory `/local/zkl/SystemTap/systemtap-1.1'
CC staprun-nsscommon.o
In file included from nsscommon.c:59:
stapsslerr.h: In function ‘nssError’:
stapsslerr.h:312: error: ‘SEC_ERROR_PKCS11_GENERAL_ERROR’ undeclared (first use in this function)
stapsslerr.h:312: error: (Each undeclared identifier is reported only once
stapsslerr.h:312: error: for each function it appears in.)
stapsslerr.h:313: error: ‘SEC_ERROR_PKCS11_FUNCTION_FAILED’ undeclared (first use in this function)
stapsslerr.h:314: error: ‘SEC_ERROR_PKCS11_DEVICE_ERROR’ undeclared (first use in this function)
make[2]: *** [staprun-nsscommon.o] Error 1
make[2]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/local/zkl/SystemTap/systemtap-1.1'
make: *** [all] Error 2
編譯出現的錯誤出現在 nsscommon.c 檔案中的 nssError 函數的第 59 行,該行是“#include "stapsslerr.h"”,進一
步的錯誤是 stapsslerr.h 檔案的312~314行,錯誤是找不到這樣三個宏SEC_ERROR_PKCS11_GENERAL_ERROR、
SEC_ERROR_PKCS11_FUNCTION_FAILED、SEC_ERROR_PKCS11_DEVICE_ERROR。繼續看 nsscommon.c 檔案,發現引入了這樣幾
個標頭檔:
23 #include <nss.h>
24 #include <nspr.h>
25 #include <prerror.h>
26 #include <secerr.h>
27 #include <sslerr.h>
這些標頭檔是 nss 和 nspr 的相關標頭檔,初步判斷是三個宏SEC_ERROR_PKCS11_GENERAL_ERROR、
SEC_ERROR_PKCS11_FUNCTION_FAILED、SEC_ERROR_PKCS11_DEVICE_ERROR應該在這些標頭檔中定義,於是寫兩個 shell 腳
本判斷出現在哪個標頭檔當中:
test.sh:
locate nss.h
locate nspr.h
locate sslerr.h
locate secerr.h
locate prerror.h
test2.sh:
./test.sh | xargs grep SEC_ERROR_PKCS11_GENERAL_ERROR
./test.sh | xargs grep SEC_ERROR_PKCS11_FUNCTION_FAILED
./test.sh | xargs grep SEC_ERROR_PKCS11_DEVICE_ERROR
執行 test2.sh 指令碼,查看結果,發現沒有查詢到這三個宏,於是在一台正常的節點上(這台節點也是CentOS-5.2,但是
SystemTap安裝正常,可能是之前使用該節點的人安裝的,不清楚為什麼安裝成功)執行這兩個指令碼,發現得到這樣的結果
:
[root@glnode05 local]# ./test2.sh
/usr/include/nss3/secerr.h:SEC_ERROR_PKCS11_GENERAL_ERROR = (SEC_ERROR_BASE + 167),
/usr/include/nss3/secerr.h:SEC_ERROR_PKCS11_FUNCTION_FAILED = (SEC_ERROR_BASE + 168),
/usr/include/nss3/secerr.h:SEC_ERROR_PKCS11_DEVICE_ERROR = (SEC_ERROR_BASE + 169),
說明這三個宏是在標頭檔 secerr.h 中定義的,而當前節點上的標頭檔 secerr.h 中卻沒有定義這三個宏,說明是標頭檔
版本不同所導致的,因此查看正常節點上的 nss 版本:
[root@glnode05 local]# rpm -q nss
nss-3.12.3.99.3-1.el5.centos.2
[root@glnode05 local]# rpm -q nss-devel
nss-devel-3.12.3.99.3-1.el5.centos.2
再回來查看當前節點上 nss 的版本:
[root@hdfs03 systemtap-1.1]# rpm -q nss
nss-3.11.99.5-2.el5.centos
[root@hdfs03 systemtap-1.1]# rpm -q nss-devel
nss-devel-3.11.99.5-2.el5.centos
發現 nss 的版本的確不一樣,繼續分析,發現當前節點上 nss 是 CentOS-5.2 預設安裝的版本 nss-3.11.99.5-
2.el5.centos ,而正常節點上的 nss-3.12.3.99.3-1.el5.centos.2 是 CentOS-5.4 中的nss版本。因此,解決方案應該
是:卸載當前節點上的 nss 和 nss-devel 包,下載 CentOS-5.4 的nss 和 nss-devel 包並進行安裝,做如下操作:
卸載當前節點上的 nss 和 nss-devel 包
[root@hdfs03 SystemTap]# rpm -e nss
error: "nss" specifies multiple packages
出現該錯誤是因為存在多個 nss 包,一個是 i386 的,一個是 x86-64的,使用 --allmatches 可以卸載這兩個。
[root@hdfs03 nss]# rpm -e --allmatches nss-3.11.99.5-2.el5.centos
error: Failed dependencies:
提示依賴錯誤,可以使用 --nodeps 選項忽略依賴
[root@hdfs03 nss]# rpm -e --allmatches --nodeps nss-3.11.99.5-2.el5.centos
這樣便可以卸載掉 nss 包
[root@hdfs03 nss]# rpm -e nss-devel --nodeps
卸載完畢,安裝CentOS-5.4 的nss 和 nss-devel 包
[root@hdfs03 SystemTap]# rpm -ivh nss-3.12.3.99.3-1.el5.centos.2.x86_64.rpm
[root@hdfs03 SystemTap]# rpm -ivh nss-devel-3.12.3.99.3-1.el5.centos.2.x86_64.rpm
安裝完畢,在當前節點上執行shell指令碼檢測標頭檔 secerr.h,
[root@hdfs03 local]# ./test2.sh
/usr/include/nss3/secerr.h:SEC_ERROR_PKCS11_GENERAL_ERROR = (SEC_ERROR_BASE + 167),
/usr/include/nss3/secerr.h:SEC_ERROR_PKCS11_FUNCTION_FAILED = (SEC_ERROR_BASE + 168),
/usr/include/nss3/secerr.h:SEC_ERROR_PKCS11_DEVICE_ERROR = (SEC_ERROR_BASE + 169),
正常檢測到這三個宏,繼續編譯安裝 SystemTap, 安裝成功。
受啟發參考資料:
http://groups.google.com/group/mozilla.dev.tech.crypto/browse_thread/thread/e50c490239e867a0