Skip to content

Commit

Permalink
fix sqlite import
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Bishop committed Aug 28, 2018
1 parent cb1d3db commit 333736d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ Grumble is an implementation of a server for the Mumble voice chat system. It is
Compiling Grumble from source
=============================

You must have a Go 1 environment installed to build Grumble. Those are available at:
## Dependencies

https://golang.org/dl/
- You must have a Go 1 environment installed to build Grumble. Those are available at: https://golang.org/dl/
- Grumble requires sqlite3 library

## Build

Once Go is installed, you should set up a GOPATH to avoid clobbering your Go environment's root directory with third party packages.

Expand Down
39 changes: 21 additions & 18 deletions cmd/grumble/murmurdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import (
"database/sql"
"errors"
"log"
"mumble.info/grumble/pkg/acl"
"mumble.info/grumble/pkg/ban"
"net"
"os"
"path/filepath"
"strconv"

_ "github.com/mattn/go-sqlite3"
"mumble.info/grumble/pkg/acl"
"mumble.info/grumble/pkg/ban"
)

const (
Expand All @@ -39,7 +41,7 @@ const SQLiteSupport = true

// Import the structure of an existing Murmur SQLite database.
func MurmurImport(filename string) (err error) {
db, err := sql.Open("sqlite", filename)
db, err := sql.Open("sqlite3", filename)
if err != nil {
panic(err.Error())
}
Expand Down Expand Up @@ -67,7 +69,7 @@ func MurmurImport(filename string) (err error) {
return err
}

err = os.Mkdir(filepath.Join(Args.DataDir, strconv.FormatInt(sid, 10)), 0750)
err = os.MkdirAll(filepath.Join(Args.DataDir, "servers", strconv.FormatInt(sid, 10)), 0750)
if err != nil {
return err
}
Expand Down Expand Up @@ -187,33 +189,34 @@ func populateChannelACLFromDatabase(server *Server, c *Channel, db *sql.DB) erro

for rows.Next() {
var (
UserId string
Group string
ApplyHere bool
ApplySub bool
Allow int64
Deny int64
UserId sql.NullString
Group sql.NullString
ApplyHere sql.NullBool
ApplySub sql.NullBool
Allow sql.NullInt64
Deny sql.NullInt64
)

if err := rows.Scan(&UserId, &Group, &ApplyHere, &ApplySub, &Allow, &Deny); err != nil {
return err
}

aclEntry := acl.ACL{}
aclEntry.ApplyHere = ApplyHere
aclEntry.ApplySubs = ApplySub
if len(UserId) > 0 {
aclEntry.UserId, err = strconv.Atoi(UserId)
aclEntry.ApplyHere = ApplyHere.Bool
aclEntry.ApplySubs = ApplySub.Bool
if UserId.Valid {
aclEntry.UserId, err = strconv.Atoi(UserId.String)
if err != nil {
return err
}
} else if len(Group) > 0 {
aclEntry.Group = Group
} else if Group.Valid {
aclEntry.Group = Group.String
} else {
return errors.New("Invalid ACL: Neither Group or UserId specified")
}

aclEntry.Deny = acl.Permission(Deny)
aclEntry.Allow = acl.Permission(Allow)
aclEntry.Deny = acl.Permission(Deny.Int64)
aclEntry.Allow = acl.Permission(Allow.Int64)
c.ACL.ACLs = append(c.ACL.ACLs, aclEntry)
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/grumble/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1452,9 +1452,9 @@ func (server *Server) Start() (err error) {
// Set sensible timeouts, in case no reverse proxy is in front of Grumble.
// Non-conforming (or malicious) clients may otherwise block indefinitely and cause
// file descriptors (or handles, depending on your OS) to leak and/or be exhausted
ReadTimeout: 5 * time.Second,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 2 * time.Minute,
IdleTimeout: 2 * time.Minute,
}
go func() {
err := server.webhttp.ListenAndServeTLS("", "")
Expand Down

0 comments on commit 333736d

Please sign in to comment.