修改pam_mysql的源代码,让他支持ipv6. - XiZi's Blog

修改pam_mysql的源代码,让他支持ipv6.

Xizi posted @ 2009年5月26日 07:08 in IPv6 with tags ubuntu IPv6 Pam_mysql , 3113 阅读

      配置了vsftp+pam_mysql+mysql的虚拟用户管理系统。但学校的ipv6网络,人家用ipv6访问的时候不能准确记录其ip地址。遂down了pam_mysql的源代码,改之。基于尽量少的改动原有文件的原则。添加了部分代码。现在ok了。下面给大家说说具体修改过程。

1.    当然是下载源代码了。

           在你能有写权限的目录,比如 /home/you/ 建立工作目录如:mysql-pam  并进入

mkdir pam-mysql
cd pam-mysql
apt-get source libpam-mysql

将会得到以下文件

ado@www:~/mysql-pam$ ls
pam-mysql-0.6.2            pam-mysql_0.6.2-1.dsc
pam-mysql_0.6.2-1.diff.gz  pam-mysql_0.6.2.orig.tar.gz
 

 2.    修改pam_mysql.c

ado@www:~/mysql-pam$ cd pam-mysql-0.6.2/
ado@www:~/mysql-pam/pam-mysql-0.6.2$ vim pam_mysql.c
 

 

第1753行,原文件为:

        if (NULL == (remote_host = xcalloc(16, sizeof(char)))) {
                syslog(LOG_AUTHPRIV | LOG_CRIT, PAM_MYSQL_LOG_PREFIX "allocation failure at " __FILE__ ":%d", __LINE__);
                return PAM_MYSQL_ERR_ALLOC;
        }
 

修改为:

        if (NULL == (remote_host = xcalloc(255, sizeof(char)))) {
                syslog(LOG_AUTHPRIV | LOG_CRIT, PAM_MYSQL_LOG_PREFIX "allocation failure at " __FILE__ ":%d", __LINE__);
                return PAM_MYSQL_ERR_ALLOC;
        }
 

 

给remote_host变量足够的存储空间。

 

从1752行开始田间如下能容:

                sprintf(remote_host,"%s","unknown");
                struct sockaddr_in6 client_address;
                int salen6=sizeof(client_address);
                 if (!getpeername(0, (struct sockaddr *) &client_address, &salen6))
                {
                        char inet[64]="no ip is 2001:0da8:a800:0000:0000:0000:0000:0000 has nothing to do";
                        inet_ntop(AF_INET6,&(client_address.sin6_addr),inet,strlen(inet));
                        sprintf(remote_host,"%s",inet);
                }
                //strcpy(remote_host, "(unknown)");注释掉原来的操作
               //下面的代码不变

3. 好了,重新编译吧

./configure  !如果提示找不到什么“mysql_config”就安装这个包"libmysqlclient15-dev"

make

sudo make install

# 默认会安装到 /usr/lib/security/里面。
# 建个软连接

ln -s /usr/lib/security/pam_mysql.so /lib/security/pam_mysql.so

 

Avatar_small
poker 88 说:
2021年7月06日 22:37

Wonderful article. Fascinating to read. I love to read such an excellent article. Thanks! It has made my task more and extra easy. Keep rocking.

Avatar_small
read more 说:
2021年7月11日 04:49

I read your blog frequently and I just thought I’d say keep up the amazing work!

Avatar_small
Harry 说:
2021年12月16日 22:15

That is great submit and also i spend time you just read this kind of submit. your blog will be great and you also have got excellent employees within your website. great revealing keep it up. 파워볼사이트 추천

Avatar_small
Harry 说:
2022年1月09日 08:25

This can be a excellent ideas particularly in order to individuals a new comer to blogosphere, short as well as precise information… Many thanks with regard to discussing that one. Essential study post. 클레오카지노

Avatar_small
Harry 说:
2022年1月14日 00:23

Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work.   free online article spinner

Avatar_small
Robert Lee 说:
2022年1月22日 23:05

I really enjoyed reading your article. qiu qiu online terpercaya

Avatar_small
Harry 说:
2022年3月04日 03:05

When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style. Local Boca Raton Handyman

Avatar_small
faddy 说:
2022年6月20日 21:07

I have read all the comments and suggestions posted by the visitors for this article are very fine,We will wait for your next article so only.Thanks! Best place to buy whiskey online

Avatar_small
dark web/deep web/d 说:
2022年8月21日 00:58

You should also avoid looking for links on dark web sites. It's a lot harder to trace a link back to its owner if you do so, and you run the risk of your identity being stolen. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月21日 01:53

This isn't an overnight process, so be patient and keep track of your progress as you search for the perfect opportunity. deep web

Avatar_small
dark web/deep web/d 说:
2022年8月21日 02:19

Linking is just another way of saying that if you write or have some information on a particular website and if you have a link to that website, then you can help bring people to the website. dark web sites

Avatar_small
dark web/deep web/d 说:
2022年8月21日 02:38

They spent hours researching and writing articles and submitting them to directories so that they can get the maximum exposure and for people to use. dark web links

Avatar_small
dark web/deep web/d 说:
2022年8月21日 02:56

Once you have found the right people, you can start by creating some links for your own website. In this process, you will need to spend time looking for relevant links and then putting them on your website. dark web

Avatar_small
dark web/deep web/d 说:
2022年8月21日 03:15

First, visit the company's main website and look for their "Affiliate" link. On the "Affiliate" link there will be a button for joining the program. When you click this button, the program will begin to display products and services related to the product or service you selected. work from home jobs

Avatar_small
dark web/deep web/d 说:
2022年8月21日 03:34

Also, make sure that your site is easy to navigate and that it is visually appealing to the visitor. No one wants to visit your site and spend time trying to figure out how to use the link on your site! affiliate marketing success

Avatar_small
HASNA 说:
2022年9月03日 02:24

A person produced a few nice points presently there. Used to do searching on the matter and discovered practically just about all people goes along with along with your blog. https://www.simplybuzzes.com/angel-number-8899-meaning/

Avatar_small
BSEB Matric Hindi Qu 说:
2022年9月27日 07:13

Every year the BSEB is provided the latest updated model question paper for intermediate Hindi Medium and English Medium students from past years old examination set wise question paper with expert answers to theory and objective type questions for all subjects of Hindi, English, Mathematics, Physics, Chemistry, Biology, Computer Science, BSEB Matric Hindi Question Paper Multimedia & Web Technology for BSEB Inter science stream students.

Avatar_small
charlly 说:
2023年1月06日 17:50

In order to support ipv6 with pam_mysql, you will need to modify the source code to include the appropriate IPv6 libraries and functions. Additionally, you will need to add support for IPv6 addresses in the pam_mysql configuration file. With these changes in place, pam_mysql when international travel resume will be able to authenticate users with IPv6 addresses.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee