mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 00:22:28 +02:00
handle permission denied during cleanup
if the .well-known/acme-challenge was created before and the user has no permissions to delete it, it failed at cleanup.
This commit is contained in:
@@ -152,5 +152,8 @@ to serve all files under specified web root ({0})."""
|
|||||||
if exc.errno == errno.ENOTEMPTY:
|
if exc.errno == errno.ENOTEMPTY:
|
||||||
logger.debug("Challenges cleaned up but %s not empty",
|
logger.debug("Challenges cleaned up but %s not empty",
|
||||||
root_path)
|
root_path)
|
||||||
|
elif exc.errno == errno.EACCES:
|
||||||
|
logger.debug("Challenges cleaned up but no permissions for %s",
|
||||||
|
root_path)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
os.rmdir(leftover_path)
|
os.rmdir(leftover_path)
|
||||||
|
|
||||||
@mock.patch('os.rmdir')
|
@mock.patch('os.rmdir')
|
||||||
def test_cleanup_oserror(self, mock_rmdir):
|
def test_cleanup_permission_denied(self, mock_rmdir):
|
||||||
self.auth.prepare()
|
self.auth.prepare()
|
||||||
self.auth.perform([self.achall])
|
self.auth.perform([self.achall])
|
||||||
|
|
||||||
@@ -166,10 +166,22 @@ class AuthenticatorTest(unittest.TestCase):
|
|||||||
os_error.errno = errno.EACCES
|
os_error.errno = errno.EACCES
|
||||||
mock_rmdir.side_effect = os_error
|
mock_rmdir.side_effect = os_error
|
||||||
|
|
||||||
|
self.auth.cleanup([self.achall])
|
||||||
|
self.assertFalse(os.path.exists(self.validation_path))
|
||||||
|
self.assertTrue(os.path.exists(self.root_challenge_path))
|
||||||
|
|
||||||
|
@mock.patch('os.rmdir')
|
||||||
|
def test_cleanup_oserror(self, mock_rmdir):
|
||||||
|
self.auth.prepare()
|
||||||
|
self.auth.perform([self.achall])
|
||||||
|
|
||||||
|
os_error = OSError()
|
||||||
|
os_error.errno = errno.ENOENT
|
||||||
|
mock_rmdir.side_effect = os_error
|
||||||
|
|
||||||
self.assertRaises(OSError, self.auth.cleanup, [self.achall])
|
self.assertRaises(OSError, self.auth.cleanup, [self.achall])
|
||||||
self.assertFalse(os.path.exists(self.validation_path))
|
self.assertFalse(os.path.exists(self.validation_path))
|
||||||
self.assertTrue(os.path.exists(self.root_challenge_path))
|
self.assertTrue(os.path.exists(self.root_challenge_path))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main() # pragma: no cover
|
unittest.main() # pragma: no cover
|
||||||
|
|||||||
Reference in New Issue
Block a user