Skip to content

home directory lookup can fail #395

@kr

Description

@kr

Method setupSSLClientCertificates uses uses getpwuid_r (via user.Current) to find the user's home directory.

        // Automatically load certificates from ~/.postgresql.
        user, err := user.Current()
        if err != nil {
            // user.Current() might fail when cross-compiling.  We have to
            // ignore the error and continue without client certificates, since
            // we wouldn't know where to load them from.
            return
        }

It would be better to use the environment variable HOME (or, on windows, a combination of HOMEDRIVE and HOMEPATH). That way the user can control where it looks.

Avoiding os/user would also prevent having to call into cgo, which would make cross compiling a bit easier and behave more consistently. For example, the comment above about how the lookup "might fail" would no longer be necessary.

If this sounds ok, I'll send a patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions