Influxdb: influx cli client fails to prompt for password when redirecting output

Created on 10 Nov 2016  路  12Comments  路  Source: influxdata/influxdb

Bug report

__System info:__ influxdb-data-1.0.0-c1.0.0, CentOS 7

__Steps to reproduce:__

  1. Install InfluxDB with http.auth_enabled on and create admin user
  2. Use influx tool to authenticate using password prompt and execute query without output redirected to file

__Expected behavior:__ Password prompt would appear and output of query would be captured into file

__Actual behavior:__ Authorization failed error appears

[me@localhost ~]$ influx -username me -password '' -database _internal -execute 'show measurements'
password: 
name: measurements
------------------
name
cluster
cq
database
hh
hh_processor
httpd
queryExecutor
runtime
shard
subscriber
tsm1_cache
tsm1_engine
tsm1_filestore
tsm1_wal
write

[me@localhost ~]$ influx -username me -password '' -database _internal -execute 'show measurements' > ~/internal_measurements
authorization failed
arecli kinbug

Most helpful comment

Still a problem.

InfluxDB shell version: 1.6.0

All 12 comments

Looking at influx cli, I believe the issue stems from liner.PasswordPrompt redirect logic:

    // If we are going to be prompted for a password, always use the entered password.
    if promptForPassword {
        // Open the liner (temporarily) and prompt for the password.
        p, e := func() (string, error) {
            l := liner.NewLiner()
            defer l.Close()
            return l.PasswordPrompt("password: ")
        }()
        if e != nil {
            return errors.New("Unable to parse password")
        }
        c.Password = p
    } else if c.Password == "" {
        c.Password = os.Getenv("INFLUX_PASSWORD")
}
// PasswordPrompt displays p, and then waits for user input. The input typed by
// the user is not displayed in the terminal.
func (s *State) PasswordPrompt(prompt string) (string, error) {
    for _, r := range prompt {
        if unicode.Is(unicode.C, r) {
            return "", ErrInvalidPrompt
        }
    }
    if !s.terminalSupported {
        return "", errors.New("liner: function not supported in this terminal")
    }
    if s.inputRedirected {
        return s.promptUnsupported(prompt)
    }
    if s.outputRedirected {
        return "", ErrNotTerminalOutput
    }

defer s.stopPrompt()

I would really rather entering my password when prompted rather than use the INFLUX_PASSWORD environment variable or making it visible to process stack and/or bash history.

I think this was fixed with #7600. If this still isn't working with that change, please comment and I'll reopen this issue.

I was having this same problem ("liner: function not supported in this terminal>") with InfluxDB 1.3 over Docker TICK using a self-signed certificate.
I am not sure how I solved it: following the advice of https://github.com/influxdata/influxdb/issues/4090, I deleted my line in the server's .ssh/authorized_keys, I logged out and in again, but the same result.
Later I added again my key in .ssh/authorized_keys and, when I connected again, it just worked...
Some idea about the reason for this?

[Edit]
It is happening again, copy-paste:
root@:~/influx/TICK-docker/1.3# sudo docker-compose run influxdb-cli
Connected to http://influxdb:8086 version 1.3.5
InfluxDB shell version: 1.3.5

auth
username: admin
Unable to process input: liner: function not supported in this terminal>

same problem with Unable to process InfluxDB shell version: 1.3.7 and docker

same problem here:

Connected to http://influxdb:8086 version 1.4.2
InfluxDB shell version: 1.4.2

auth
username: admin
Unable to process input: liner: function not supported in this terminal>

i am facing the same problem with @rapport

I'm having the same problem using docker-compose on debian linux:

# docker-compose run influxdb-cli
Starting docker_influxdb_1 ... done
Connected to http://influxdb:8086 version 1.4.2
InfluxDB shell version: 1.4.2
> auth
username:
Unable to process input: liner: function not supported in this terminal>

I followed this error through the source back to the PasswordPrompt function in Liner. It looks either the terminal's columns are reported as 0, or the terminal is "not supported" by liner. The former looks related to this issue. The latter could be due to it having detected that STDIN/OUT are redirected, or some other unlikely scenarios.

I have not found a solution yet.

I came up with a workaround. Run a shell in the container, then manually start the influx cli from there.

# docker-compose run --entrypoint /bin/sh influxdb-cli
Starting docker_influxdb_1 ... done
/ # influx -host influxdb
Connected to http://influxdb:8086 version 1.4.2
InfluxDB shell version: 1.4.2
> auth
username: admin
password:

Same here with docker and Influxdb 1.5.

auth
username: admin
Unable to process input: liner: function not supported in this terminal>

Can you please reopen this issue? This is a bit annoying as more and more people are using docker images.

Still a problem.

InfluxDB shell version: 1.6.0

Please reopen the ticket. I'm seeing the same problem on 1.8.1.

Please reopen the ticket. I'm seeing the same problem on 1.8.2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

deepujain picture deepujain  路  3Comments

allenbunny picture allenbunny  路  3Comments

Raniz85 picture Raniz85  路  3Comments

jonira picture jonira  路  4Comments

binary0111 picture binary0111  路  3Comments