7116135 pkg requires first portion of hostname in publisher URI to have more than one character s11-sru
authorSaurabh Vyas <saurabh.vyas@oracle.com>
Wed, 29 Feb 2012 10:23:27 +0530
branchs11-sru
changeset 2643 5e783bc49bd7
parent 2637 5b524def9b53
child 2645 4c497a5fde9e
7116135 pkg requires first portion of hostname in publisher URI to have more than one character
src/modules/misc.py
src/pkg/manifests/package:pkg.p5m
src/tests/cli/t_pkg_publisher.py
--- a/src/modules/misc.py	Fri Feb 24 11:31:13 2012 +0000
+++ b/src/modules/misc.py	Wed Feb 29 10:23:27 2012 +0530
@@ -20,7 +20,7 @@
 # CDDL HEADER END
 #
 
-# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
 
 import OpenSSL.crypto as osc
 import cStringIO
@@ -225,7 +225,12 @@
 
         return useragent
 
-_hostname_re = re.compile("^[a-zA-Z0-9\[](?:[a-zA-Z0-9\-:]*[a-zA-Z0-9:\]]+\.?)*$")
+# Valid hostname can be : HOSTNAME or IPv4 addr or IPV6 addr
+_hostname_re = re.compile(r"""^(?:[a-zA-Z0-9\-]+[a-zA-Z0-9\-\.]*
+                   |(?:\d{1,3}\.){3}\d{3}
+                   |\[([a-fA-F0-9\.]*:){,7}[a-fA-F0-9\.]+\])$""", re.X)
+
+
 _invalid_host_chars = re.compile(".*[^a-zA-Z0-9\-\.:\[\]]+")
 _valid_proto = ["file", "http", "https"]
 
--- a/src/pkg/manifests/package:pkg.p5m	Fri Feb 24 11:31:13 2012 +0000
+++ b/src/pkg/manifests/package:pkg.p5m	Wed Feb 29 10:23:27 2012 +0530
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 set name=pkg.fmri value=pkg:/package/pkg@$(PKGVERS)
@@ -30,7 +30,7 @@
 set name=pkg.linted.pkglint.manifest003.1 value=true
 set name=com.oracle.service.bugid \
     last-fmri=package/[email protected],5.11-0.175.0.1.0.4.2584:20111110T170548Z \
-    value=7147803
+    value=7147803 value=7116135
 set name=info.classification \
     value=org.opensolaris.category.2008:System/Packaging
 set name=variant.arch value=$(ARCH)
--- a/src/tests/cli/t_pkg_publisher.py	Fri Feb 24 11:31:13 2012 +0000
+++ b/src/tests/cli/t_pkg_publisher.py	Wed Feb 29 10:23:27 2012 +0530
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 import testutils
@@ -261,6 +261,11 @@
                 self.pkg("set-publisher -O ftp://%s2 test2" % self.bogus_url,
                     exit=1)
 
+                # Verify single character in hostname is valid publisher
+                self.pkg("set-publisher --no-refresh -g http://a/ a")
+                self.pkg("set-publisher --no-refresh -g http://a.example.com " \
+                    "a.example.com")
+
         def test_missing_perms(self):
                 """Bug 2393"""