Title mb makehashes: Handle Permission Denieds Gracefully
Priority bug Status resolved
Superseder Nosy List poeml, toma
Assigned To poeml Keywords

Created on 2012-03-30.16:54:53 by toma, last changed by poeml.

msg368 (view) Author: toma Date: 2012-03-30.16:54:53
When there is a folder which is shielded from the public, mb crashes:

Traceback (most recent call last):
  File "/usr/bin/mb", line 1645, in <module>
    r = mirrordoctor.main()
  File "/usr/lib/pymodules/python2.6/", line 257, in main
    return self.cmd(args)
  File "/usr/lib/pymodules/python2.6/", line 280, in cmd
    retval = self.onecmd(argv)
  File "/usr/lib/pymodules/python2.6/", line 412, in onecmd
    return self._dispatch_cmd(handler, argv)
  File "/usr/lib/pymodules/python2.6/", line 1100, in _dispatch_cmd
    return handler(argv[0], opts, *args)
  File "/usr/bin/mb", line 1036, in do_makehashes
    src_basenames = set(os.listdir(src_dir))
OSError: [Errno 13] Permission denied: '/srv/kde/stable/4.8.2'


This setup is used by KDE to provide pre-release tarballs to packagers. When 
they are released, they get their public read bit set.

Mirrorbrain should not crash, but just give a warning and continue the hashing 
msg383 (view) Author: poeml Date: 2012-04-16.04:45:26
I see - I didn't foresee this use case yet. (I solved that in a different way, by 
setting ownership such that mb makehashes can always see all files.) Right, mb 
should not fail here. 
Thanks for the report!
msg394 (view) Author: toma Date: 2012-05-28.13:04:53
--- mb.orig     2012-05-28 13:03:55.000000000 +0000
+++ mb  2012-05-28 12:48:30.000000000 +0000
@@ -1040,7 +1040,11 @@
             # a set offers the fastest access for "foo in ..." lookups
-            src_basenames = set(os.listdir(src_dir))
+            try:
+                src_basenames = set(os.listdir(src_dir))
+            except os.error:
+                sys.stderr.write('Can not access directory: %r\n' % src_dir)
+                src_basenames = []
             if opts.verbose:
                 print 'Examining directory', src_dir
msg395 (view) Author: poeml Date: 2012-05-31.20:45:13
Great, thanks!! Submitted to svn trunk.
msg462 (view) Author: poeml Date: 2014-01-22.20:19:39
I'll close this bug since it's fixed in SVN and I don't expect problems. It'll ship 
with 2.18.0.
Date User Action Args
2014-01-22 20:19:39poemlsetstatus: testing -> resolved
messages: + msg462
2012-05-31 20:45:13poemlsetstatus: chatting -> testing
messages: + msg395
2012-05-28 13:04:53tomasetmessages: + msg394
2012-04-16 04:45:26poemlsetstatus: unread -> chatting
assignedto: poeml
messages: + msg383
nosy: + poeml
title: Handle Permission Denieds Gracefully -> mb makehashes: Handle Permission Denieds Gracefully
2012-03-30 16:54:53tomacreate