Bug 224869

Summary: Python os.getenv calls should handle the env var being undefined
Product: WebKit Reporter: Sam Sneddon [:gsnedders] <gsnedders>
Component: Tools / TestsAssignee: Sam Sneddon [:gsnedders] <gsnedders>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, glenn, jbedard, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 224640    
Attachments:
Description Flags
Calls to os.getenv
none
Patch none

Description Sam Sneddon [:gsnedders] 2021-04-21 07:46:24 PDT
Created attachment 426681 [details]
Calls to os.getenv

See getenv.txt for a list.

The single-arg variant of os.getenv returns None when the environment variable is undefined. This can cause issues.

Note that this technically isn't blocking 224640, but per https://tox.readthedocs.io/en/latest/config.html#conf-passenv only a limited set of environment variables are passed through by default, and it would be good to avoid relying on anything else being defined by default.

Ignoring those in CISupport (which is also lower priority given we control the configuration in which it is run), having audited all of them, two calls are problematic when None is returned:

Tools/Scripts/webkitpy/common/checkout/scm/svn.py
56:    def has_authorization_for_realm(self, realm, home_directory=os.getenv("HOME")):

Tools/Scripts/webkitpy/common/system/executive.py
357:        command = ["killall", "-TERM", "-u", os.getenv("USER"), process_name]
Comment 1 Radar WebKit Bug Importer 2021-04-21 07:46:32 PDT
<rdar://problem/76958611>
Comment 2 Sam Sneddon [:gsnedders] 2021-04-21 07:56:18 PDT
Created attachment 426686 [details]
Patch
Comment 3 EWS 2021-04-21 10:58:53 PDT
Committed r276374 (236851@main): <https://commits.webkit.org/236851@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 426686 [details].