pqutil

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSSLKeyUnknownOwnership    = errors.New("pq: could not get owner information for private key, may not be properly protected")
	ErrSSLKeyHasWorldPermissions = errors.New("pq: private key has world access; permissions should be u=rw,g=r (0640) if owned by root, or u=rw (0600), or less")
)
View Source
var WarnFD io.Writer = os.Stderr

Functions

func CheckPermissions added in v1.12.0

func CheckPermissions(fi os.FileInfo) error

func ErrNotExists added in v1.12.0

func ErrNotExists(err error) bool

ErrNotExists reports if err is a "path doesn't exist" type error.

fs.ErrNotExist is not enough, as "/dev/null/somefile" will return ENOTDIR instead of ENOENT.

func Home

func Home() string

Home gets the PostgreSQL configuration dir in the user's home directory: %APPDATA%/postgresql on Windows, and $HOME/.postgresql/postgresql.crt everywhere else.

Returns an empy string if no home directory was found.

Matches pqGetHomeDirectory() from PostgreSQL. https://github.com/postgres/postgres/blob/2b117bb/src/interfaces/libpq/fe-connect.c#L8214

func Join

func Join[S ~[]E, E ~string](s S) string

func ParseBool

func ParseBool(str string) (bool, error)

ParseBool is like strconv.ParseBool, but also accepts "yes"/"no" and "on"/"off".

func Pgpass

func Pgpass(passfile string) string

Pgpass gets the filepath to the pgpass file to use, returning "" if a pgpass file shouldn't be used.

func SSLKeyPermissions

func SSLKeyPermissions(sslkey string) error

SSLKeyPermissions checks the permissions on user-supplied SSL key files, which should have very little access. libpq does not check key file permissions on Windows.

If the file is owned by the same user the process is running as, the file should only have 0600. If the file is owned by root, and the group matches the group that the process is running in, the permissions cannot be more than 0640. The file should never have world permissions.

Returns an error when the permission check fails.

func User

func User() (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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