mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
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>
30 lines
513 B
Go
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
|
|
}
|