sudo安装错误/usr/bin/ld: cannot find -lpam

centos 5.1版本为
引用
[root@rztest sudo-1.7.2p6]# uname -a
Linux rztest 2.6.18-53.el5 #1 SMP Mon Nov 12 02:22:48 EST 2007 i686 i686 i386 GNU/Linux


sudo编译包版本为sudo-1.7.2p6
报如下错误
引用
#make install
...
gcc -c -I. -I.  -O2 -D_GNU_SOURCE -D_PATH_SUDOERS=\"/etc/sudoers\" -DSUDOERS_UID=0 -DSUDOERS_GID=0 -DSUDOERS_MODE=0440  ./closefrom.c
gcc -o sudo gram.o alias.o alloc.o defaults.o error.o list.o match.o toke.o redblack.o zero_bytes.o  sudo_auth.o passwd.o  audit.o check.o env.o getspwuid.o gettime.o goodpath.o fileops.o find_path.o interfaces.o lbuf.o logging.o parse.o pwutil.o set_perms.o sudo.o sudo_edit.o sudo_nss.o term.o tgetpass.o strlcpy.o strlcat.o closefrom.o  -lpam -ldl -lcrypt    
/usr/bin/ld: cannot find -lpam
collect2: ld returned 1 exit status
make: *** [sudo] Error 1


同时比较make正确时的日志:
引用
gcc -c -I. -I.  -O2 -D_GNU_SOURCE -D_PATH_SUDOERS=\"/etc/sudoers\" -DSUDOERS_UID=0 -DSUDOERS_GID=0 -DSUDOERS_MODE=0440  ./closefrom.c
gcc -o sudo gram.o alias.o alloc.o defaults.o error.o list.o match.o toke.o redblack.o zero_bytes.o  sudo_auth.o pam.o  audit.o check.o env.o getspwuid.o gettime.o goodpath.o fileops.o find_path.o interfaces.o lbuf.o logging.o parse.o pwutil.o set_perms.o sudo.o sudo_edit.o sudo_nss.o term.o tgetpass.o strlcpy.o strlcat.o closefrom.o  -lpam -ldl   
gcc -c -I. -I.  -O2 -D_GNU_SOURCE -D_PATH_SUDOERS=\"/etc/sudoers\" -DSUDOERS_UID=0 -DSUDOERS_GID=0 -DSUDOERS_MODE=0440  ./visudo.c
gcc -o visudo gram.o alias.o alloc.o defaults.o error.o list.o match.o toke.o redblack.o zero_bytes.o  visudo.o fileops.o gettime.o goodpath.o find_path.o pwutil.o strlcpy.o strlcat.o closefrom.o  
/bin/sh ./libtool --mode=compile gcc -c -I. -I.  -O2 -D_GNU_SOURCE -D_PATH_SUDOERS=\"/etc/sudoers\" -DSUDOERS_UID=0 -DSUDOERS_GID=0 -DSUDOERS_MODE=0440  ./sudo_noexec.c
mkdir .libs
gcc -c -I. -I. -O2 -D_GNU_SOURCE -D_PATH_SUDOERS=\"/etc/sudoers\" -DSUDOERS_UID=0 -DSUDOERS_GID=0 -DSUDOERS_MODE=0440 ./sudo_noexec.c  -fPIC -DPIC -o .libs/sudo_noexec.o
/bin/sh ./libtool --mode=link gcc  -o sudo_noexec.la sudo_noexec.lo -avoid-version -rpath /usr/local/libexec
gcc -shared  .libs/sudo_noexec.o   -Wl,-soname -Wl,sudo_noexec.so -o .libs/sudo_noexec.so
creating sudo_noexec.la
(cd .libs && rm -f sudo_noexec.la && ln -s ../sudo_noexec.la sudo_noexec.la)


其中/usr/bin/ld: cannot find -lpam引起了我的注意,根据经验系统中很可能少包,网上搜索也没有很好的解决方法。
进一步比较两者之间的configure日志
引用
checking for main in -ldl... yes
checking security/pam_appl.h usability... no
checking security/pam_appl.h presence... no
checking for security/pam_appl.h... no
checking pam/pam_appl.h usability... no
checking pam/pam_appl.h presence... no
checking for pam/pam_appl.h... no
checking for library containing crypt... -lcrypt
checking for getspnam... yes
checking for log file location... /var/log/sudo.log
checking for timestamp file location... /var/run/sudo
configure: using the following authentication methods: passwd
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sudo.man
config.status: creating visudo.man
config.status: creating sudoers.man
config.status: creating sudoers.ldap.man
config.status: creating sudo_usage.h
config.status: creating config.h
config.status: creating pathnames.h

