diff options
author | Miloslav Trmač <mitr@redhat.com> | 2019-03-02 06:36:44 +0100 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2019-04-09 21:08:44 +0200 |
commit | 97c9115c02b05f9aa0120b84deffed8b7b3d6018 (patch) | |
tree | 97e103ca1c4186d554ddb36295739eb34e2c2ed8 /libpod/container_internal.go | |
parent | fe79bdd07e140176dc64ebef8da3eea2ae28b96b (diff) | |
download | podman-97c9115c02b05f9aa0120b84deffed8b7b3d6018.tar.gz podman-97c9115c02b05f9aa0120b84deffed8b7b3d6018.tar.bz2 podman-97c9115c02b05f9aa0120b84deffed8b7b3d6018.zip |
Potentially breaking: Make hooks sort order locale-independent
Don't sort OCI hooks using the locale collation order; it does not
make sense for the same system-wide directory to be interpreted differently
depending on the user's LC_COLLATE setting, and the language-specific
collation order can even change over time.
Besides, the current collation order determination code has never worked
with the most common LC_COLLATE values like en_US.UTF-8.
Ideally, we would like to just order based on Unicode code points
to be reliably stable, but the existing implementation is case-insensitive,
so we are forced to rely on the unicode case mapping tables at least.
(This gives up on canonicalization and width-insensitivity, potentially
breaking users who rely on these previously documented properties.)
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r-- | libpod/container_internal.go | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 22df36c11..485b43f7d 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -25,7 +25,6 @@ import ( opentracing "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "golang.org/x/text/language" kwait "k8s.io/apimachinery/pkg/util/wait" ) @@ -34,15 +33,6 @@ const ( artifactsDir = "artifacts" ) -var ( - // localeToLanguageMap maps from locale values to language tags. - localeToLanguageMap = map[string]string{ - "": "und-u-va-posix", - "c": "und-u-va-posix", - "posix": "und-u-va-posix", - } -) - // rootFsSize gets the size of the container's root filesystem // A container FS is split into two parts. The first is the top layer, a // mutable layer, and the rest is the RootFS: the set of immutable layers @@ -1283,48 +1273,15 @@ func (c *Container) saveSpec(spec *spec.Spec) error { return nil } -// localeToLanguage translates POSIX locale strings to BCP 47 language tags. -func localeToLanguage(locale string) string { - locale = strings.Replace(strings.SplitN(locale, ".", 2)[0], "_", "-", 1) - langString, ok := localeToLanguageMap[strings.ToLower(locale)] - if !ok { - langString = locale - } - return langString -} - // Warning: precreate hooks may alter 'config' in place. func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (extensionStageHooks map[string][]spec.Hook, err error) { - var locale string - var ok bool - for _, envVar := range []string{ - "LC_ALL", - "LC_COLLATE", - "LANG", - } { - locale, ok = os.LookupEnv(envVar) - if ok { - break - } - } - - langString := localeToLanguage(locale) - lang, err := language.Parse(langString) - if err != nil { - logrus.Warnf("failed to parse language %q: %s", langString, err) - lang, err = language.Parse("und-u-va-posix") - if err != nil { - return nil, err - } - } - allHooks := make(map[string][]spec.Hook) if c.runtime.config.HooksDir == nil { if rootless.IsRootless() { return nil, nil } for _, hDir := range []string{hooks.DefaultDir, hooks.OverrideDir} { - manager, err := hooks.New(ctx, []string{hDir}, []string{"precreate", "poststop"}, lang) + manager, err := hooks.New(ctx, []string{hDir}, []string{"precreate", "poststop"}) if err != nil { if os.IsNotExist(err) { continue @@ -1343,7 +1300,7 @@ func (c *Container) setupOCIHooks(ctx context.Context, config *spec.Spec) (exten } } } else { - manager, err := hooks.New(ctx, c.runtime.config.HooksDir, []string{"precreate", "poststop"}, lang) + manager, err := hooks.New(ctx, c.runtime.config.HooksDir, []string{"precreate", "poststop"}) if err != nil { if os.IsNotExist(err) { logrus.Warnf("Requested OCI hooks directory %q does not exist", c.runtime.config.HooksDir) |