Discussion:
[fossil-users] "remember this password (Y/n)?" and `isatty()`
Eduard
2018-06-08 08:47:20 UTC
Permalink
Hi,

I would like to be able to non-interactively set `remote-url` and make
Fossil remember the password. The `isatty()` check makes that far more
difficult than it should be. Maybe it would be possible to add a
command-line switch to force it to remember the password, or a switch to
make it pretend stdin is a tty?

Best,
Eduard
Warren Young
2018-06-08 14:24:24 UTC
Permalink
Maybe it would be possible to add a command-line switch to force it to remember the password, or a switch to make it pretend stdin is a tty?
It looks like that last is already available: -interactive.

I’m not aware of any place that all of the global options to Fossil are documented. I had to dig through the command line parser in main() within src/shell.c to find it.

I’m not certain that this option will affect your symptom. If not, let us know exactly what method you’re trying and what symptom you get when it fails, if it does.
Eduard
2018-06-08 23:08:50 UTC
Permalink
The '--interactive' switch is only for the sqlite shell I think. It is
not accepted for the remote-url command.

Simple test case:

$ fossil remote-url https://a:***@example.com/
remember password (Y/n)? y
https://***@example.com/
$ yes | fossil remote-url https://a:***@example.com/
https://***@example.com/

The problem is that `save_password_prompt` never gets called if the
stdin is not a tty. There are two code paths leading to it, and both are
guarded by `isatty(fileno(stdin))`:

https://fossil-scm.org/index.html/artifact?udc=1&name=61b100991bd4e137&ln=279-280
https://fossil-scm.org/index.html/artifact?udc=1&name=61b100991bd4e137&ln=552+561

I think one fix is to factor out the `isatty(fileno(stdin))` in a
separate function, which checks the environment for a
`FOSSIL_FORCE_INTERACTIVE` variable (or a new global command-line switch).

That, and/or add a `--remember-password` option to `remote-url`.
Post by Warren Young
Maybe it would be possible to add a command-line switch to force it to remember the password, or a switch to make it pretend stdin is a tty?
It looks like that last is already available: -interactive.
I’m not aware of any place that all of the global options to Fossil are documented. I had to dig through the command line parser in main() within src/shell.c to find it.
I’m not certain that this option will affect your symptom. If not, let us know exactly what method you’re trying and what symptom you get when it fails, if it does.
_______________________________________________
fossil-users mailing list
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
Warren Young
2018-06-13 17:36:17 UTC
Permalink
The '--interactive' switch is only for the sqlite shell I think. It is not accepted for the remote-url command.
So reflect the same feature into main() within src/main.c. Then test the global variable stdin_is_interactive wherever isatty(stdin) is currently used.
Loading...