• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • 關于squid和mysql的認證問題

    發表于:2007-05-25來源:作者:點擊數: 標簽:
    我用http://people.fsn.hu/~airween/mysql_auth/這個網址上的mysql_auth提供的作mysql認證,但是我在mysql_auth-0.5編譯總是出錯 gcc-I/usr/local/include-L/usr/local/lib-csrc/mysql_auth.c src/mysql_auth.c:24:mysql/mysql.h:Nosuchfileordirectory ***

    我用http://people.fsn.hu/~airween/mysql_auth/這個網址上的mysql_auth提供的作mysql認證,但是我在mysql_auth-0.5編譯總是出錯

    gcc -I/usr/local/include -L/usr/local/lib -c src/mysql_auth.c
    src/mysql_auth.c:24: mysql/mysql.h: No such file or directory
    *** Error code 1

    Stop in /tmp/mysql_auth-0.5.
    這個錯誤是我在freebsd中編譯得到的。

    [root@squid mysql_auth-0.5]# make
    gcc -I/usr/local/include -L/usr/local/lib   -c -o src/mysql_auth.o src/mysql_auth.c
    src/mysql_auth.c:24:25: mysql/mysql.h: No such file or directory
    src/mysql_auth.c: In function `main':
    src/mysql_auth.c:37: `MYSQL' undeclared (first use in this function)
    src/mysql_auth.c:37: (Each undeclared identifier is reported only once
    src/mysql_auth.c:37: for each function it appears in.)
    src/mysql_auth.c:37: parse error before "connect"
    src/mysql_auth.c:38: `MYSQL_RES' undeclared (first use in this function)
    src/mysql_auth.c:38: `result' undeclared (first use in this function)
    src/mysql_auth.c:39: `MYSQL_ROW' undeclared (first use in this function)
    src/mysql_auth.c:39: parse error before "row"
    src/mysql_auth.c:64: `connect' undeclared (first use in this function)
    src/mysql_auth.c:188: `row' undeclared (first use in this function)
    make: *** [src/mysql_auth.o] Error 1

    這個錯誤是在redhat中得到的,那位大俠幫忙看看把
    Make any changes to the source code you need. For example, set up correctly place of configuration file. See that in define.h. 

    Review the Makefile, and modify based on target platform or site requirements. Setting up the mysql.h header and libmysqlclients.a places. Setting up your squid user and group accounts, and squid root directory.
    Setting up correctly the permissions of mysql_auth.conf (mode 600)!
    This is very important! This file included a mysql account, with select, update, insert and delete privileges! 
    Also very important: if you use mysql.log, be very carefull! It contains all transactions! For example: 


    52 Query       UPDATE data SET password = password ("1234") WHERE user LIKE 'airween'

    After when you edit what you want, type 'make', then 'make install', then 'make clean'. 

    'Make install' will put 'mysql_auth' into /usr/local/squid/bin by default, and 'mysql_auth.conf' to /usr/local/squid/etc. 


    這段話是說明怎么安裝的,我有些東西我看的不是很明白的,也希望那位可以詳細解釋一下。謝謝。

     wujianpengjj 回復于:2003-10-14 21:45:02
    搞定,經過漫長的三天的痛苦的安裝,終于搞定squid+mysql在bsd上的安裝了。

     wujianpengjj 回復于:2003-10-15 02:24:19
    FreeBSD4.7 上搭建squid代理mysql認證服務器
                                                               Wjp
                                                                                             2003-10-14
    首先我要感謝hj的幫助,不管是在我學習linux上,還是FreeBSD上雖然更多的是java上。
    接著聲明一下,本人的語文水平很不好,寫的文檔可能比較糟糕,但是看在我辛辛苦苦作了好幾個通宵的份上希望有人在轉載時注名出處http://www.jnull.com/jive/thread.jsp?nav=false&forum=7&thread=943 和作者wjp,還有第一段感謝的人。^_^謝謝。
    文檔的開頭先介紹一下我為什么用這些東西作為代理服務器的開發。
    一. 我試用了squid,socks5,wingate,kingate,覺得squid適用像我們學校這種單位應用。
    它在性能和節省帶寬,提高訪問速度上很有優勢。
    二. 我用的操作系統是FreeBSD,雖然我是BSD的超級菜鳥,但是在瀏覽squid的FAQ時看到,squid可能在FreeBSD上運行是比較快的,加上hj的極力推薦,我相信FreeBSD不會讓大家失望的。
    三. 剛開始我用的是NSCA這種認證,這也是,中文文檔比較多的一種認證方式,但是我覺得它的開發很困難,我是不懂怎么寫一個htpasswd的,像改密碼,什么的都比較,困難。而且我的直覺上覺的mysql認證會比NSCA快,所以我選用了mysql,還有朋友用LDAP的,很遺憾因為我不會搭建LDAP服務器,就沒有用它,感覺上LDAP的表現也會同樣出色的。
    以上就是我選用這三個組合的原因,不知各位大俠同意否。

    操作系統和軟件的安裝,本人學FreeBSD沒有一個星期,全靠hj的幫助,還有FreeBSD手冊才搞定得,我裝的是FreeBSD4.8從ftp.freeBSD.org上下載的mini版,大家可以參考FreeBSD的手冊http://people.freebsdchina.org/kinki 。我現在會的就是能把FreeBSD安裝完,設好ip上網,大家肯定比我厲害^_^。
    現在的BSD上是沒有squid和mysql的,我先安裝squid。我是用ports安裝的(如果你不會和我一樣菜的話,我建議你仔細讀一下http://www.jnull.com/jive/thread.jsp?forum=7&thread=183&tstart=45&trange=15 這篇文章,我相信你也會喜歡ports的):

    BSD# cd /usr/ports/www/squid
    BSD# make install
    BSD# make clean

    如果你能上網的話那么squid就裝完了。我現在裝的是squid2.5這個版本的,這個版本和2.4比在認證上有了很大的改變。接著是mysql了。
    BSD# cd /usr/ports/databases/mysql323-server
    BSD# make install
    BSD# make clean

    同樣的easy,哈哈!我太喜歡ports了。我裝的是mysql3-23-58這個版本。接下來去下載squid的認證模塊,http://people.fsn.hu/~airween/mysql_auth/mysql_auth-0.5.tar.gz 
    我把它放在/tmp下(這兒是e文的文檔http://people.fsn.hu/~airween/mysql_auth/ )。
    BSD# tar -zxvf mysql_auth-0.5.tar.gz
    BSD# cd mysql_auth-0.5
    BSD# make
    BSD# make install
    當你make時可能會出錯,問題出在Makefile這個文件上,那個mysql_auth的作者他libmysqlclients.a這兩個文件的位置和我的這兩個文件的位置不同就會出錯,我貼出我剛開始的錯誤

    BSD# make
    gcc -I/usr/local/include -L/usr/local/lib -c src/mysql_auth.c
    gcc -I/usr/local/include -L/usr/local/lib -c src/confparser.c
    gcc -I/usr/local/include -L/usr/local/lib -c src/mypasswd.c
    gcc -o mysql_auth src/mysql_auth.c src/confparser.c -lmysqlclient -I/usr/local/include -L/usr/local/lib
    /usr/libexec/elf/ld: cannot find -lmysqlclient
    *** Error code 1

    Stop in /tmp/10-13/mysql_auth-0.5.
    以上就是那兩個文件不對的錯誤,我是重新修改了Makefile的以下是Makefile的內容

    CC = gcc
    CFLAGS = -I/usr/local/include -L/usr/local/lib
    LDFLAGS = -lmysqlclient
    SRC = src
    OBJS = $(SRC)/mysql_auth.o $(SRC)/confparser.o $(SRC)/mypasswd.o
    INSTALL = /usr/bin/install
    CONF = $(SRC)/mysql_auth.conf
    all : mysql_auth mypasswd
    clean:
            rm -rf src/*.o *.o mysql_auth mypasswd

    mysql_auth: $(OBJS)
            $(CC) -o $@ $(SRC)/mysql_auth.c $(SRC)/confparser.c $(LDFLAGS) $(CFLAGS)

    mypasswd: $(OBJS)
            $(CC) -o $@ $(SRC)/mypasswd.c $(SRC)/confparser.c $(LDFLAGS) $(CFLAGS)

    install:
            $(INSTALL) -o nobody -g nogroup -m 755 mysql_auth /usr/local/squid/bin/mysql_auth
            $(INSTALL) -o root -g wheel -m 700 mypasswd /usr/local/bin/mypasswd
            $(INSTALL) -o nobody -g nogroup -m 600 $(CONF) /usr/local/squid/etc/mysql_auth.conf
            $(INSTALL) -o nobody -g nogroup -m 600 $(CONF) /usr/local/squid/etc/mysql_auth.conf.default
    關鍵是CFLAGS = -I/usr/local/include -L/usr/local/lib這一行它認為libmysqlclients.a在/usr/local/lib這個目錄下,實際上我的在/usr/local/lib/mysql下,這個就是錯誤的原因,所以你要改寫這句話把它改成你的libmysqlclients.a所在的地方,(這個文件cp 到/usr/local/lib不行我試過,不知道別人怎么樣)
    我的就是CFLAGS = -I/usr/local/include -L/usr/local/lib/mysql
    這樣就ok了,相信你也能ok的。
    然后在make install,如果這兒過不去,那么可能是這個問題看看你現在有沒有對/usr/local/squid/bin和/usr/local/squid/etc這個有權限,如果沒有改過來,如果沒有這個目錄那么mkdir建立這兩個目錄,相信這樣之后你就能通過編譯了。
    哈哈。差不多快搞定了
    修改squid.conf
    BSD# cd /usr/local/etc/squid
    BSD# vi squid.conf
    acl password proxy_auth REQUIRED
    http_access allow password
    auth_param basic program /usr/local/squid/bin/mysql_auth
    有這三句話,mysql的認證就可以了,但是你要保證squid對mysql_auth有權限。如果什么都是對的認證通不過往往就是mysql_auth的權限問題。
    運行squid看看正常嗎,squid –z先初始話cache,然后squid -NCd1
    如果squid出錯你就看看squid的文檔去吧,網上又很多的,隨便提一句很可能是你的文件夾的權限問題,像log這類看看squid對她有沒有權限。

    Squid完成了接著是mysql了我的數據庫沒有初始話,一些安全措施都沒有作,用的是root用戶而且密碼是空的所以可能和實際做的不一樣了,實際的root的應該有密碼
    BSD# cd /tmp/10-13/mysql_auth-0.5/scripts
    BSD# cd path/to/mysql_auth-source/scripts
    BSD# mysql -u root -p < create_script
    Enter password: 你的root的密碼,如果沒有那么就沒有這行輸入
    To add a user: 
    BSD#> mysql –u root-p mysql_auth
    Enter password:
    Welcome message...

    mysql> insert into data values ('wjp', '123456');
    Query OK, 1 row affected (0.00 sec)

    mysql>
    如果你希望data表里存的密碼是加密的那么就用password這個函數如下如果這兒用的是加密方式那么mysql_auth.conf中也要指定是加密方式,默認的密碼是不加密的。mysql_auth.conf中的選項是encrypt_password_form   NO
    改成YES就行了
    shell> mysql -u your_user_name -p mysql_auth
    Enter password:
    Welcome message...

    mysql> insert into data values ('wjp', password("123456"));
    Query OK, 1 row affected (0.00 sec)
    到這一步你運行mysql,運行squid,然后設上代理用wjp這個帳號,用123456這個密碼就可以了,good luck!^_^

    如果你的mysql不和squid裝在一臺機器上,你就要配置mysql_auth.conf這個文件了以下是對mysql_auth.conf簡單的解釋,說明寫的很清楚,如果你熟悉mysql的話作這個沒有問題的。我也不多說了。如果不太明白的我建議先看看mysql。

    現在來看看mysql_auth.conf

    # mysql_auth.conf - an mysql authenticator config file
    # this is the default name. you can call this by other name,
    # but set up it in mysql_auth-source/src/define.h.
    #
    # comment: first character in line is '#'
    # empty line (EOL at first) allowed
    #
    # format of parameters and their values:
    # parameter - SPACE(S) and/or TAB(S) - value
    #
    # IMPORTANT: see the mysql_auth-source/scripts/create_script
    # this configuration file made by this script
    #
    # by Ervin Hegedus, 2002

    # hostname
    #
    # where is the mysql server - the server hostname or IP address;
    # first 'hostname' directive, and after space(s) or tab(s) its
    # value
    #
    # default:
    #這個選項就是指定mysql數據庫的,如果不是同一臺機器,那么請指定ip或者hostname.
    hostname        localhost

    # user
    #
    # which user can connect to database
    # default:
    #這個就是mysql_auth是以什么用戶連接mysql數據庫的默認是squid,如果你想改變,mysql
    #數據庫中應該有這個用戶可以登陸的
    user            squid

    # password
    #
    # user's password for database, that store the accounts
    # default:
    #連接用的密碼
    password        squid

    # database
    #
    # mysql database name, where accounts places are
    # default:
    #用到的庫
    database        mysql_auth

    # next three directives tells what will the select query,
    # like this:
    # SELECT * FROM table WHERE user_column LIKE "username" AND password_column LIKE "password"
    # where username and password comes from client in HTTP header,
    # and user_column and password_column is the columns name in table
    # this is an easy way to tune this program to your existing database

    # table
    #
    # the table name, where accounts exist in user-password pair
    # default:
    #用到的表
    table           data

    # user_column
    #
    # user column name in table
    # if you already have a database, what contains user-password
    # pair, you can set it here
    #帳號字段
    user_column     user

    # password_column
    #
    # password column name in table
    # like user column name above
    #用戶密碼字段
    password_column         password

    # encrypt_password_form
    #
    # passwords are stored in encrypted form,
    # using mysql internal 'password()' function
    # this mean, you just storing the passwords encrypted format,
    # Squid and clients doesn't use encrypt form!
    # The value is case insensitive (YES/yes or not one of these).
    # For backward compatibility, default is NO.
    #是否使用密碼文存儲
    encrypt_password_form   NO


    寫到這兒已經是2003-10-15 2:15了,困了,睡覺了,good luck!^_^
    wjp@mail.neuq.edu.cn
    2003-10-15

     wujianpengjj 回復于:2003-10-15 02:25:22
    http://www.jnull.com/jive/thread.jsp?nav=false&forum=7&thread=943

     段譽 回復于:2004-05-19 11:47:37
    sorry,這么好的貼子,居然被沉掉了,是我的失職,向樓主表示歉意。

    另外:你說的代碼的問題,我可以滿足你的需求,并爭取將它發展起來,:)。常保持聯系,:)

     Manson 回復于:2004-06-17 10:40:27
    最近Proxy壇子有些冷清啊

     wujianpengjj 回復于:2004-06-17 19:52:47
    以后不能上網了,郁悶啊。

     段譽 回復于:2004-06-18 08:55:53
    同情ing

     leaper 回復于:2004-07-13 17:47:55
    支持一下,很好的一個東西。

     pupie 回復于:2004-07-25 17:42:05
    昨天晚上才升級到SQUID 2.5 STABLE 6,結果今天早上不知道怎么一哈突然WEB PROXY 掛了,所有IE都打不開頁面,禁用了WEB  PROXY 才恢復正常。
    300 USERs IN LAN

     佟兒 回復于:2004-08-28 20:18:42
    [img:8196952901]http://bbs.chinaunix.net/forum/uploadfile/_________94771093149310.gif[/img:8196952901]

     馨馨 回復于:2004-08-28 21:49:08
    這是技術論壇,不是到處胡鬧的地方!

     solaris_yschang 回復于:2004-09-02 09:29:18
    支持

    原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>