bbolt

package
v0.5.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package bbolt handles transaction with the deprecated bbolt database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DBFilename

func DBFilename() string

DBFilename returns the filename of the database.

func RemoveDb

func RemoveDb(dbDir string) error

RemoveDb removes the database file.

func Z_ForTests_CreateDBFromYAML

func Z_ForTests_CreateDBFromYAML(src, destDir string) (err error)

Z_ForTests_CreateDBFromYAML creates the database inside destDir and loads the src file content into it.

nolint:revive,nolintlint // We want to use underscores in the function name here.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is our database API.

func New

func New(dbDir string) (db *Database, err error)

New creates a new database by creating or opening the underlying db.

func (*Database) AllGroups

func (c *Database) AllGroups() (all []GroupDB, err error)

AllGroups returns all groups or an error if the database is corrupted.

func (*Database) AllUsers

func (c *Database) AllUsers() (all []UserDB, err error)

AllUsers returns all users or an error if the database is corrupted.

func (*Database) BrokerForUser

func (c *Database) BrokerForUser(username string) (brokerID string, err error)

BrokerForUser returns the broker ID assigned to the given username, empty if it's not assigned yet or an error if no user was found in the database.

func (*Database) Close

func (c *Database) Close() error

Close closes the db and signal the monitoring goroutine to stop.

func (*Database) DeleteUser

func (c *Database) DeleteUser(uid uint32) error

DeleteUser removes the user from the database.

func (*Database) GroupByID

func (c *Database) GroupByID(gid uint32) (GroupDB, error)

GroupByID returns a group matching this gid or an error if the database is corrupted or no entry was found.

func (*Database) GroupByName

func (c *Database) GroupByName(name string) (GroupDB, error)

GroupByName returns a group matching a given name or an error if the database is corrupted or no entry was found.

func (*Database) GroupByUGID

func (c *Database) GroupByUGID(ugid string) (GroupDB, error)

GroupByUGID returns a group matching this ugid or an error if the database is corrupted or no entry was found.

func (*Database) UpdateBrokerForUser

func (c *Database) UpdateBrokerForUser(username, brokerID string) error

UpdateBrokerForUser updates the last broker the user successfully authenticated with.

func (*Database) UpdateUserEntry

func (c *Database) UpdateUserEntry(user UserDB, authdGroups []GroupDB, localGroups []string) error

UpdateUserEntry inserts or updates user and group buckets from the user information.

func (*Database) UserByID

func (c *Database) UserByID(uid uint32) (UserDB, error)

UserByID returns a user matching this uid or an error if the database is corrupted or no entry was found.

func (*Database) UserByName

func (c *Database) UserByName(name string) (UserDB, error)

UserByName returns a user matching this name or an error if the database is corrupted or no entry was found.

func (*Database) UserGroups

func (c *Database) UserGroups(uid uint32) ([]GroupDB, error)

UserGroups returns all groups for a given user or an error if the database is corrupted or no entry was found.

func (*Database) UserLocalGroups

func (c *Database) UserLocalGroups(uid uint32) ([]string, error)

UserLocalGroups returns all local groups for a given user or an error if the database is corrupted or no entry was found.

type GroupDB

type GroupDB struct {
	Name  string
	GID   uint32
	UGID  string
	Users []string
}

GroupDB is the struct stored in json format in the bucket.

func NewGroupDB

func NewGroupDB(name string, gid uint32, ugid string, members []string) GroupDB

NewGroupDB creates a new GroupDB.

type NoDataFoundError

type NoDataFoundError struct {
	// contains filtered or unexported fields
}

NoDataFoundError is returned when we didn’t find a matching entry.

func (NoDataFoundError) Error

func (err NoDataFoundError) Error() string

Error implements the error interface to return key/bucket name.

func (NoDataFoundError) Is

func (NoDataFoundError) Is(target error) bool

Is makes this error insensitive to the key and bucket name.

type UserDB

type UserDB struct {
	Name  string
	UID   uint32
	GID   uint32
	Gecos string // Gecos is an optional field. It can be empty.
	Dir   string
	Shell string

	// Shadow entries
	LastPwdChange  int
	MaxPwdAge      int
	PwdWarnPeriod  int
	PwdInactivity  int
	MinPwdAge      int
	ExpirationDate int
}

UserDB is the public type that is shared to external packages.

func NewUserDB

func NewUserDB(name string, uid, gid uint32, gecos, dir, shell string) UserDB

NewUserDB creates a new UserDB.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL