Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Jan 2012 22:23:46 +0100
From:      "Grzegorz Blach" <magik@roorback.net>
To:        "FreeBSD gnats submit" <FreeBSD-gnats-submit@FreeBSD.org>
Subject:   ports/164295: databases/godis: Fixed authenticaton to database != 0
Message-ID:  <1326921826.35522@silver.nine>
Resent-Message-ID: <201201182130.q0ILUCxv087800@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         164295
>Category:       ports
>Synopsis:       databases/godis: Fixed authenticaton to database != 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 18 21:30:12 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Grzegorz Blach
>Release:        FreeBSD 9.0-RELEASE amd64
>Organization:
>Environment:


System: FreeBSD 9.0-RELEASE #5 r229491: Wed Jan  4 19:17:56 CET 2012
    magik@silver.nine:/usr/obj/usr/src/sys/SILVER



>Description:


Currently godis select database and then authenticate to it,
this fail because auth command must be called before select.

Connecting to db == 0 with authentication works,
because db == 0 is default one and select command is not used in this case.



>How-To-Repeat:


Simple code that should work if you can connect to db == 1 with authentication. Change "secret" to your password before use.


---- begin of test.go ----
package main

import (
    "godis"
)

func main() {
    db := godis.New("", 1, "secret")

    foo, err := db.Get("foo")
    if err == nil {
        println(foo.String())
    } else {
        println(err.String())
    }
}
---- end of test.go ----



>Fix:


--- godis.diff.txt begins here ---
diff -ruN databases/godis/Makefile databases/godis/Makefile
--- databases/godis/Makefile	2011-11-26 23:56:56.000000000 +0100
+++ databases/godis/Makefile	2012-01-18 21:37:10.577464630 +0100
@@ -7,7 +7,7 @@
 
 PORTNAME=	godis
 PORTVERSION=	20110803
-PORTREVISION=	2
+PORTREVISION=	3
 CATEGORIES=	databases
 MASTER_SITES=	LOCAL/jlaffaye
 
diff -ruN databases/godis/files/patch-conn.go databases/godis/files/patch-conn.go
--- databases/godis/files/patch-conn.go	1970-01-01 01:00:00.000000000 +0100
+++ databases/godis/files/patch-conn.go	2012-01-18 22:00:03.847468110 +0100
@@ -0,0 +1,24 @@
+--- conn.go.orig	2011-09-04 22:00:03.000000000 +0200
++++ conn.go	2012-01-18 21:31:25.000000000 +0100
+@@ -342,8 +342,8 @@
+ }
+ 
+ func (cc *conn) configConn(db int, password string) os.Error {
+-    if db != 0 {
+-        buf := [][]byte{[]byte("SELECT"), []byte(strconv.Itoa(db))}
++    if password != "" {
++        buf := [][]byte{[]byte("AUTH"), []byte(password)}
+         _, err := cc.rwc.Write(buildCmd(buf))
+ 
+         if err != nil {
+@@ -356,8 +356,8 @@
+         }
+     }
+ 
+-    if password != "" {
+-        buf := [][]byte{[]byte("AUTH"), []byte(password)}
++    if db != 0 {
++        buf := [][]byte{[]byte("SELECT"), []byte(strconv.Itoa(db))}
+         _, err := cc.rwc.Write(buildCmd(buf))
+ 
+         if err != nil {
--- godis.diff.txt ends here ---



>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1326921826.35522>