Package: release.debian.org Severity: normal User: release.debian....@packages.debian.org Usertags: unblock
Please unblock package goiardi It includes a backported fix for a server crash when handling objects with duplicate array items. It also removes the logs on purge, a change that should have been uploaded before the freeze but apparently didn't happen. unblock goiardi/0.11.2-2 The debdiff is as follows: +goiardi (0.11.2-2) unstable; urgency=medium + + * Remove /var/log/goiardi on purge as well (really closes: #847354). + * Add databag_duplicate_field_crash.patch: cherrypick a fix for a server + crash when handling objects with duplicate items in an array. + + -- Jordi Mallach <jo...@debian.org> Thu, 30 Mar 2017 02:51:02 +0200 + goiardi (0.11.2-1) unstable; urgency=medium * New upstream release. diff -Nru goiardi-0.11.2/debian/patches/databag_duplicate_field_crash.patch goiardi-0.11.2/debian/patches/databag_duplicate_field_crash.patch --- goiardi-0.11.2/debian/patches/databag_duplicate_field_crash.patch 1970-01-01 01:00:00.000000000 +0100 +++ goiardi-0.11.2/debian/patches/databag_duplicate_field_crash.patch 2017-03-30 02:50:08.000000000 +0200 @@ -0,0 +1,173 @@ +Index: goiardi/CHANGELOG +=================================================================== +--- goiardi.orig/CHANGELOG ++++ goiardi/CHANGELOG +@@ -4,6 +4,8 @@ + Does require rebuilding the search index. + * Allow using 'novault' as a build tag to avoid having to have the vault api + present when building goiardi. Not relevant to most people. ++* Backport fix for duplicate items in arrays in indexed objects crashing the ++ server when saving. + + + 0.11.1 +Index: goiardi/circle.yml +=================================================================== +--- goiardi.orig/circle.yml ++++ goiardi/circle.yml +@@ -1,6 +1,6 @@ + machine: + environment: +- GODIST: "go1.7.3.linux-amd64.tar.gz" ++ GODIST: "go1.7.4.linux-amd64.tar.gz" + dependencies: + pre: + - mkdir -p download +Index: goiardi/indexer/postgres_indexer.go +=================================================================== +--- goiardi.orig/indexer/postgres_indexer.go ++++ goiardi/indexer/postgres_indexer.go +@@ -21,6 +21,7 @@ import ( + "github.com/ctdk/goiardi/datastore" + "github.com/ctdk/goiardi/util" + "github.com/lib/pq" ++ "sort" + "strings" + ) + +@@ -146,6 +147,11 @@ func (p *PostgresIndex) SaveItem(obj Ind + return err + } + case []string: ++ // remove dupes from slices of strings like we're doing ++ // now with the trie index, both to reduce ambiguity and ++ // to maybe make the indexes just a little bit smaller ++ sort.Strings(v) ++ v = util.RemoveDupStrings(v) + for _, w := range v { + w = util.IndexEscapeStr(w) + w = strings.Replace(w, "\n", "\\n", -1) +Index: goiardi/search/search_test.go +=================================================================== +--- goiardi.orig/search/search_test.go ++++ goiardi/search/search_test.go +@@ -258,6 +258,14 @@ func TestSearchBasicQueryEscaped(t *test + } + } + ++func TestIndexDupes(t *testing.T) { ++ r, _ := role.New("idx_role") ++ r.Default["foo"] = "bar" ++ r.Default["notdupe"] = []string{"I", "am", "good"} ++ r.Default["dupes"] = []string{"I", "", "will", "", "cause", "problems", "I", ""} ++ r.Save() ++} ++ + // Probably don't want this as an always test, but it's handy to have available. + /* + func TestEmbiggenSearch(t *testing.T) { +Index: goiardi/util/string_test.go +=================================================================== +--- /dev/null ++++ goiardi/util/string_test.go +@@ -0,0 +1,37 @@ ++/* ++ * Copyright (c) 2013-2016, Jeremy Bingham (<jer...@goiardi.gl>) ++ * ++ * Licensed under the Apache License, Version 2.0 (the "License"); ++ * you may not use this file except in compliance with the License. ++ * You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, software ++ * distributed under the License is distributed on an "AS IS" BASIS, ++ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ++ * See the License for the specific language governing permissions and ++ * limitations under the License. ++ */ ++ ++package util ++ ++import ( ++ "sort" ++ "testing" ++) ++ ++func TestDupRemoval(t *testing.T) { ++ strs := []string{"This", "", "has", "", "some", "", "some", "dupes"} ++ sort.Strings(strs) ++ strs = RemoveDupStrings(strs) ++ chkmap := make(map[string]uint8) ++ for _, v := range strs { ++ chkmap[v]++ ++ } ++ for k, v := range chkmap { ++ if v > 1 { ++ t.Errorf("string '%s' had %d elements, should have had 1", k, v) ++ } ++ } ++} +Index: goiardi/util/strings.go +=================================================================== +--- goiardi.orig/util/strings.go ++++ goiardi/util/strings.go +@@ -84,3 +84,45 @@ func parseArray(array string) []string { + } + return results + } ++ ++// RemoveDupStrings removes duplicates from a slice of strings. The slice of ++// strings must be sorted before it's used with this function. ++func RemoveDupStrings(strs []string) []string { ++ for i, v := range strs { ++ // catches the case where we've sliced off all the duplicates, ++ // but if we don't break here checking the last element will ++ // needlessly keep marching down the remainder of the slice for ++ // no effect ++ if i > len(strs) { ++ break ++ } ++ j := 1 ++ s := 0 ++ for { ++ if i+j >= len(strs) { ++ break ++ } ++ if v == strs[i+j] { ++ j++ ++ s++ ++ } else { ++ break ++ } ++ } ++ if s == 0 { ++ continue ++ } ++ strs = delTwoPosElements(i+1, s, strs) ++ } ++ return strs ++} ++ ++// DelSliceElement removes an element from a slice of strings. ++func DelSliceElement(pos int, strs []string) []string { ++ return delTwoPosElements(pos, 1, strs) ++} ++ ++func delTwoPosElements(pos int, skip int, strs []string) []string { ++ strs = append(strs[:pos], strs[pos+skip:]...) ++ return strs ++} +Index: goiardi/util/util.go +=================================================================== +--- goiardi.orig/util/util.go ++++ goiardi/util/util.go +@@ -175,6 +175,8 @@ func Indexify(flattened map[string]inter + line := fmt.Sprintf("%s:%s", k, v) + readyToIndex = append(readyToIndex, line) + case []string: ++ sort.Strings(v) ++ v = RemoveDupStrings(v) + for _, w := range v { + //w = IndexEscapeStr(w) + line := fmt.Sprintf("%s:%s", k, w) diff -Nru goiardi-0.11.2/debian/patches/series goiardi-0.11.2/debian/patches/series --- goiardi-0.11.2/debian/patches/series 2017-01-17 11:11:34.000000000 +0100 +++ goiardi-0.11.2/debian/patches/series 2017-03-30 02:47:01.000000000 +0200 @@ -1 +1,2 @@ avoid_vault_import.patch +databag_duplicate_field_crash.patch diff -Nru goiardi-0.11.2/debian/postrm goiardi-0.11.2/debian/postrm --- goiardi-0.11.2/debian/postrm 2016-12-21 18:07:33.000000000 +0100 +++ goiardi-0.11.2/debian/postrm 2017-01-18 09:22:10.000000000 +0100 @@ -11,6 +11,7 @@ # Get rid of cruft rm -rf /var/lib/goiardi + rm -rf /var/log/goiardi rm -f /etc/goiardi/admin.pem \ /etc/goiardi/chef-validator.pem \ /etc/goiardi/chef-webui.pem -- System Information: Debian Release: 9.0 APT prefers unstable-debug APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.9.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=ca_ES.UTF-8, LC_CTYPE=ca_ES.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system)