从以上可以看出利用 passwd验证,而make正确得系统采用pam认证。
引用
checking for main in -ldl... yes
checking security/pam_appl.h usability... yes
checking security/pam_appl.h presence... yes
checking for security/pam_appl.h... yes
checking whether to use PAM session support... yes
checking for log file location... /var/log/sudo.log
checking for timestamp file location... /var/run/sudo
configure: using the following authentication methods: pam
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sudo.man
config.status: creating visudo.man
config.status: creating sudoers.man
config.status: creating sudoers.ldap.man
config.status: creating sudo_usage.h
config.status: creating config.h
config.status: creating pathnames.h
configure: You will need to customize sample.pam and install it as /etc/pam.d/sudo

到这里,可以比较明显的看出系统很可能缺少pam包,比较系统间的rpm包,可以明显看到,能正确安装的系统多出了pam-devel-0.99.6.2-3.26.el5。
引用
[root@mcprod ~/sudo-1.7.2p6]# rpm -qa | grep pam
pam_smb-1.1.7-7.2.1
pam_passwdqc-1.0.2-1.2.2
pam-0.99.6.2-3.26.el5
spamassassin-3.1.9-1.el5
pam_ccreds-3-5
pam_pkcs11-0.5.3-23
pam-devel-0.99.6.2-3.26.el5
pam_krb5-2.2.14-1


引用
[root@rztest sudo-1.7.2p6]# rpm -qa|grep pam
pam_smb-1.1.7-7.2.1
pam_krb5-2.2.14-1
pam_passwdqc-1.0.2-1.2.2
pam-0.99.6.2-3.26.el5
spamassassin-3.1.9-1.el5
pam_pkcs11-0.5.3-23
pam_ccreds-3-5


安装pam-devel rpm包
引用
[root@rztest sudo-1.7.2p6]# yum install pam-devel
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for pam-devel to pack into transaction set.
pam-devel-0.99.6.2-6.el5_ 100% |=========================|  60 kB    00:00    
---> Package pam-devel.i386 0:0.99.6.2-6.el5_4.1 set to be updated
--> Running transaction check
--> Processing Dependency: pam = 0.99.6.2-6.el5_4.1 for package: pam-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for pam to pack into transaction set.
pam-0.99.6.2-6.el5_4.1.i3 100% |=========================|  87 kB    00:01    
---> Package pam.i386 0:0.99.6.2-6.el5_4.1 set to be updated
--> Running transaction check
--> Processing Dependency: audit-libs >= 1.6.5 for package: pam
--> Processing Dependency: glibc > 2.5-19 for package: pam
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for audit-libs to pack into transaction set.
audit-libs-1.7.13-2.el5.i 100% |=========================|  16 kB    00:01    
---> Package audit-libs.i386 0:1.7.13-2.el5 set to be updated
---> Downloading header for glibc to pack into transaction set.
glibc-2.5-42.el5_4.3.i686 100% |=========================| 150 kB    00:09    
---> Package glibc.i686 0:2.5-42.el5_4.3 set to be updated
--> Running transaction check
--> Processing Dependency: glibc = 2.5-18 for package: glibc-headers
--> Processing Dependency: audit-libs = 1.5.5-7.el5 for package: audit
--> Processing Dependency: audit-libs = 1.5.5-7.el5 for package: audit-libs-python
--> Processing Dependency: glibc-common = 2.5-42.el5_4.3 for package: glibc
--> Processing Dependency: glibc = 2.5-18 for package: glibc-devel
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for glibc-headers to pack into transaction set.
glibc-headers-2.5-42.el5_ 100% |=========================| 148 kB    00:04    
---> Package glibc-headers.i386 0:2.5-42.el5_4.3 set to be updated
---> Downloading header for audit to pack into transaction set.
audit-1.7.13-2.el5.i386.r 100% |=========================|  21 kB    00:01    
---> Package audit.i386 0:1.7.13-2.el5 set to be updated
---> Downloading header for glibc-devel to pack into transaction set.
glibc-devel-2.5-42.el5_4. 100% |=========================| 115 kB    00:01    
---> Package glibc-devel.i386 0:2.5-42.el5_4.3 set to be updated
---> Downloading header for audit-libs-python to pack into transaction set.
audit-libs-python-1.7.13- 100% |=========================|  15 kB    00:00    
---> Package audit-libs-python.i386 0:1.7.13-2.el5 set to be updated
---> Downloading header for glibc-common to pack into transaction set.
glibc-common-2.5-42.el5_4 100% |=========================| 729 kB    08:58    
---> Package glibc-common.i386 0:2.5-42.el5_4.3 set to be updated
--> Running transaction check

