gopass/pkg/fsutil/umask.go
google-labs-jules[bot] 86720090b6
docs: Add GoDoc to pkg and improve markdown files (#3251)
This change adds GoDoc comments to many of the public symbols in the
`pkg/` directory. It also includes various improvements to the
documentation in `README.md` and other markdown files in the `docs/`
directory.

This is a partial documentation effort, as requested by the user, to
get a pull request submitted quickly.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
2025-09-22 19:37:15 +02:00

30 lines
513 B
Go

package fsutil
import (
"os"
"strconv"
)
// Umask extracts the umask from the environment variables.
// It checks for GOPASS_UMASK and PASSWORD_STORE_UMASK.
// If neither is set, it returns the default umask of 0o77.
func Umask() int {
for _, en := range []string{"GOPASS_UMASK", "PASSWORD_STORE_UMASK"} {
um := os.Getenv(en)
if um == "" {
continue
}
iv, err := strconv.ParseInt(um, 8, 32)
if err != nil {
continue
}
if iv >= 0 && iv <= 0o777 {
return int(iv)
}
}
return 0o77
}