diff mbox series

[bitbake-devel] bitbake-hashclient: Warn on bad .netrc

Message ID 20240325155632.2002975-1-JPEWhacker@gmail.com
State New
Headers show
Series [bitbake-devel] bitbake-hashclient: Warn on bad .netrc | expand

Commit Message

Joshua Watt March 25, 2024, 3:56 p.m. UTC
If there is an error parsing .netrc, warn the user on stderr

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 bitbake/bin/bitbake-hashclient | 2 ++
 1 file changed, 2 insertions(+)

Comments

Paulo Neves April 13, 2024, 10:48 a.m. UTC | #1
What about wget.py@370?

except (FileNotFoundError, netrc.NetrcParseError):
    pass

Locally i added a the diagnostic as well because python added a permission check that will make bitbake silently
skip netrc authentication on a not obvious parsing errors. From the docs[1]:

> Parse errors will raise
[NetrcParseError](https://docs.python.org/3/library/netrc.html#netrc.NetrcParseError)
with diagnostic
> information including the file name, line number, and terminating token.
> If no argument is specified on a POSIX system, the presence of passwords in
> the

.netrc

file will raise a
[NetrcParseError](https://docs.python.org/3/library/netrc.html#netrc.NetrcParseError)
if the file
> ownership or permissions are insecure (owned by a user other than the user
> running the process, or accessible for read or write by any other user).
> This implements security behavior equivalent to that of ftp and other
> programs that use

.netrc

.

Paulo Neves

[1]
https://docs.python.org/3/library/netrc.html#netrc.netrc

On 3/25/24 16:56, Joshua Watt wrote:

> If there is an error parsing .netrc, warn the user on stderr
>
> Signed-off-by: Joshua Watt
> [<JPEWhacker@gmail.com>](mailto:JPEWhacker@gmail.com)
> ---
>  bitbake/bin/bitbake-hashclient | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/bitbake/bin/bitbake-hashclient b/bitbake/bin/bitbake-hashclient
> index 47dd27cd3c2..610787ed2b0 100755
> --- a/bitbake/bin/bitbake-hashclient
> +++ b/bitbake/bin/bitbake-hashclient
> @@ -346,6 +346,8 @@ def main():
>                  login, _, password = auth
>          except FileNotFoundError:
>              pass
> +        except netrc.NetrcParseError as e:
> +            sys.stderr.write(f"Error parsing {e.filename}:{e.lineno}: {e.msg}\n")
>
>      func = getattr(args, 'func', None)
>      if func:
> --
> 2.34.1
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#16013):
> https://lists.openembedded.org/g/bitbake-devel/message/16013
> Mute This Topic:
> https://lists.openembedded.org/mt/105140768/4454782
> Group Owner:
> bitbake-devel+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/bitbake-devel/unsub
> [
> paulo@myneves.com
> ]
> -=-=-=-=-=-=-=-=-=-=-=-
diff mbox series

Patch

diff --git a/bitbake/bin/bitbake-hashclient b/bitbake/bin/bitbake-hashclient
index 47dd27cd3c2..610787ed2b0 100755
--- a/bitbake/bin/bitbake-hashclient
+++ b/bitbake/bin/bitbake-hashclient
@@ -346,6 +346,8 @@  def main():
                 login, _, password = auth
         except FileNotFoundError:
             pass
+        except netrc.NetrcParseError as e:
+            sys.stderr.write(f"Error parsing {e.filename}:{e.lineno}: {e.msg}\n")
 
     func = getattr(args, 'func', None)
     if func: