Source: miniflux
Version: 2.2.12-1
Severity: normal
X-Debbugs-Cc: [email protected]

Dear Maintainer,

I noticed that miniflux's postins tries to create the admin account,
either upon package installation (when the right debconf values were
pre-seeded), or after the package is installed, via `dpkg-reconfigure
miniflux`.

However it doesn't work, here are some logs:

```
root# dpkg-reconfigure miniflux
dbconfig-common: writing config to /etc/dbconfig-common/miniflux.conf
dbconfig-common: flushing administrative password
usermod: no changes
level=INFO msg="Running database migrations" current_version=114 
latest_version=114
this is not an interactive terminal, exiting
```

Looking into the database confirms that no user was created:

```
root# sudo -i -u postgres psql
psql (15.14 (Debian 15.14-0+deb12u1))
Type "help" for help.

postgres=# \c miniflux
You are now connected to database "miniflux" as user "postgres".
miniflux=# SELECT id, username, is_admin, last_login_at FROM users;
 id | username | is_admin | last_login_at
----+----------+----------+---------------
(0 rows)
```

I did some research, it turns out that the breakage was caused by a
change upstream, the command `-create-admin` now insists that stdin must
be connected to a TTY, and fails otherwise. Here is the upstream change:

- https://github.com/miniflux/v2/issues/2555
- https://github.com/miniflux/v2/pull/2560/commits/fdc8e66

Ironically, it was commited just _one day_ after you implemented admin
account creation in the postinst...

I tried to trick miniflux like this:

```
root# { echo "myself"; echo "foobar"; } \
      | miniflux -c /etc/miniflux/miniflux.conf -create-admin
this is not an interactive terminal, exiting
```

Of course, it doesn't work.

AFAIK, there are 2 ways to create the miniflux admin account:
- use `-create-admin`, but now it needs a TTY
- use variables in the config file, but then we need to start the
  miniflux daemon for it to take effect

It seems that none are good for a postinst script...

My impression is that we could ask for a change upstream. There's no
need to insist on a TTY on stdin, they could change their code to
support something like `echo user\npass\n | miniflux -create-admin`.

In term of implementation, instead of proactively checking for a TTY via
`term.IsTerminal(fd)` (cf. [1]), maybe it's possible to handle errors
from either NewReader or ReadString. There should be some specific error
if stdin is closed.

What do you think?

Best,

Arnaud

[1] https://github.com/miniflux/v2/blob/main/internal/cli/ask_credentials.go

Reply via email to