Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setenv not working with < #1899

Closed
IceyMu opened this issue Feb 7, 2023 · 10 comments
Closed

setenv not working with < #1899

IceyMu opened this issue Feb 7, 2023 · 10 comments
Assignees

Comments

@IceyMu
Copy link

IceyMu commented Feb 7, 2023

Hello,

When I try to read the value of a file into an environment variable using setenv and < I get back an empty environment variable e.g

setenv AWS_ACCESS_KEY_ID < /etc/xrootd/access_key

Doesn't change the environment variable AWS_ACCESS_KEY_ID.

I can however read from a file into a variable using set and then copy that variable to the environment variable e.g

set ACCESS_KEY < /etc/xrootd/access_key
setenv AWS_ACCESS_KEY_ID = $ACCESS_KEY

Makes the environment variable AWS_ACCESS_KEY_ID have the value of the contents of /etc/xrootd/access_key

setenv also works if I were to pass the value directly e.g

setenv AWS_ACCESS_KEY_ID = 1234

I am using xrootd 5.5.1 from the epel repository.

Thanks

@abh3 abh3 self-assigned this Feb 7, 2023
@amadio
Copy link
Member

amadio commented Feb 8, 2023

Can you please explain to us where this setenv command is? If that's a ~/.tcshrc or similar, I don't see how this could be a problem with XRootD.

@IceyMu
Copy link
Author

IceyMu commented Feb 8, 2023

The setenv is in the xrootd configuration file. I am trying to use setenv as described in section 4.4 of the configuration file syntax manual.

The configuration I am trying to use is:

set redirector = elephant103.heprc.uvic.ca

all.manager $(redirector):1095


# Debugging output
#xrd.trace all
#xrootd.trace all
#ofs.trace all
#sec.trace all
#pss.trace all
#http.trace all


all.export /

# The names used here must match what is going to be passed as server_type
if named s3_proxy
  # Proxy setup
  all.role proxy server
  ofs.osslib libXrdPss.so
  pss.origin http://elephant102.heprc.uvic.ca:9000
  pss.localroot /bucket

  # XRootD doesn't seem to like reading files directly into environment variables
  set ACCESS_KEY < /etc/xrootd/access_key
  set SECRET_KEY < /etc/xrootd/secret_key

  setenv AWS_ACCESS_KEY_ID = $ACCESS_KEY
  setenv AWS_SECRET_ACCESS_KEY = $SECRET_KEY
else if named standalone
  all.role server
  oss.localroot /data
fi

# TLS Setup
xrd.tls /etc/grid-security/xrd/xrdcert.pem /etc/grid-security/xrd/xrdkey.pem
xrd.tlsca certdir /etc/grid-security/certificates
xrootd.tls all

if $redirector
  all.role manager
  http.desthttps yes
else
  xrootd.seclib libXrdSec.so
  sec.protocol gsi -dlgpxy:request \
                   -exppxy:=creds \
                   -ca:verify \
                   -crl:try \
                   -gmapopt:nomap \
                   -vomsat:require \
                   -vomsfun:default
fi

xrootd.seclib libXrdSec.so
http.secxtractor libXrdHttpVOMS.so

if exec xrootd
  xrd.protocol http libXrdHttp.so
fi

# Authorization configuration
ofs.authorize
acc.audit deny grant
acc.authdb /etc/xrootd/Authfile

# TPC Setup
xrootd.chksum adler32

ofs.tpc fcreds ?gsi =X509_USER_PROXY
ofs.tpc require client gsi
ofs.tpc scan stderr
ofs.tpc echo
ofs.tpc ttl 300 600
ofs.tpc xfr 100
ofs.tpc autorm
ofs.tpc pgm /etc/xrootd/tpc.sh

http.exthandler xrdtpc libXrdHttpTPC.so
http.header2cgi Authorization authz

# Macaroon setup
http.exthandler xrdmacaroons libXrdMacaroons.so
macaroons.secretkey /etc/xrootd/macaroon-secret
all.sitename test_sitename
ofs.authlib libXrdMacaroons.so

@abh3
Copy link
Member

abh3 commented Feb 8, 2023 via email

@amadio
Copy link
Member

amadio commented Feb 8, 2023

Thank you both for the explanations. I will have a look tomorrow how to fix this one.

@xrootd-dev
Copy link

xrootd-dev commented Feb 8, 2023 via email

@amadio
Copy link
Member

amadio commented Feb 13, 2023

Hi Andy, I can fix this one, leave it for me. It looks as if the code below is not going to override an environment variable if it's already set:

https://github.com/xrootd/xrootd/blob/master/src/XrdOuc/XrdOucStream.cc#L1458-L1460

@IceyMu Can you please confirm that AWS_ACCESS_KEY_ID is not set when you launch the server?

@IceyMu
Copy link
Author

IceyMu commented Feb 13, 2023

I've tried running my configs on a new virtual machine and this makes the config work with setenv and < together.

@abh3
Copy link
Member

abh3 commented Feb 13, 2023 via email

@abh3
Copy link
Member

abh3 commented Feb 13, 2023 via email

@amadio
Copy link
Member

amadio commented Feb 14, 2023

Actually, the "if" (if that is what you are talking about) is merely
saying if the envar is not set or if it is set but the new value differs
from the old value then it is set.

Indeed, after I commented I went through the code a bit more carefully and saw that it it's working for both set and setenv. I wrote a simple config file and ran with GDB and saw that it works as intended.

@amadio amadio closed this as completed Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants