Skip to content

s3cmd --configure crashes with env variable only AWS_ACCESS_KEY_ID set #1201

@martnst

Description

@martnst

Steps to reproduce:

  1. Build a Docker image

    # Dockerfile 
    FROM ubuntu:20.04
    RUN apt-get update && apt-get install -y s3cmd
    $ docker build . -t my-image
  2. Create a docker container with just AWS_ACCESS_KEY_ID but not AWS_SECRET_ACCESS_KEY set.

    $ docker run --rm -it --env AWS_ACCESS_KEY_ID=1234567800000 my-image /bin/bash
  3. Verify the ENV variables in question.

    root@730f1ea70045:/# echo $AWS_ACCESS_KEY_ID              
    1234567800000
    root@730f1ea70045:/# echo $AWS_SECRET_ACCESS_KEY
    
    root@730f1ea70045:/# 
  4. Run $ s3cmd --configure

    root@730f1ea70045:/# s3cmd --configure

Actual behavior:

root@730f1ea70045:/# s3cmd --configure
    
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    An unexpected error has occurred.
  Please try reproducing the error using
  the latest s3cmd code from the git master
  branch found at:
    https://github.com/s3tools/s3cmd
  and have a look at the known issues list:
    https://github.com/s3tools/s3cmd/wiki/Common-known-issues-and-their-solutions
  If the error persists, please report the
  following lines (removing any private
  info as necessary) to:
   s3tools-bugs@lists.sourceforge.net


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Invoked as: /usr/bin/s3cmd --configure
Problem: <class 'TypeError: decoding to str: need a bytes-like object, NoneType found
S3cmd:   2.0.2
python:   3.8.10 (default, Jun  2 2021, 10:49:15) 
[GCC 9.4.0]
Traceback (most recent call last):
  File "/usr/bin/s3cmd", line 3092, in <module>
    rc = main()
  File "/usr/bin/s3cmd", line 2792, in main
    cfg = Config(options.config, options.access_key, options.secret_key, options.access_token)
  File "/usr/lib/python3/dist-packages/S3/Config.py", line 239, in __init__
    self.secret_key = config_unicodise(env_secret_key)
  File "/usr/lib/python3/dist-packages/S3/Config.py", line 49, in config_unicodise
    return unicode(string, encoding, errors)
TypeError: decoding to str: need a bytes-like object, NoneType found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/s3cmd", line 3172, in <module>
    report_exception(e)
  File "/usr/bin/s3cmd", line 3047, in report_exception
    sys.stderr.write(u"environment LANG=%s\n" % unicodise_s(os.getenv("LANG"), 'ascii'))
  File "/usr/lib/python3/dist-packages/S3/Utils.py", line 321, in unicodise_s
    return unicodise(string, encoding, errors, True)
  File "/usr/lib/python3/dist-packages/S3/Utils.py", line 312, in unicodise
    return unicode(string, encoding, errors)
TypeError: decoding to str: need a bytes-like object, NoneType found

Expected behavior:
It should fail gracefully. Best, only picking up the Access Key from env variables while asking the Secret Key without prefilled value.

Regards,
Martin

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions