MCPcopy Index your code
hub / github.com/python/cpython / _security_check

Method _security_check

Lib/netrc.py:163–176  ·  view source on GitHub ↗
(self, fp)

Source from the content-addressed store, hash-verified

161 return
162
163 def _security_check(self, fp):
164 prop = os.fstat(fp.fileno())
165 current_user_id = os.getuid()
166 if prop.st_uid != current_user_id:
167 fowner = _getpwuid(prop.st_uid)
168 user = _getpwuid(current_user_id)
169 raise NetrcParseError(
170 f"~/.netrc file owner ({fowner}) does not match"
171 f" current user ({user})")
172 if (prop.st_mode & (stat.S_IRWXG | stat.S_IRWXO)):
173 raise NetrcParseError(
174 "~/.netrc access too permissive: access"
175 " permissions must restrict access to only"
176 " the owner")
177
178 def authenticators(self, host):
179 """Return a (user, account, password) tuple for given host."""

Callers 1

_parseMethod · 0.95

Calls 3

_getpwuidFunction · 0.85
NetrcParseErrorClass · 0.85
filenoMethod · 0.45

Tested by

no test coverage detected