Forum OpenACS Q&A: Error with proxy::exec

Collapse
Posted by Claudio Pasolini on
I'm trying to copy a file into an S3 bucket via 'exec aws s3 ...' but i'm getting 'Unable to locate credentials' error.

The credentials are there where expected and running the command in a system shell works fine.

Running 'exec whoami' returns the expected user, but running 'exec ls ~' returns ls: cannot access '~': No such file or directory.

Replacing exec with the original real_exec works well and so it seems that the problem lies in proxy::exec.

Collapse
2: Re: Error with proxy::exec (response to 1)
Posted by Claudio Pasolini on
I forgot to mention that I'm using OpenACS 5.10.0 and NaviServer 4.99.26 on Debian 11.

Just to be clear, actually if a proxied process make reference to '~' it breaks.

Collapse
3: Re: Error with proxy::exec (response to 1)
Posted by Gustaf Neumann on
Dear Claudio,

I think you are addressing two issues:

1. tilde expansion in Tcl
2. locating credentials / accessing home directory

Tilde expansion in Tcl is being phased out [1], so i would not recommend to build upon it. Nevertheless, "exec ls ~" never worked in a tclsh AFIKT:

$ tclsh8.5
% exec ls ~
ls: ~: No such file or directory

$ tclsh8.6 % exec ls ~ ls: ~: No such file or directory

$ tclsh8.7 % exec ls ~ ls: ~: No such file or directory

$ tclsh9.0 % exec ls ~ ls: ~: No such file or directory

One can get the expansion by calling bash via exec.

I am not an AWS user, but according to the online documentation [2], there are multiple ways of addressing the credentials. Since OpenACS runs under the specified OpenACS user (e.g., nsadmin), you could add the environment variable USER to your setup, or you can specify "/home/nsadmin/.aws/config" since, i assume, OpenACS is always running with the same user in your environment...

[1] https://wiki.tcl-lang.org/page/Tilde+Substitution
[2] https://repost.aws/knowledge-center/s3-locate-credentials-error

Collapse
4: Re: Error with proxy::exec (response to 1)
Posted by Claudio Pasolini on
Hi Gustaf,

thank you for taking the time to answer, I didn't know that Tcl doesn't expand the tilde.

The AWS CLI searches the credentials into the ~/.aws/credentials folder but, as you suggested, setting some environment variables fixed the problem.

Claudio