Commit 44292158 authored by Alexander Pace's avatar Alexander Pace
Browse files

removing unneeded patches

parent 54b31680
From be7992f35ab4ed7ed9907319b429dc079c2b7285 Mon Sep 17 00:00:00 2001
From: "Jan Alexander Steffens (heftig)" <jan.steffens@gmail.com>
Date: Tue, 11 Jul 2017 21:52:37 +0200
Subject: [PATCH] avahi-python: Use the agnostic DBM interface
Also fixes configure failing if Python 3 is the build python and GDBM is
enabled, since Py3 only has anydbm under the name of 'dbm'.
Not enough to make ServiceTypeDatabase.py compatible with Py3, but it's
a start.
(cherry picked from commit 63750f1be96ad08c407193b08bf3b9ee74310e2d)
Related: #1561019
---
avahi-python/avahi/Makefile.am | 15 +----------
avahi-python/avahi/ServiceTypeDatabase.py.in | 33 ++++++++++++++++++-------
configure.ac | 9 +++----
service-type-database/Makefile.am | 18 +++-----------
service-type-database/{build-db.in => build-db} | 13 +++++++---
5 files changed, 42 insertions(+), 46 deletions(-)
rename service-type-database/{build-db.in => build-db} (87%)
diff --git a/avahi-python/avahi/Makefile.am b/avahi-python/avahi/Makefile.am
index 3eb67d0..c906b9b 100644
--- a/avahi-python/avahi/Makefile.am
+++ b/avahi-python/avahi/Makefile.am
@@ -25,29 +25,16 @@ avahidir = $(pythondir)/avahi
if HAVE_GDBM
nodist_avahi_SCRIPTS = ServiceTypeDatabase.py
-
-ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
- $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,gdbm,g' \
- -e 's,@FIRST_KEY\@,key = self.db.firstkey(),g' \
- -e 's,@CHECK_KEY\@,while key is not None:,g' \
- -e 's,@NEXT_KEY\@,key = self.db.nextkey(key),g' \
- -e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \
- chmod +x $@
endif
if HAVE_DBM
nodist_avahi_SCRIPTS = ServiceTypeDatabase.py
+endif
ServiceTypeDatabase.py: ServiceTypeDatabase.py.in
$(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,dbm,g' \
- -e 's,@FIRST_KEY\@,keys = self.db.keys(),g' \
- -e 's,@CHECK_KEY\@,for key in keys:,g' \
- -e 's,@NEXT_KEY\@,,g' \
-e 's,@pkglibdatadir\@,$(pkglibdatadir),g' $< > $@ && \
chmod +x $@
-endif
avahi_PYTHON = $(avahi_SCRIPTS)
diff --git a/avahi-python/avahi/ServiceTypeDatabase.py.in b/avahi-python/avahi/ServiceTypeDatabase.py.in
index 4ddd654..d7f9969 100644
--- a/avahi-python/avahi/ServiceTypeDatabase.py.in
+++ b/avahi-python/avahi/ServiceTypeDatabase.py.in
@@ -17,7 +17,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-import @DBM@
+try:
+ import anydbm as dbm
+except ImportError:
+ import dbm
+
import locale
import re
@@ -28,7 +32,7 @@ class ServiceTypeDatabase:
def __init__(self, filename = "@pkglibdatadir@/service-types.db"):
- self.db = @DBM@.open(filename, "r")
+ self.db = dbm.open(filename, "r")
l = locale.getlocale(locale.LC_MESSAGES)
@@ -90,13 +94,24 @@ class ServiceTypeDatabase:
def __iter__(self):
- @FIRST_KEY@
- @CHECK_KEY@
-
- if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key) and not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
- yield key
-
- @NEXT_KEY@
+ def want_key(key):
+ if not re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+', key):
+ return False
+ if re.search('_[a-zA-Z0-9-]+\._[a-zA-Z0-9-]+\[.*\]', key):
+ return False
+ return True
+
+ try:
+ key = self.db.firstkey()
+ except AttributeError:
+ for key in self.db.keys():
+ if want_key(key):
+ yield key
+ else:
+ while key is not None:
+ if want_key(key):
+ yield key
+ key = self.db.nextkey(key)
def __len__(self):
diff --git a/configure.ac b/configure.ac
index 6678971..fbbf7cf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -824,11 +824,10 @@ if test "x$HAVE_PYTHON" = "xyes" ; then
fi
AM_CHECK_PYMOD(socket,,,[AC_MSG_ERROR(Could not find Python module socket)])
- if test "x$HAVE_GDBM" = "xyes"; then
- AM_CHECK_PYMOD(gdbm,,,[AC_MSG_ERROR(Could not find Python module gdbm)])
- fi
- if test "x$HAVE_DBM" = "xyes"; then
- AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
+ if test "x$HAVE_GDBM" = "xyes" || test "x$HAVE_DBM" = "xyes"; then
+ AM_CHECK_PYMOD(anydbm,,,[
+ AM_CHECK_PYMOD(dbm,,,[AC_MSG_ERROR(Could not find Python module dbm)])
+ ])
fi
fi
fi
diff --git a/service-type-database/Makefile.am b/service-type-database/Makefile.am
index d184fde..f9fa082 100644
--- a/service-type-database/Makefile.am
+++ b/service-type-database/Makefile.am
@@ -15,7 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-EXTRA_DIST=build-db.in service-types
+EXTRA_DIST=service-types
pkglibdatadir=$(libdir)/avahi
@@ -27,16 +27,11 @@ if HAVE_GDBM
noinst_SCRIPTS=build-db
pkglibdata_DATA+=service-types.db
-build-db: build-db.in
- $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,gdbm,g' $< > $@ && \
- chmod +x $@
-
-service-types.db: service-types build-db
+service-types.db: service-types
$(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
mv $@.coming $@
-CLEANFILES = service-types.db build-db
+CLEANFILES = service-types.db
endif
if HAVE_DBM
@@ -44,11 +39,6 @@ if HAVE_DBM
noinst_SCRIPTS=build-db
pkglibdata_DATA+=service-types.db.pag service-types.db.dir
-build-db: build-db.in
- $(AM_V_GEN)sed -e 's,@PYTHON\@,$(PYTHON),g' \
- -e 's,@DBM\@,dbm,g' $< > $@ && \
- chmod +x $@
-
service-types.db.pag: service-types.db
$(AM_V_GEN)mv service-types.db.coming.pag service-types.db.pag
service-types.db.dir: service-types.db
@@ -57,7 +47,7 @@ service-types.db: service-types build-db
$(AM_V_GEN)$(PYTHON) build-db $< $@.coming && \
if test -f "$@.coming"; then mv $@.coming $@; fi
-CLEANFILES = service-types.db* build-db
+CLEANFILES = service-types.db*
endif
endif
diff --git a/service-type-database/build-db.in b/service-type-database/build-db
similarity index 87%
rename from service-type-database/build-db.in
rename to service-type-database/build-db
index 4cda425..78ee892 100755
--- a/service-type-database/build-db.in
+++ b/service-type-database/build-db
@@ -1,4 +1,4 @@
-#!@PYTHON@
+#!/usr/bin/env python
# -*-python-*-
# This file is part of avahi.
#
@@ -17,7 +17,12 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
-import @DBM@, sys
+try:
+ import anydbm as dbm
+except ImportError:
+ import dbm
+
+import sys
if len(sys.argv) > 1:
infn = sys.argv[1]
@@ -29,9 +34,9 @@ if len(sys.argv) > 2:
else:
outfn = infn + ".db"
-db = @DBM@.open(outfn, "n")
+db = dbm.open(outfn, "n")
-for ln in file(infn, "r"):
+for ln in open(infn, "r"):
ln = ln.strip(" \r\n\t")
if ln == "" or ln.startswith("#"):
--
2.14.3
From 3303a8a621467dd7be67cec211fe417e9c81946f Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Fri, 27 Apr 2018 11:09:07 +0100
Subject: [PATCH] avahi-python: Encode unicode strings as UTF-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Previously, we would effectively encode anything representable in
Latin-1 as Latin-1, and crash on anything not representable in Latin-1:
>>> import avahi
>>> avahi.string_to_byte_array(u'©')
[dbus.Byte(169)]
>>> avahi.string_to_byte_array(u'\ufeff')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/avahi/__init__.py", line 94, in string_to_byte_array
r.append(dbus.Byte(ord(c)))
ValueError: Integer outside range 0-255
This is particularly important for Python 3, where the str type
is a Unicode string.
The b'' syntax for bytestrings is supported since at least Python 2.7.
These functions now accept either Unicode strings (Python 2 unicode,
Python 3 str), which are encoded in UTF-8, or bytestrings
(Python 2 str, Python 3 bytes) which are taken as-is.
Signed-off-by: Simon McVittie <smcv@debian.org>
(cherry picked from commit 169e85dbc13dcaae8a699618883e512614f540b7)
Related: #1561019
---
avahi-python/avahi/__init__.py | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/avahi-python/avahi/__init__.py b/avahi-python/avahi/__init__.py
index 7b45029..02305b0 100644
--- a/avahi-python/avahi/__init__.py
+++ b/avahi-python/avahi/__init__.py
@@ -17,6 +17,8 @@
# Some definitions matching those in avahi-common/defs.h
+import sys
+
import dbus
SERVER_INVALID, SERVER_REGISTERING, SERVER_RUNNING, SERVER_COLLISION, SERVER_FAILURE = range(0, 5)
@@ -66,6 +68,9 @@ DBUS_INTERFACE_HOST_NAME_RESOLVER = DBUS_NAME + ".HostNameResolver"
DBUS_INTERFACE_SERVICE_RESOLVER = DBUS_NAME + ".ServiceResolver"
DBUS_INTERFACE_RECORD_BROWSER = DBUS_NAME + ".RecordBrowser"
+if sys.version_info[0] >= 3:
+ unicode = str
+
def byte_array_to_string(s):
r = ""
@@ -86,12 +91,19 @@ def txt_array_to_string_array(t):
return l
-
def string_to_byte_array(s):
+ if isinstance(s, unicode):
+ s = s.encode('utf-8')
+
r = []
for c in s:
- r.append(dbus.Byte(ord(c)))
+ if isinstance(c, int):
+ # Python 3: iterating over bytes yields ints
+ r.append(dbus.Byte(c))
+ else:
+ # Python 2: iterating over str yields str
+ r.append(dbus.Byte(ord(c)))
return r
@@ -107,6 +119,12 @@ def dict_to_txt_array(txt_dict):
l = []
for k,v in txt_dict.items():
- l.append(string_to_byte_array("%s=%s" % (k,v)))
+ if isinstance(k, unicode):
+ k = k.encode('utf-8')
+
+ if isinstance(v, unicode):
+ v = v.encode('utf-8')
+
+ l.append(string_to_byte_array(b"%s=%s" % (k,v)))
return l
--
2.14.3
From ffb19d8f3c7f1fe4f31f79f8601dd3079730401b Mon Sep 17 00:00:00 2001
From: Simon McVittie <smcv@debian.org>
Date: Fri, 27 Apr 2018 09:01:13 +0100
Subject: [PATCH] Remove empty avahi_discover Python module
The avahi-discover tool no longer has any code outside its main
executable, so it does not need to install library modules. Its only
library code was avahi_discover.SimpleGladeApp, which was removed
in 2009.
Signed-off-by: Simon McVittie <smcv@debian.org>
---
avahi-python/avahi-discover/Makefile.am | 6 ------
avahi-python/avahi-discover/__init__.py | 18 ------------------
2 files changed, 24 deletions(-)
delete mode 100755 avahi-python/avahi-discover/__init__.py
diff --git a/avahi-python/avahi-discover/Makefile.am b/avahi-python/avahi-discover/Makefile.am
index 5fc4b25..bb4d717 100644
--- a/avahi-python/avahi-discover/Makefile.am
+++ b/avahi-python/avahi-discover/Makefile.am
@@ -18,7 +18,6 @@
AM_CFLAGS=-I$(top_srcdir)
EXTRA_DIST = \
- __init__.py \
avahi-discover.py \
avahi-discover.desktop.in.in
@@ -31,15 +30,11 @@ pythonscripts =
desktopdir = $(datadir)/applications
desktop_DATA =
-avahi_discoverdir = $(pythondir)/avahi_discover
-avahi_discover_PYTHON =
-
if HAVE_GDBM
pythonscripts += \
avahi-discover
desktop_DATA += avahi-discover.desktop
@INTLTOOL_DESKTOP_RULE@
-avahi_discover_PYTHON += __init__.py
endif
if HAVE_DBM
@@ -47,7 +42,6 @@ pythonscripts += \
avahi-discover
desktop_DATA += avahi-discover.desktop
@INTLTOOL_DESKTOP_RULE@
-avahi_discover_PYTHON += __init__.py
endif
avahi-discover.desktop.in: avahi-discover.desktop.in.in
diff --git a/avahi-python/avahi-discover/__init__.py b/avahi-python/avahi-discover/__init__.py
deleted file mode 100755
index 6f3ec7f..0000000
--- a/avahi-python/avahi-discover/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-#!@PYTHON@
-# -*-python-*-
-# This file is part of avahi.
-#
-# avahi is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# avahi is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
-# License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with avahi; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA.
--
2.14.3
From 374245ec1418e7e1e57120fcaf0a12ec695f5f6d Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Wed, 24 Oct 2018 15:22:19 +0000
Subject: [PATCH] avahi-client: fix resource leak
---
avahi-client/browser.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/avahi-client/browser.c b/avahi-client/browser.c
index c978d94..fa4a9a8 100644
--- a/avahi-client/browser.c
+++ b/avahi-client/browser.c
@@ -72,6 +72,8 @@ static void parse_domain_file(AvahiDomainBrowser *b) {
if (avahi_normalize_name(buf, domain, sizeof(domain)))
b->static_browse_domains = avahi_string_list_add(b->static_browse_domains, domain);
}
+
+ fclose(f);
}
static void domain_browser_ref(AvahiDomainBrowser *db) {
--
2.17.2
From 4b48927e8e2c721d103018b4ce39a164b6c2898f Mon Sep 17 00:00:00 2001
From: Michal Sekletar <msekleta@redhat.com>
Date: Wed, 24 Oct 2018 15:38:48 +0000
Subject: [PATCH] chroot: fix bogus assignments in assertions
---
avahi-daemon/chroot.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/avahi-daemon/chroot.c b/avahi-daemon/chroot.c
index ccd56be..871b3b3 100644
--- a/avahi-daemon/chroot.c
+++ b/avahi-daemon/chroot.c
@@ -188,8 +188,8 @@ static int recv_fd(int fd) {
return -1;
}
- assert(h->cmsg_len = CMSG_LEN(sizeof(int)));
- assert(h->cmsg_level = SOL_SOCKET);
+ assert(h->cmsg_len == CMSG_LEN(sizeof(int)));
+ assert(h->cmsg_level == SOL_SOCKET);
assert(h->cmsg_type == SCM_RIGHTS);
return *((int*)CMSG_DATA(h));
--
2.17.2
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment