MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _security_check

Method _security_check

tools/python-3.11.9-amd64/Lib/netrc.py:144–164  ·  view source on GitHub ↗
(self, fp, default_netrc, login)

Source from the content-addressed store, hash-verified

142 self._security_check(fp, default_netrc, self.hosts[entryname][0])
143
144 def _security_check(self, fp, default_netrc, login):
145 if os.name == 'posix' and default_netrc and login != "anonymous":
146 prop = os.fstat(fp.fileno())
147 if prop.st_uid != os.getuid():
148 import pwd
149 try:
150 fowner = pwd.getpwuid(prop.st_uid)[0]
151 except KeyError:
152 fowner = 'uid %s' % prop.st_uid
153 try:
154 user = pwd.getpwuid(os.getuid())[0]
155 except KeyError:
156 user = 'uid %s' % os.getuid()
157 raise NetrcParseError(
158 (f"~/.netrc file owner ({fowner}, {user}) does not match"
159 " current user"))
160 if (prop.st_mode & (stat.S_IRWXG | stat.S_IRWXO)):
161 raise NetrcParseError(
162 "~/.netrc access too permissive: access"
163 " permissions must restrict access to only"
164 " the owner")
165
166 def authenticators(self, host):
167 """Return a (user, account, password) tuple for given host."""

Callers 1

_parseMethod · 0.95

Calls 2

NetrcParseErrorClass · 0.85
filenoMethod · 0.45

Tested by

no test coverage detected