18370 a non-priv'd user in a ngz without connection to the GZ will result in a permissions error
authorBrock Pytlik <brock.pytlik@oracle.com>
Wed, 25 May 2011 16:19:24 -0700
changeset 2380 0f18e26e692c
parent 2379 292ebc6e9010
child 2381 45a20c3a277a
18370 a non-priv'd user in a ngz without connection to the GZ will result in a permissions error
src/modules/client/imageconfig.py
src/tests/cli/t_pkg_sysrepo.py
--- a/src/modules/client/imageconfig.py	Wed May 25 14:30:00 2011 -0700
+++ b/src/modules/client/imageconfig.py	Wed May 25 16:19:24 2011 -0700
@@ -873,6 +873,7 @@
                 else:
                         old_sysconfig = NullSystemPublisher()
 
+                write_sys_cfg = True
                 if use_system_pub:
                         # get new syspub data from sysdepot
                         try:
@@ -909,6 +910,7 @@
                                     sysdepot_uri)
                         except TransportFailures:
                                 self.sys_cfg = old_sysconfig
+                                write_sys_cfg = False
                         else:
                                 try:
                                         try:
@@ -942,6 +944,7 @@
                                                 # the ImageConfig.
                                                 self.sys_cfg = \
                                                     NullSystemPublisher()
+                                                write_sys_cfg = False
                                         else:
                                                 raise
                                 else:
@@ -964,11 +967,12 @@
                         self.sys_cfg = NullSystemPublisher()
                 self.__publishers, self.added_pubs, self.removed_pubs = \
                     self.__merge_publishers(self.img_cfg, self.sys_cfg,
-                        pkg_counts, old_sysconfig, self.__proxy_url)
+                        pkg_counts, old_sysconfig, self.__proxy_url,
+                        write_sys_cfg)
 
         @staticmethod
         def __merge_publishers(img_cfg, sys_cfg, pkg_counts, old_sysconfig,
-            proxy_url):
+            proxy_url, write_sys_cfg):
                 """This funcion merges an old publisher configuration from the
                 system repository with the new publisher configuration from the
                 system repository.  It retuns a tuple containing a dictionary
@@ -992,6 +996,9 @@
                 whether the system publisher should be used.
 
                 The 'proxy_url' parameter is the url for the system repository.
+
+                The 'write_sys_cfg' parameter indicates whether the new sys_cfg
+                object should attempt to save its configuration to disk.
                 """
 
                 pubs_with_installed_pkgs = set()
@@ -1016,7 +1023,8 @@
                         sys_cfg.publishers[prefix].disabled = True
 
                 # Write out the new system publisher configuration.
-                sys_cfg.write()
+                if write_sys_cfg:
+                        sys_cfg.write()
                 for p in sys_cfg.publishers.values():
                         for o in p.repository.origins:
                                 o.system = True
--- a/src/tests/cli/t_pkg_sysrepo.py	Wed May 25 14:30:00 2011 -0700
+++ b/src/tests/cli/t_pkg_sysrepo.py	Wed May 25 16:19:24 2011 -0700
@@ -1247,6 +1247,30 @@
                     (self.durl1, self.durl2, self.durl3)
                 self.__check_publisher_info(expected, su_wrap=True)
 
+                # Test that when the sysrepo isn't available, unprivileged users
+                # don't lose functionality.
+                self.sc.stop()
+                # Since the last priviledged command was done when no
+                # system-publishers were available, that's what's expected when
+                # the system repository isn't available.
+                expected = """\
+PUBLISHER\tSTICKY\tSYSPUB\tENABLED\tTYPE\tSTATUS\tURI
+"""
+                self.__check_publisher_info(expected, su_wrap=True)
+                self.pkg("property", su_wrap=True)
+                self.pkg("install foo", su_wrap=True, exit=1)
+
+                # Now do a privileged command command to change what the state
+                # on disk is.
+                self.sc.start()
+                expected =  self.expected_all_access % \
+                    (self.durl1, self.durl2, self.durl3)
+                self.__check_publisher_info(expected)
+                self.sc.stop()
+                self.__check_publisher_info(expected, su_wrap=True)
+                self.pkg("property", su_wrap=True)
+                self.pkg("install foo", su_wrap=True, exit=1)
+
 
         __smf_cmds_template = { \
             "usr/bin/svcprop" : """\