Sunday, November 03, 2013

Overriding Yum "User-Agent" header

Last week I spent many hours figuring out why I couldn't use YUM successfully in my company network any more. Every YUM command I tried to run I always got the error:

[Errno 14] HTTP Error 503: Service Unavailable
Trying other mirror.

All the mirrors URL were working fine throughout an internet browser like Firefox or Chrome and I was pretty sure any proxy hadn't been implemented in the network, the only reason could be the Firewall.
Googling I found a possible reason could be that the Firewall was blocking specific "User-Agent" header, or more in general, blocking all the connection without a valid "User-Agent" header.
Digging deeper I discovered that YUM "User-Agent" header is managed in the file 

 /usr/lib/python2.6/site-packages/yum/yumRepo.py

said that, I just modified this line from:

'user_agent': default_grabber.opts.user_agent,

to:

 'user_agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0.5) Gecko/20120605 Firefox/10.0.5',

Et voilĂ , YUM is now working fine again!
Of course you can get the trick using any valid browser "User-Agent" header.

Remember to do the trick again every time you update YUM it self.

I don't know if this is the best workaround, but it worked for me and my network configuration.

Hope you find it useful

Emilio


1 comment:

Anonymous said...

Thanks!