Dependencies Resolved

=============================================================================
Package                 Arch       Version          Repository        Size
=============================================================================
Installing:
pam-devel               i386       0.99.6.2-6.el5_4.1  updates           187 k
Updating for dependencies:
audit                   i386       1.7.13-2.el5     base              379 k
audit-libs              i386       1.7.13-2.el5     base               80 k
audit-libs-python       i386       1.7.13-2.el5     base               78 k
glibc                   i686       2.5-42.el5_4.3   updates           5.2 M
glibc-common            i386       2.5-42.el5_4.3   updates            16 M
glibc-devel             i386       2.5-42.el5_4.3   updates           2.0 M
glibc-headers           i386       2.5-42.el5_4.3   updates           601 k
pam                     i386       0.99.6.2-6.el5_4.1  updates           976 k

Transaction Summary
=============================================================================
Install      1 Package(s)        
Update       8 Package(s)        
Remove       0 Package(s)        

Total download size: 26 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): glibc-2.5-42.el5_4 100% |=========================| 5.2 MB    00:29    
(2/9): glibc-headers-2.5- 100% |=========================| 601 kB    00:03    
(3/9): audit-1.7.13-2.el5 100% |=========================| 379 kB    01:02    
(4/9): glibc-devel-2.5-42 100% |=========================| 2.0 MB    00:11    
(5/9): audit-libs-python- 100% |=========================|  78 kB    00:03    
(6/9): glibc-common-2.5-4 100% |=========================|  16 MB    01:24    
(7/9): audit-libs-1.7.13- 100% |=========================|  80 kB    00:03    
(8/9): pam-devel-0.99.6.2 100% |=========================| 187 kB    00:02    
(9/9): pam-0.99.6.2-6.el5 100% |=========================| 976 kB    00:04    
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating  : glibc-common                 ####################### [ 1/17]
  Updating  : glibc                        ####################### [ 2/17]
  Updating  : audit-libs                   ####################### [ 3/17]
  Updating  : pam                                                  [ 4/17]warning: /etc/pam.d/system-auth created as /etc/pam.d/system-auth.rpmnew
  Updating  : pam                          ####################### [ 4/17]
  Updating  : glibc-headers                ####################### [ 5/17]
  Updating  : audit                        ####################### [ 6/17]
  Updating  : glibc-devel                  ####################### [ 7/17]
  Updating  : audit-libs-python            ####################### [ 8/17]
  Installing: pam-devel                    ####################### [ 9/17]
  Cleanup   : glibc                        ####################### [10/17]
  Cleanup   : glibc-headers                ####################### [11/17]
  Cleanup   : audit                        ####################### [12/17]
  Cleanup   : glibc-devel                  ####################### [13/17]
  Cleanup   : audit-libs-python            ####################### [14/17]
  Cleanup   : glibc-common                 ####################### [15/17]
  Cleanup   : audit-libs                   ####################### [16/17]
  Cleanup   : pam                          ####################### [17/17]

Installed: pam-devel.i386 0:0.99.6.2-6.el5_4.1
Dependency Updated: audit.i386 0:1.7.13-2.el5 audit-libs.i386 0:1.7.13-2.el5 audit-libs-python.i386 0:1.7.13-2.el5 glibc.i686 0:2.5-42.el5_4.3 glibc-common.i386 0:2.5-42.el5_4.3 glibc-devel.i386 0:2.5-42.el5_4.3 glibc-headers.i386 0:2.5-42.el5_4.3 pam.i386 0:0.99.6.2-6.el5_4.1
Complete!


附:
插入式验证模块(Pluggable Authentication Module,PAM)API 将公开一组功能,应用程序程序员可以使用这些功能来实现与安全性相关的功能,例如用户验证、数据加密、LDAP 等。
哪些操作系统支持 PAM?
PAM 最初是由 Sun Microsystems 于 1995 年开发的,并且以下操作系统版本(及更高版本)都提供支持:

    * RedHat 5.0
    * SUSE 6.2
    * Debian 2.2
    * Mandrake 5.2
    * Caldera 1.3
    * TurboLinux 3.6

详见 http://www.ibm.com/developerworks/cn/linux/l-pam/index.html






你可能感兴趣的:(c,linux,python,gcc,Security)