up2date patch [was Re: [rhn-users] up2date...]

Bob Drzyzgula redhat at drzyzgula.org
Fri Mar 19 15:09:22 UTC 2004


On Thu, Mar 18, 2004 at 07:31:33PM -0500, Todd Warner wrote:
> 
> Patches gladly accepted. Send 'em our way and we'll take a look-see.
> rhnlib and up2date are GPLed software so... there you go.
> 
> Definately sounds like something is funky though. I will make sure the
> right people know about it.
> 
> -- 
> ____________
>  /odd Warner                                    <taw@{redhat,pobox}.com>
>           Bit Twiddler - Operation Cheetah Flip - Red Hat Inc.
> ---------------------gpg info in the message headers--------------------
> "But when you think about it, it's mostly the bad decisions we make
>  that change our lives. Good ones just get you home safely." -Chris Bliss

up2date patch:

# This is a patch against RHEL 3.0WS up2date-RHEL3-4.2.5
#
# This patch will
#  (a)  Add support for a configurable user agent string to
#       be used when connecting to the RHN server.
#  (b)  Support a new setting, "userAgent" in the
#       configuration file /etc/sysconfig/rhn/up2date
#  (c)  Support a new up2date command line option, --userAgent
#
# Source files affected by this are
#
#  config.py
#  wrapper.py
#  man/en/up2date.8
#  repoBackends/up2dateRepo.py
#
# This patch depends on parallel changes in rhnlib.
#
# Shortcomings of this patch include:
#
#  * the userAgent setting is only supported for RHN connections.
#  * a new i18n string _("User Agent String") has been added,
#    but no internationalizations of this string have been provided.
#  * the man page has been changed to document the --userAgent
#    option, this may need to be translated as well.
#
# This patch is provided as is, with no warranty.
#
# Bob Drzyzgula
# redhat at drzyzgula.org
#
diff -r -U 3 up2date-RHEL3-4.2.5.orig/config.py up2date-RHEL3-4.2.5.patched/config.py
--- up2date-RHEL3-4.2.5.orig/config.py	2003-10-07 22:35:22.000000000 -0400
+++ up2date-RHEL3-4.2.5.patched/config.py	2004-03-16 11:37:03.000000000 -0500
@@ -102,6 +102,7 @@
     'disallowConfChanges': ("Config options that can not be overwritten by a config update action",
                             ['sslCACert','useNoSSLForPackages','noSSLServerURL',
                              'serverURL','disallowConfChanges', 'noReboot']),
+    'userAgent'         : ("User-Agent header to use in xmlrpc connections", 0),
 }
 
 # a peristent configuration storage class
diff -r -U 3 up2date-RHEL3-4.2.5.orig/man/en/up2date.8 up2date-RHEL3-4.2.5.patched/man/en/up2date.8
--- up2date-RHEL3-4.2.5.orig/man/en/up2date.8	2003-11-04 16:18:24.000000000 -0500
+++ up2date-RHEL3-4.2.5.patched/man/en/up2date.8	2004-03-16 11:40:49.000000000 -0500
@@ -124,6 +124,9 @@
 Specify a password to use with an authenticated http
 proxy
 .TP
+\fB--userAgent\fR
+Specify the http user agent string to use 
+.TP
 \fB--show-package-dialog\fR
 Show the package installation dialog in gui mode
 .TP
diff -r -U 3 up2date-RHEL3-4.2.5.orig/repoBackends/up2dateRepo.py up2date-RHEL3-4.2.5.patched/repoBackends/up2dateRepo.py
--- up2date-RHEL3-4.2.5.orig/repoBackends/up2dateRepo.py	2003-11-04 15:00:21.000000000 -0500
+++ up2date-RHEL3-4.2.5.patched/repoBackends/up2dateRepo.py	2004-03-16 11:37:03.000000000 -0500
@@ -247,6 +247,7 @@
                             proxy = serverSettings.proxyUrl,
                             username = serverSettings.proxyUser,
                             password = serverSettings.proxyPassword,
+                            userAgent = serverSettings.userAgent,
                             headers = logininfo)
     server.add_header("X-Up2date-Version", up2dateUtils.version())
     return server
@@ -265,6 +266,7 @@
         self.proxyUrl = None
         self.proxyUser = None
         self.proxyPassword = None
+        self.userAgent = None
         
         if self.cfg["enableProxy"] and up2dateUtils.getProxySetting():
             self.proxyUrl = up2dateUtils.getProxySetting()
@@ -272,6 +274,9 @@
                 if self.cfg["proxyUser"] and self.cfg["proxyPassword"]:
                     self.proxyPassword = self.cfg["proxyPassword"]
                     self.proxyUser = self.cfg["proxyUser"]
+        
+        if self.cfg["userAgent"]:
+            self.userAgent = self.cfg["userAgent"]
                     
     def settings(self):
         return self.xmlrpcServerUrl, self.httpServerUrl, \
diff -r -U 3 up2date-RHEL3-4.2.5.orig/rpcServer.py up2date-RHEL3-4.2.5.patched/rpcServer.py
--- up2date-RHEL3-4.2.5.orig/rpcServer.py	2003-11-04 15:00:21.000000000 -0500
+++ up2date-RHEL3-4.2.5.patched/rpcServer.py	2004-03-16 11:37:03.000000000 -0500
@@ -73,11 +73,16 @@
             lang = string.split(lang, '.')[0]
             break
 
+    if cfg["userAgent"]:
+        userAgentString = cfg["userAgent"]
+    else:
+        userAgentString = None
         
     s = rpclib.Server(serverUrl, refreshCallback=refreshCallback,
                       proxy=proxyHost,
                       username=proxyUser,
-                      password=proxyPassword)
+                      password=proxyPassword,
+                      userAgent=userAgentString)
     s.add_header("X-Up2date-Version", up2dateUtils.version())
     
     if lang:
diff -r -U 3 up2date-RHEL3-4.2.5.orig/wrapper.py up2date-RHEL3-4.2.5.patched/wrapper.py
--- up2date-RHEL3-4.2.5.orig/wrapper.py	2003-11-11 17:57:03.000000000 -0500
+++ up2date-RHEL3-4.2.5.patched/wrapper.py	2004-03-16 11:40:11.000000000 -0500
@@ -189,6 +189,8 @@
      help=_("Force up2date to install this arch of the package. Not valid with -u, --list, or --dry-run")),
     Option(     "--upgrade-to-release", action="store", metavar="<release-version>",
       help=_("Upgrade to the channel specified")),
+    Option(     "--userAgent", action="store", metavar="<user agent>",
+      help=_("User Agent String")),
     ]
 
 def printUsage(poptContext, stream = sys.stdout):
@@ -553,6 +555,9 @@
         cfg.set("proxyPassword", options.proxyPassword)
         cfg.set("enableProxyAuth", 1)
         save_cfg = 1
+    if options.userAgent:
+        cfg.set("userAgent", options.userAgent)
+        save_cfg = 1
     if save_cfg:
         cfg.save()
 





More information about the rhn-users mailing list