#1777 File parameter fails if prompted for
Closed: Fixed None Opened 12 years ago by mkosek.

https://bugzilla.redhat.com/show_bug.cgi?id=557163 [[BR]]
https://bugzilla.redhat.com/show_bug.cgi?id=737994

The File parameter (parameters.py line 1298) does not work properly unless it's provided on the command line. If the command prompts for the parameter it fails. For example if one has a file called "csr" containing a certificate signing request this works:

ipa cert-request --principal=foo/vm-041.idm.lab.bos.redhat.com csr

however this does not:

ipa cert-request --principal=foo/vm-041.idm.lab.bos.redhat.com
<csr>: csr
ipa: ERROR: Base64 decoding failed: Incorrect padding

The reason it fails is because the validation function is being called on the file name not the file contents:

The parameter is defined like this:

    takes_args = (
        File('csr', validate_csr,
            cli_name='csr_file',
        ),
    )

If csr is not provided on the command line it's prompted for and validate_csr is invoked being passed the filename entered on the command line, however validate_csr is expecting file contents.

The reason why it works when passed on the command line is because of the function load_files() in cli.py which is invoked in the run method of the command which loads the file contents and runs the validation routine on the file contents.

The problem occurs in prompt_interactively() in cli.py which calls the parameter like this:

value = param(raw, **kw)

which invokes the validation routine. But the raw value is what was read from the terminal, it's the file name. There is no mechanism to cause contents of the file to be read, so the validation routine sees the file name, not the file contents and it fails.

Metadata Update from @mkosek:
- Issue assigned to rcritten
- Issue set to the milestone: FreeIPA 2.1.2 (bug fixing)

7 years ago

Login to comment on this ticket.

Metadata