The following configuration works:
machine code.mycompany.net
login supernerd
password HelloW0rld
The following configuration doesn't work:
machine code.mycompany.net
login supernerd
password Please excuse my dear aunt sally.
The following configuration works:
machine code.mycompany.net
login supernerd
password HelloW0rld
The following configuration doesn't work:
machine code.mycompany.net
login supernerd
password Please excuse my dear aunt sally.
From this bug report (now python/cpython
issue 36615) or this page, spaces in password don't seem to be supported in a .netrc (
or _netrc
) file.
Or even if they are, not all the programs using that .netrc
file will be able to interpret said space correctly.
As runrig mentions in the comments:
Quoting the field as in another answer here should work, but the python library doesn't like it.
But, e.g., command lineftp
and theperl netrc
library is fine with it.
So this should work when used when those commands:
password "Please excuse my dear aunt sally."
Using ftp on IRIX 6.5 running on an SGI, I added quotes around my password and it works fine, e.g.:
password "Please excuse my dear aunt sally."
This is the tokenizer of the GNU Inetutils version 2.5:
token (void)
{
char *cp;
int c;
struct toktab *t;
if (feof (cfile) || ferror (cfile))
return (0);
while ((c = getc (cfile)) != EOF &&
(c == '\n' || c == '\t' || c == ' ' || c == ','))
continue;
if (c == EOF)
return (0);
cp = tokval;
if (c == '"')
{
while ((c = getc (cfile)) != EOF && c != '"')
{
if (c == '\\')
c = getc (cfile);
*cp++ = c;
}
}
else
{
*cp++ = c;
while ((c = getc (cfile)) != EOF
&& c != '\n' && c != '\t' && c != ' ' && c != ',')
{
if (c == '\\')
c = getc (cfile);
*cp++ = c;
}
}
*cp = 0;
if (tokval[0] == 0)
return (0);
for (t = toktab; t->tokstr; t++)
if (!strcmp (t->tokstr, tokval))
return (t->tval);
return (ID);
}
As you can see: tokens may be surrounded by double quotes.
if (c == '"')
{
while ((c = getc (cfile)) != EOF && c != '"')
{
if (c == '\\')
c = getc (cfile);
*cp++ = c;
}
}
I have studied wget's netrc.c; I hope most netrc parsers work similarly:
Note that #
after whitespace starts a comment until end of line.
A string can be put between double quotes (for example if the string starts
with #
, or contains a lot of whitespace that we don't want to backslash).
"#pass%"
"S3cret with spaces"
To make sure a character is understood as part of a string, prefix it with a backslash so that it is understood verbatim. This is supported with or without double quotes:
S3cret\ with\ spaces
\#not-a-comment
backslash:\\
"anything"
"double\"quote"
© 2022 - 2024 — McMap. All rights reserved.