File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ Source code is also available at: https://github.com/snowflakedb/snowflake-conne
1515 - Added support for ` disable_saml_url_check ` connection parameter to disable SAML URL check in OKTA authentication.
1616 - Fixed a bug that OCSP certificate signed using SHA384 algorithm cannot be verified.
1717 - Fixed a bug that status code shown as uploaded when PUT command failed with 400 error.
18+ - Fixed a bug that a PermissionError was raised when the current user does not have the right permission on parent directory of config file path.
1819
1920- v3.10.1(May 21, 2024)
2021
Original file line number Diff line number Diff line change @@ -320,8 +320,15 @@ def read_config(
320320 ):
321321 if sliceoptions .only_in_slice :
322322 del read_config_file [section ]
323- if not filep .exists ():
323+ try :
324+ if not filep .exists ():
325+ continue
326+ except PermissionError :
327+ LOGGER .debug (
328+ f"Fail to read configuration file from { str (filep )} due to no permission on its parent directory"
329+ )
324330 continue
331+
325332 if (
326333 sliceoptions .check_permissions # Skip checking if this file couldn't hold sensitive information
327334 # Same check as openssh does for permissions
Original file line number Diff line number Diff line change 44
55from __future__ import annotations
66
7+ import logging
78import os .path
89import re
910import shutil
@@ -598,6 +599,34 @@ def test_warn_config_file_permissions(tmp_path):
598599 )
599600
600601
602+ @pytest .mark .skipif (IS_WINDOWS , reason = "chmod doesn't work on Windows" )
603+ def test_log_debug_config_file_parent_dir_permissions (tmp_path , caplog ):
604+ tmp_dir = tmp_path / "tmp_dir"
605+ tmp_dir .mkdir ()
606+ c_file = tmp_dir / "config.toml"
607+ c1 = ConfigManager (file_path = c_file , name = "root_parser" )
608+ c1 .add_option (name = "b" , parse_str = lambda e : e .lower () == "true" )
609+ c_file .write_text (
610+ dedent (
611+ """\
612+ b = true
613+ """
614+ )
615+ )
616+ mod = tmp_dir .stat ()
617+ tmp_dir .chmod (0 )
618+
619+ caplog .clear ()
620+
621+ with caplog .at_level (logging .DEBUG ):
622+ c1 .read_config ()
623+ assert not c1 .conf_file_cache
624+ assert "due to no permission on its parent directory" in caplog .text
625+
626+ tmp_dir .chmod (stat .S_IMODE (mod .st_mode ))
627+ shutil .rmtree (tmp_dir )
628+
629+
601630def test_configoption_missing_root_manager ():
602631 with pytest .raises (
603632 TypeError ,
You can’t perform that action at this time.
0 commit comments