Skip to content

Commit e7d72f5

Browse files
authored
[Identity] Suppress stdin for subprocess-based creds (#31534)
In some cases, the underyling executable being called hangs waiting for user input. When calling the executables we should just ignore stdin. Signed-off-by: Paul Van Eck <paulvaneck@microsoft.com>
1 parent 7f6bb71 commit e7d72f5

7 files changed

Lines changed: 7 additions & 0 deletions

File tree

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Bugs Fixed
1010

1111
- Ensure `AzurePowershellCredential` calls PowerShell with the `-NoProfile` flag to avoid loading user profiles for more consistent behavior. ([#31682](https://github.com/Azure/azure-sdk-for-python/pull/31682))
12+
- Fixed an issue with subprocess-based developer credentials (such as AzureCliCredential) where the process would sometimes hang waiting for user input. ([#31534](https://github.com/Azure/azure-sdk-for-python/pull/31534))
1213

1314
### Other Changes
1415

sdk/identity/azure-identity/azure/identity/_credentials/azd_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def _run_command(command: str, timeout: int) -> str:
211211

212212
kwargs: Dict[str, Any] = {
213213
"stderr": subprocess.PIPE,
214+
"stdin": subprocess.DEVNULL,
214215
"cwd": working_directory,
215216
"universal_newlines": True,
216217
"env": dict(os.environ, NO_COLOR="true"),

sdk/identity/azure-identity/azure/identity/_credentials/azure_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def _run_command(command: str, timeout: int) -> str:
187187

188188
kwargs: Dict[str, Any] = {
189189
"stderr": subprocess.PIPE,
190+
"stdin": subprocess.DEVNULL,
190191
"cwd": working_directory,
191192
"universal_newlines": True,
192193
"timeout": timeout,

sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def start_process(args: List[str]) -> "subprocess.Popen":
158158
cwd=working_directory,
159159
stdout=subprocess.PIPE,
160160
stderr=subprocess.PIPE,
161+
stdin=subprocess.DEVNULL,
161162
universal_newlines=True,
162163
)
163164
return proc

sdk/identity/azure-identity/azure/identity/aio/_credentials/azd_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ async def _run_command(command: str, timeout: int) -> str:
158158
*args,
159159
stdout=asyncio.subprocess.PIPE,
160160
stderr=asyncio.subprocess.PIPE,
161+
stdin=asyncio.subprocess.DEVNULL,
161162
cwd=working_directory,
162163
env=dict(os.environ, NO_COLOR="true"),
163164
)

sdk/identity/azure-identity/azure/identity/aio/_credentials/azure_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ async def _run_command(command: str, timeout: int) -> str:
136136
*args,
137137
stdout=asyncio.subprocess.PIPE,
138138
stderr=asyncio.subprocess.PIPE,
139+
stdin=asyncio.subprocess.DEVNULL,
139140
cwd=working_directory,
140141
env=dict(os.environ, AZURE_CORE_NO_COLOR="true"),
141142
)

sdk/identity/azure-identity/azure/identity/aio/_credentials/azure_powershell.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,6 @@ async def start_process(command_line):
139139
cwd=working_directory,
140140
stdout=asyncio.subprocess.PIPE,
141141
stderr=asyncio.subprocess.PIPE,
142+
stdin=asyncio.subprocess.DEVNULL,
142143
)
143144
return proc

0 commit comments

Comments
 (0)