首页 | 站长技术 专题 | 下载频道 | 网页模板 | 图片素材 | 虚拟主机 | 项目市场 | 源码市场 | 本站产品 | 广告服务 | 建站论坛
文档首页
建站指南
网站编程
网站设计
图像动画
网络安全
服务器技术
数据库技术
技术专题
技术问答
您的位置:中国建站 > 站长技术 > 服务器技术 > Ftp服务器 > VSFTP+MySQL虚拟用户配置

VSFTP+MySQL虚拟用户配置

作者: 来源:ChinaUnix.net 加入时间:2006-07-26
VSFTPD是一种在UNIX/Linux中非常安全且快速的FTP服务器,目前已经被许多大型站点所采用。VSFTPD支持将用户名和口令保存在数据库文件或数据库服务器中。VSFTPD称这种形式的用户为虚拟用户。相对于FTP的本地(系统)用户来说,虚拟用户只是FTP服务器的专有用户,虚拟用户只能访问FTP服务器所提供的资源,这大大增强系统本身的安全性。相对于匿名用户而言,虚拟用户需要用户名和密码才能获取FTP服务器中的文件,增加了对用户和下载的可管理性。对于需要提供下载服务,但又不希望所有人都可以匿名下载;既需要对下载用户进行管理,又考虑到主机安全和管理方便的FTP站点来说,虚拟用户是一种极好的解决方案。本文介绍在RedHat Linux 9上如何将VSFTPD的虚拟用户名和密码保存在MySQL数据库服务器中。 

  一、VSFTPD的安装 

  目前,VSFTPD的最新版本是1.2.0版。官方下载地址为ftp://vsftpd.beasts.org/users/cevans/vsftpd-1.2.0.tar.gz。在安装前,需要先做以下准备工作: 

  VSFTPD默认配置中需要“nobody”用户。在系统中添加此用户,如果用户已经存在,useradd命令有相应提示。 
  [root@hpe45 root]# useradd nobody 
  useradd: user nobody exists 

  VSFTPD默认配置中需要“/usr/share/empty”目录。在系统中此目录,如果目录已经存在,mkdir命令有相应提示。 
  [root@hpe45 root]# mkdir /usr/share/empty/ 
  mkdir: cannot create directory '/usr/share/empty': File exists 

  VSFTPD提供匿名FTP服务时,需要“ftp”用户和一个有效的匿名目录。 
  [root@hpe45 root]# mkdir /var/ftp/ 
  [root@hpe45 root]# useradd -d /var/ftp ftp 
  接下来的操作对于ftp用户是否已经存在都是有用的。 
  [root@hpe45 root]# chown root.root /var/ftp 
  [root@hpe45 root]# chmod og-w /var/ftp 

  以上准备工作完成后,我们就可以开始编译源代码了。假定我们下载的vsftpd-1.2.0.tar.gz在/root目录,执行以下命令: 
  [root@hpe45 root]# tar zxvf vsftpd-1.2.0.tar.gz 
  [root@hpe45 root]# cd vsftpd-1.2.0 
  [root@hpe45 vsftpd-1.2.0]# make 
  [root@hpe45 vsftpd-1.2.0]# make install 

  上面的“make install”命令将编译好的二进制文件、手册等复制到相应目录。在RHL9上,可能需要手动执行以下复制: 
  [root@hpe45 vsftpd-1.2.0]# cp vsftpd /usr/local/sbin/vsftpd 
  [root@hpe45 vsftpd-1.2.0]# cp vsftpd.conf.5 /usr/local/share/man/man5 
  [root@hpe45 vsftpd-1.2.0]# cp vsftpd.8 /usr/local/share/man/man8 

  接下来,我们复制一个简单的配置文件作为基础供后面修改。 
  [root@hpe45 vsftpd-1.2.0]# cp vsftpd.conf /etc 
  [root@hpe45 vsftpd-1.2.0]# cp RedHat/vsftpd.pam /etc/pam.d/ftp 
  复制PAM验证文件,以允许本地用户登录VSFTPD。 
  [root@hpe45 vsftpd-1.2.0]# cp RedHat/vsftpd.pam /etc/pam.d/ftp 

  二、创建guest用户 

  VSFTPD采用PAM方式验证虚拟用户。由于虚拟用户的用户名/口令被单独保存,因此在验证时,VSFTPD需要用一个系统用户的身份来读取数据库文件或数据库服务器以完成验证,这就是VSFTPD的guest用户。这正如同匿名用户也需要有一个系统用户ftp一样。当然,我们也可以把guest用户看成是虚拟用户在系统中的代表。下面在系统中添加vsftpdguest用户,作为VSFTPD的guest。 
  [root@hpe45 vsftpd-1.2.0]# useradd vsftpdguest 
  当虚拟用户登录后,所在的位置为vsftpdguest的自家目录/home/vsftpdguest。如果要让虚拟用户登录到/var/ftp等其他目录,修改vsftpdguest的自家目录即可。 

  三、设置VSFTPD配置文件 

  在/etc/vsftpd.conf文件中,加入以下选项: 
  guest_enable=YES 
  guest_username=vsftpdguest 

  然后执行以下命令,让VSFTPD在后台运行: 
  [root@hpe45 vsftpd-1.2.0]# /usr/local/sbin/vsftpd & 

  四、将虚拟用户保存在MySQL数据库服务器中 

  我们建立数据库vsftpdvu,表users,字段name和passwd用于保存虚拟用户的用户名和口令,同时增加两个虚拟用户xiaotong和xiaowang。 

  [root@hpe45 vsftpd-1.2.0]# mysql -p 
  mysql>create database vsftpdvu; 
  mysql>use vsftpdvu; 
  mysql>create table users(name char(16) binary,passwd char(16) binary); 
  mysql>insert into users (name,passwd) values ('xiaotong',password('qqmywife')); 
  mysql>insert into users (name,passwd) values ('xiaowang',password('ttmywife')); 
  mysql>quit 

  然后,授权vsftpdguest可以读vsftpdvu数据库的users表。执行以下命令: 
  [root@hpe45 vsftpd-1.2.0]# mysql -u root mysql -p 
  mysql>grant select on vsftpdvu.users to vsftpdguest@localhost identified by 'i52serial0'; 
  mysql>quit 

  如果要验证刚才的操作是否成功可以执行下面命令: 
  [root@hpe45 vsftpd]#mysql -u vsftpdguest -pi52serial0 vsftpdvu 
  mysql>select * from users; 
  如果成功,将会列出xiaotong、xiaowang和加密后的密码 

  五、设置MySQL的PAM验证 

  这里我们要用到一个利用mysql进行pam验证的开源项目(http://sourceforge.net/projects/pam-mysql/)。首先从网站下载它的程序包pam_myql-0.5.tar.gz,复制到/root目录中。在编译安装之前,要确保mysql-devel的RPM包已经安装在你的机器上,如果没有请从RHL安装光盘中安装该包。然后,执行以下命令: 
  [root@hpe45 root]#tar xvzf pam_mysql-0.5.tar.gz 
  [root@hpe45 root]#cd pam_mysql 
  [root@hpe45 pam_mysql]#make 
  [root@hpe45 pam_mysql]#make install 
  make install这一步可能会出现错误,那只好手动将该目录下生成的pam_mysql.o复制到/lib/security目录下。 
  接下来,我们要设置vsftpd的PAM验证文件。打开/etc/pam.d/ftp文件,加入以下内容: 
  auth required pam_mysql.o user=vsftpdguest passwd=i52serial0 host=localhost db=vsftpdvu table=users usercolumn=name passwdcolumn=passwd crypt=2 
  account required pam_mysql.o user=vsftpdguest passwd=i52serial0 host=localhost db=vsftpdvu table=users usercolumn=name passwdcolumn=passwd crypt=2 
  上面涉及到的参数,只要对应前面数据库的设置就可以明白它们的含义。这里需要说明的是crypt参数。crypt表示口令字段中口令的加密方式:crypt=0,口令以明文方式(不加密)保存在数据库中;crypt=1,口令使用UNIX系统的DES加密方式加密后保存在数据库中;crypt=2,口令经过MySQL的password()函数加密后保存。 

  六、进一步的虚拟用户设置 

  经过以上的步骤,虚拟用户就可以正常使用了。这里介绍进一步的虚拟用户设置。首先,介绍虚拟用户的权限设置。 

  VSFTPD-1.2.0新添了virtual_use_local_privs参数,当该参数激活(YES)时,虚拟用户使用与本地用户相同的权限。当此参数关闭(NO)时,虚拟用户使用与匿名用户相同的权限,这也就是VSFTPD-1.2.0之前版本对虚拟用户权限的处理方法。这两者种做法相比,后者更加严格一些,特别是在有写访问的情形下。默认情况下此参数是关闭的(NO)。 
  当virtual_use_local_privs=YES时,只需设置write_enable=YES,虚拟用户就可以就拥有写权限。而virtual_use_local_privs=NO时,对虚拟用户权限的设置就更多一些更严格一些。 
  控制虚拟用户浏览目录:如果让用户不能浏览目录,但仍可以对文件操作,那么需要执行以下二个步骤:一,配置文件中,anon_world_readable_only=YES。二,虚拟用户目录的权限改为只能由vsftpdguest操作: 
  [root@hpe45 root]# chown vsftpdguest.vsftpdguest /home/vsftpdguest 
  [root@hpe45 root]# chmod 700 /home/vsftpdguest 
  允许虚拟用户上传文件: 
  write_enable=YES 
  anon_upload_enable=YES 
  允许虚拟用户修改文件名和删除文件: 
  anon_other_write_enable=YES 
  由于以上选项的设置同样会对匿名用户生效。如果不想匿名用户趁机拥有同样的权限,最好是禁止匿名用户登录。 

  其次,由于虚拟用户在系统中是vsftpdguest身份,所以可以访问到系统的其他目录。为了更加安全,我们可以将虚拟用户限制在自家目录下。有两种做法:一,在配置文件中增加以下选项 
  chroot_local_user=NO 
  chroot_list_enable=YES 
  chroot_list_file=/etc/vsftpd.chroot_list 
  然后,在/etc/vsftpd.chroot_list文件中加入虚拟用户名xiaotong和xiaowang。 
  第二种做法,在配置文件中修改chroot_local_user=YES。 
  经过修改后,虚拟用户登录后其根目录就限制在/home/vsftpdguest下,无法访问其他目录。 

  七、虚拟用户的个人目录 

  大家可以发现,无论是哪个虚拟用户,登录后所在的目录都是/home/vsftpdguest,即都是guest_username用户的自家目录。下面,介绍如何为每个虚拟用户建立自家目录。首先,在主配置文件中加入以下选项: 
  user_config_dir=/etc/vsftpd/vsftpd_user_conf 
  然后,生成/etc/vsftpd/vsftpd_user_conf目录,并在该目录下建立与特定虚拟用户同名的文件: 
  [root@hpe45 root]# mkdir /etc/vsftpd/vsftpd_user_conf 
  [root@hpe45 root]# cd /etc/vsftpd/vsftpd_user_conf 
  [root@hpe45 vsftpd_user_conf]# touch xiaowang 
  以上的操作为虚拟用户xiaowang建立了个人配置文件/etc/vsftpd/vsftpd_user_conf/xiaowang。接下来,在xiaowang的个人配置文件中将xiaowang的自家目录修改为/home/xiaowang,配置选项为: 
  local_root=/home/xiaowang 
  然后,新建xiaowang目录,并将权限设为vsftpdguest: 
  [root@hpe45 vsftpd_user_conf]# mkdir /home/xiaowang 
  [root@hpe45 vsftpd_user_conf]# chown vsftpdguest.vsftpdguest ./xiaowang 
  [root@hpe45 vsftpd_user_conf]# chmod 600 /home/xiaowang 
  经过以上设置,xiaowang登录VSFTPD后,用“pwd”指令就可以发现被自己被定位到自己的“/home/xiaowang”目录。 
  从文件系统层次来看,由于“/home/xiaowang”目录的权限是属于vsftpdguest的,所以其他的虚拟用户同样也可以访问xiaowang的自家目录。解决这个问题也很简单,我们只需要让VSFTPD负责将虚拟用户限制在其自家目录,就可以避免虚拟用户的互相访问。具体做法参照前面第六步中所述,这里不再赘述。经过以上设置后,虚拟用户就可以拥有属于自己的目录了。

 leaper 回复于:2004-05-03 09:42:38
好东西,先收起来

 zqqa 回复于:2004-05-19 09:26:21
大哥,我照你方法配完了。可进去的时候总是说用户密码不对阿

 alibab 回复于:2004-05-31 11:27:25
真的不错,不过我在想,是不是可以用Qmail的Vpopmail库中的用户信息作为FTP的用户来认证,或是修改一下也可,这样,有一套用户就可以管理WEB和MAIL了, 

 alibab 回复于:2004-07-03 19:02:38
大哥, 帮帮呀,出现以下错误, lmysqlclient 是怎陌回事, 
[root@bail pam_mysql]# make
mkdir -p ./dynamic
gcc -shared -Xlinker -x -L/usr/lib/mysql -lz -o pam_mysql.so dynamic/pam_mysql.o  -lmysqlclient -lcrypt
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [pam_mysql.so] Error 1

 alibab 回复于:2004-07-03 19:03:45
mysql_devel我已经装上了, 怎样才能去掉lmysqlclient错误呀

 alibab 回复于:2004-07-03 20:33:05
cp /usr/local/mysql/lib/libmysqlclient.10.0 /usr/lib  上面 lmysqlclien的问题解决了, 

在客户端连接时,总是提示口令不对.

找不到问题所在

 qdinfo 回复于:2005-03-01 17:10:08
好东东啊。可是按装到这一步出错了。
大家帮我看看。
我的MYSQL是用tar.gz包按装的。




qdinfo:~/pam_mysql# ls
Changelog  CREDITS  Makefile  Makefile.bsd  pam_mysql.c  Readme
qdinfo:~/pam_mysql# make
mkdir -p ./dynamic
gcc -O2 -Dlinux -DLINUX_PAM -ansi -D_POSIX_SOURCE -Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align -Wtraditional -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline -Wshadow -pedantic -fPIC -DPAM_DYNAMIC  -c pam_mysql.c -o dynamic/pam_mysql.o
pam_mysql.c:35:25: mysql/mysql.h: 没有那个文件或目录
pam_mysql.c:56:34: security/pam_modules.h: 没有那个文件或目录
pam_mysql.c:57:31: security/pam_misc.h: 没有那个文件或目录
pam_mysql.c:81: error: parse error before '*' token
pam_mysql.c:81: warning: type defaults to `int' in declaration of `mysql_auth'
pam_mysql.c:81: error: ISO C forbids data definition with no type or storage class
pam_mysql.c:106: error: parse error before '*' token
pam_mysql.c:109: warning: function declaration isn't a prototype
pam_mysql.c:111: error: parse error before '*' token
pam_mysql.c:113: warning: function declaration isn't a prototype
pam_mysql.c:115: error: syntax error before "int"
pam_mysql.c:115: error: parse error before '*' token
pam_mysql.c:116: warning: function declaration isn't a prototype
pam_mysql.c:117: error: syntax error before "int"
pam_mysql.c:117: error: parse error before '*' token
pam_mysql.c:118: warning: function declaration isn't a prototype
pam_mysql.c:119: error: syntax error before "int"
pam_mysql.c:119: error: parse error before '*' token
pam_mysql.c:120: warning: function declaration isn't a prototype
pam_mysql.c:121: error: syntax error before "int"
pam_mysql.c:121: error: parse error before '*' token
pam_mysql.c:122: warning: function declaration isn't a prototype
pam_mysql.c:123: error: syntax error before "int"
pam_mysql.c:123: error: parse error before '*' token
pam_mysql.c:124: warning: function declaration isn't a prototype
pam_mysql.c:125: error: syntax error before "int"
pam_mysql.c:125: error: parse error before '*' token
pam_mysql.c:126: warning: function declaration isn't a prototype
pam_mysql.c:133: error: parse error before '*' token
pam_mysql.c:133: warning: function declaration isn't a prototype
pam_mysql.c:141: error: parse error before '*' token
pam_mysql.c:141: warning: function declaration isn't a prototype
pam_mysql.c:143: error: parse error before '*' token
pam_mysql.c:144: warning: function declaration isn't a prototype
pam_mysql.c:151: error: parse error before '*' token
pam_mysql.c:151: warning: function declaration isn't a prototype
pam_mysql.c: In function `breakArgs':
pam_mysql.c:157: warning: traditional C rejects ISO C style function definitions
pam_mysql.c: In function `parseArgs':
pam_mysql.c:233: warning: traditional C rejects ISO C style function definitions
pam_mysql.c: At top level:
pam_mysql.c:391: error: parse error before '*' token
pam_mysql.c:391: warning: function declaration isn't a prototype
pam_mysql.c: In function `db_connect':
pam_mysql.c:392: error: `PAM_AUTH_ERR' undeclared (first use in this function)
pam_mysql.c:392: error: (Each undeclared identifier is reported only once
pam_mysql.c:392: error: for each function it appears in.)
pam_mysql.c:399: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:401: warning: implicit declaration of function `mysql_init'
pam_mysql.c:401: error: `auth_sql_server' undeclared (first use in this function)
pam_mysql.c:402: warning: implicit declaration of function `mysql_real_connect'
pam_mysql.c:404: warning: assignment makes pointer from integer without a cast
pam_mysql.c:407: warning: implicit declaration of function `mysql_select_db'
pam_mysql.c:411: warning: implicit declaration of function `mysql_error'
pam_mysql.c:411: warning: format argument is not a pointer (arg 3)
pam_mysql.c: In function `db_close':
pam_mysql.c:420: warning: traditional C rejects ISO C style function definitions
pam_mysql.c:424: warning: implicit declaration of function `mysql_close'
pam_mysql.c: At top level:
pam_mysql.c:428: error: parse error before '*' token
pam_mysql.c:429: warning: function declaration isn't a prototype
pam_mysql.c: In function `db_checkpasswd':
pam_mysql.c:438: error: `MYSQL_RES' undeclared (first use in this function)
pam_mysql.c:438: error: `result' undeclared (first use in this function)
pam_mysql.c:439: error: `MYSQL_ROW' undeclared (first use in this function)
pam_mysql.c:439: error: parse error before "row"
pam_mysql.c:440: error: `PAM_AUTH_ERR' undeclared (first use in this function)
pam_mysql.c:452: error: `user' undeclared (first use in this function)
pam_mysql.c:456: error: `PAM_BUF_ERR' undeclared (first use in this function)
pam_mysql.c:462: warning: implicit declaration of function `mysql_escape_string'
pam_mysql.c:509: warning: implicit declaration of function `mysql_query'
pam_mysql.c:509: error: `auth_sql_server' undeclared (first use in this function)
pam_mysql.c:513: warning: implicit declaration of function `mysql_store_result'
pam_mysql.c:516: warning: function `mysql_error' was previously declared within a block
pam_mysql.c:516: warning: format argument is not a pointer (arg 3)
pam_mysql.c:517: warning: implicit declaration of function `mysql_free_result'
pam_mysql.c:521: warning: implicit declaration of function `mysql_num_rows'
pam_mysql.c:523: warning: function `mysql_free_result' was previously declared within a block
pam_mysql.c:528: error: `row' undeclared (first use in this function)
pam_mysql.c:528: warning: implicit declaration of function `mysql_fetch_row'
pam_mysql.c:531: warning: function `mysql_error' was previously declared within a block
pam_mysql.c:531: warning: format argument is not a pointer (arg 3)
pam_mysql.c:536: error: `passwd' undeclared (first use in this function)
pam_mysql.c:576: warning: implicit declaration of function `make_scrambled_password'
pam_mysql.c:589: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:603: warning: function `mysql_free_result' was previously declared within a block
pam_mysql.c: At top level:
pam_mysql.c:611: error: parse error before '*' token
pam_mysql.c:613: warning: function declaration isn't a prototype
pam_mysql.c: In function `converse':
pam_mysql.c:617: warning: implicit declaration of function `pam_get_item'
pam_mysql.c:617: error: `pamh' undeclared (first use in this function)
pam_mysql.c:617: error: `PAM_CONV' undeclared (first use in this function)
pam_mysql.c:617: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:619: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:620: error: dereferencing pointer to incomplete type
pam_mysql.c:620: error: `nargs' undeclared (first use in this function)
pam_mysql.c:621: error: `message' undeclared (first use in this function)
pam_mysql.c:622: error: `response' undeclared (first use in this function)
pam_mysql.c:622: error: dereferencing pointer to incomplete type
pam_mysql.c:623: error: `PAM_CONV_AGAIN' undeclared (first use in this function)
pam_mysql.c:625: warning: implicit declaration of function `pam_strerror'
pam_mysql.c:625: warning: format argument is not a pointer (arg 3)
pam_mysql.c:628: warning: function `pam_strerror' was previously declared within a block
pam_mysql.c:628: warning: format argument is not a pointer (arg 3)
pam_mysql.c: In function `saltify':
pam_mysql.c:636: warning: traditional C rejects ISO C style function definitions
pam_mysql.c:648: warning: implicit declaration of function `time'
pam_mysql.c: At top level:
pam_mysql.c:673: error: parse error before '*' token
pam_mysql.c:675: warning: function declaration isn't a prototype
pam_mysql.c: In function `updatePasswd':
pam_mysql.c:681: error: `PAM_AUTH_ERR' undeclared (first use in this function)
pam_mysql.c:690: error: `user' undeclared (first use in this function)
pam_mysql.c:690: error: `newpass' undeclared (first use in this function)
pam_mysql.c:692: error: `oldpass' undeclared (first use in this function)
pam_mysql.c:692: error: `isRoot' undeclared (first use in this function)
pam_mysql.c:699: error: `PAM_BUF_ERR' undeclared (first use in this function)
pam_mysql.c:732: warning: function `make_scrambled_password' was previously declared within a block
pam_mysql.c:768: warning: function `mysql_escape_string' was previously declared within a block
pam_mysql.c:786: warning: function `mysql_query' was previously declared within a block
pam_mysql.c:786: error: `my' undeclared (first use in this function)
pam_mysql.c:789: warning: function `mysql_error' was previously declared within a block
pam_mysql.c:789: warning: format argument is not a pointer (arg 3)
pam_mysql.c:793: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c: At top level:
pam_mysql.c:799: error: parse error before '*' token
pam_mysql.c:800: warning: function declaration isn't a prototype
pam_mysql.c: In function `askForPassword':
pam_mysql.c:801: warning: array type has incomplete element type
pam_mysql.c:801: error: storage size of `msg' isn't known
pam_mysql.c:807: error: `pwprompt' undeclared (first use in this function)
pam_mysql.c:811: error: `PAM_BUF_ERR' undeclared (first use in this function)
pam_mysql.c:817: error: `PAM_PROMPT_ECHO_OFF' undeclared (first use in this function)
pam_mysql.c:820: error: `pamh' undeclared (first use in this function)
pam_mysql.c:823: warning: implicit declaration of function `_pam_overwrite'
pam_mysql.c:824: warning: implicit declaration of function `_pam_drop'
pam_mysql.c:827: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:829: warning: implicit declaration of function `_pam_drop_reply'
pam_mysql.c:830: error: `PAM_CONV_AGAIN' undeclared (first use in this function)
pam_mysql.c:831: error: `PAM_INCOMPLETE' undeclared (first use in this function)
pam_mysql.c:831: error: `PAM_AUTHINFO_UNAVAIL' undeclared (first use in this function)
pam_mysql.c:836: warning: implicit declaration of function `pam_set_item'
pam_mysql.c:836: error: `pwtype' undeclared (first use in this function)
pam_mysql.c:836: error: dereferencing pointer to incomplete type
pam_mysql.c:801: warning: unused variable `msg'
pam_mysql.c: At top level:
pam_mysql.c:839: error: parse error before '*' token
pam_mysql.c:839: warning: function declaration isn't a prototype
pam_mysql.c: In function `sqlLog':
pam_mysql.c:849: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:861: error: `PAM_AUTH_ERR' undeclared (first use in this function)
pam_mysql.c:886: error: `user' undeclared (first use in this function)
pam_mysql.c:890: error: `PAM_BUF_ERR' undeclared (first use in this function)
pam_mysql.c:893: error: `msg' undeclared (first use in this function)
pam_mysql.c:906: warning: function `mysql_escape_string' was previously declared within a block
pam_mysql.c:952: warning: implicit declaration of function `mysql_real_query'
pam_mysql.c:952: error: `auth_sql_server' undeclared (first use in this function)
pam_mysql.c:963: warning: function `mysql_error' was previously declared within a block
pam_mysql.c:963: warning: format argument is not a pointer (arg 3)
pam_mysql.c: At top level:
pam_mysql.c:978: error: syntax error before "int"
pam_mysql.c:978: error: parse error before '*' token
pam_mysql.c:982: warning: function declaration isn't a prototype
pam_mysql.c: In function `pam_sm_authenticate':
pam_mysql.c:989: error: `MYSQL' undeclared (first use in this function)
pam_mysql.c:989: error: parse error before "auth_sql_server"
pam_mysql.c:995: error: `argc' undeclared (first use in this function)
pam_mysql.c:995: error: `argv' undeclared (first use in this function)
pam_mysql.c:999: warning: implicit declaration of function `pam_get_user'
pam_mysql.c:999: error: `pamh' undeclared (first use in this function)
pam_mysql.c:1001: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:1006: error: `PAM_USER_UNKNOWN' undeclared (first use in this function)
pam_mysql.c:1009: warning: function `pam_get_item' was previously declared within a block
pam_mysql.c:1009: error: `PAM_AUTHTOK' undeclared (first use in this function)
pam_mysql.c:1009: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1014: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1017: error: `PAM_AUTHINFO_UNAVAIL' undeclared (first use in this function)
pam_mysql.c:1019: error: `auth_sql_server' undeclared (first use in this function)
pam_mysql.c: At top level:
pam_mysql.c:1045: error: syntax error before "int"
pam_mysql.c:1045: error: parse error before '*' token
pam_mysql.c:1047: warning: function declaration isn't a prototype
pam_mysql.c: In function `pam_sm_acct_mgmt':
pam_mysql.c:1051: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c: At top level:
pam_mysql.c:1055: error: syntax error before "int"
pam_mysql.c:1055: error: parse error before '*' token
pam_mysql.c:1057: warning: function declaration isn't a prototype
pam_mysql.c: In function `pam_sm_setcred':
pam_mysql.c:1061: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c: At top level:
pam_mysql.c:1067: error: syntax error before "int"
pam_mysql.c:1067: error: parse error before '*' token
pam_mysql.c:1069: warning: function declaration isn't a prototype
pam_mysql.c: In function `pam_sm_chauthtok':
pam_mysql.c:1077: error: `MYSQL' undeclared (first use in this function)
pam_mysql.c:1077: error: parse error before "auth_sql_server"
pam_mysql.c:1083: error: `argc' undeclared (first use in this function)
pam_mysql.c:1083: error: `argv' undeclared (first use in this function)
pam_mysql.c:1087: warning: function `pam_get_user' was previously declared within a block
pam_mysql.c:1087: error: `pamh' undeclared (first use in this function)
pam_mysql.c:1088: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c:1093: error: `PAM_USER_UNKNOWN' undeclared (first use in this function)
pam_mysql.c:1100: error: `auth_sql_server' undeclared (first use in this function)
pam_mysql.c:1104: error: `flags' undeclared (first use in this function)
pam_mysql.c:1104: error: `PAM_PRELIM_CHECK' undeclared (first use in this function)
pam_mysql.c:1109: error: `PAM_CHANGE_EXPIRED_AUTHTOK' undeclared (first use in this function)
pam_mysql.c:1112: warning: function `pam_get_item' was previously declared within a block
pam_mysql.c:1112: error: `PAM_OLDAUTHTOK' undeclared (first use in this function)
pam_mysql.c:1113: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1120: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1122: error: `PAM_AUTHTOK_ERR' undeclared (first use in this function)
pam_mysql.c:1141: error: `PAM_UPDATE_AUTHTOK' undeclared (first use in this function)
pam_mysql.c:1146: warning: function `pam_get_item' was previously declared within a block
pam_mysql.c:1146: error: `PAM_AUTHTOK' undeclared (first use in this function)
pam_mysql.c:1147: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1158: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1173: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c:1180: warning: dereferencing type-punned pointer will break strict-aliasing rules
pam_mysql.c: At top level:
pam_mysql.c:1199: error: syntax error before "int"
pam_mysql.c:1199: error: parse error before '*' token
pam_mysql.c:1201: warning: function declaration isn't a prototype
pam_mysql.c: In function `pam_sm_open_session':
pam_mysql.c:1205: error: `PAM_SUCCESS' undeclared (first use in this function)
pam_mysql.c: At top level:
pam_mysql.c:1209: error: syntax error before "int"
pam_mysql.c:1209: error: parse error before '*' token
pam_mysql.c:1211: warning: function declaration isn't a prototype
pam_mysql.c: In function `pam_sm_close_session':
pam_mysql.c:1215: error: `PAM_SUCCESS' undeclared (first use in this function)
make: *** [dynamic/pam_mysql.o] 错误 1

 yw112 回复于:2005-03-25 10:14:15
我也是这样弄得
跟楼上的错误一样!!
那位大虾能指点一下呀!!

 anstan 回复于:2005-03-25 10:26:11
假定你把mysql装在了/usr/local/mysql下,
那么你在编译pam_mysql的时候一定会出问题,(假定pam_mysql也是用tar.gz方式安装)
这时候 vi Makefile 一下,把它改成下面的样子:

ifndef FULL_LINUX_PAM_SOURCE_TREE
export DYNAMIC=-DPAM_DYNAMIC
export CC=gcc
export CFLAGS=-O2 -Dlinux -DLINUX_PAM \
-ansi -D_POSIX_SOURCE -Wall -Wwrite-strings \
-Wpointer-arith -Wcast-qual -Wcast-align -Wtraditional \
-Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline \
-Wshadow -pedantic -fPIC [b:6778fee5b0]-I/usr/local/mysql/include[/b:6778fee5b0]
export MKDIR=mkdir -p
export LD_D=gcc -shared -Xlinker -x [b:6778fee5b0]-L/usr/local/mysql/lib/mysql [/b:6778fee5b0]-lz
endif

注意粗体的部分就是你应该改的,当然,如果你按装在其它目录,那么请也相应的改一改,这样你就可以在当前目录下得到pam_mysql.so 这个模块了。
上一篇文章:ftp协议里面自带的命令
下一篇文章:Linux服务器设置指南-代理接入服务器(1)3
返回上页】 
 

本站在线服务QQ  程序定制:70632246 广告受理/投搞/投诉:7606208 技术客服:3828351
网站简介 广告服务 成功案例 联系方式 办公电话:0580-3825369
Copyright © 2001-2007 JZ173.COM,All rights reserved  浙ICP备05023962号 感谢【中国商务网】提供服务器