(self, fp, default_netrc, login)
| 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.""" |
no test coverage detected