Skip to content

Commit 4abe013

Browse files
Merge pull request #121 from opensciencegrid/cms-x509less
adding first version of x509less cmsxcache
2 parents 0915d78 + a42f849 commit 4abe013

4 files changed

Lines changed: 30 additions & 1 deletion

File tree

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@ RUN chmod 0644 /etc/cron.d/*
116116
COPY cms-xcache/image-config.d/* /etc/osg/image-init.d/
117117
COPY cms-xcache/xcache-consistency-check-wrapper.sh /usr/bin/xcache-consistency-check-wrapper.sh
118118
COPY cms-xcache/rsyslog-cms-xcache.conf /etc/rsyslog.d/cms-xcache.conf
119+
COPY cms-xcache/sbin/* /usr/local/sbin/
120+
RUN chmod 0544 /usr/local/sbin/fetch_scitoken.sh
119121

120122
RUN mkdir -p /var/log/xrootd/cms-xcache && \
121123
touch /var/log/xrootd/cms-xcache/xrootd.log && \

cms-xcache/cron.d/fetch-scitoken

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@reboot root /usr/local/sbin/fetch_scitoken.sh &>> /tmp/fetch-cms-scitoken.cron.log
2+
0 */6 * * * root /usr/local/sbin/fetch_scitoken.sh &>> /tmp/fetch-cms-scitoken.cron.log

cms-xcache/sbin/fetch_scitoken.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
if [ -f /etc/grid-security/fetch_scitoken_secret ]; then
4+
USER=`cat /etc/grid-security/fetch_scitoken_secret | awk -F ":" '{print $1}'`
5+
PASS=`cat /etc/grid-security/fetch_scitoken_secret | awk -F ":" '{print $2}'`
6+
7+
if [[ -z "$USER" || -z "$PASS" ]]; then
8+
echo "Wrong format in secret file"
9+
exit 1
10+
fi
11+
12+
curl -s --user $USER:$PASS -d grant_type=client_credentials -d scope="storage.read:/" https://cms-auth.cern.ch/token \
13+
| python3 -c 'import sys,json; print(json.loads(sys.stdin.read())["access_token"])' > /tmp/jwt_xrdcache
14+
15+
if [ $? -ne 0 ]; then
16+
echo "Failed to retrieve token"
17+
exit 2
18+
fi
19+
20+
chown xrootd: /tmp/jwt_xrdcache
21+
chmod 600 /tmp/jwt_xrdcache
22+
23+
else
24+
echo "Secret file not found"
25+
fi

cms-xcache/supervisord.d/10-cms-xcache.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
command=xrootd -c /etc/xrootd/xrootd-cms-xcache.cfg -k fifo -n cms-xcache -k %(ENV_XC_NUM_LOGROTATE)s -s /var/run/xrootd/xrootd-cms-xcache.pid -l /var/log/xrootd/xrootd.log
33
user=xrootd
44
autorestart=true
5-
environment=LD_PRELOAD=/usr/lib64/libtcmalloc.so,TCMALLOC_RELEASE_RATE=10
5+
environment=LD_PRELOAD=/usr/lib64/libtcmalloc.so,TCMALLOC_RELEASE_RATE=10,BEARER_TOKEN_FILE=/tmp/jwt_xrdcache,XrdSecPROTOCOL="ztn"
66

0 commit comments

Comments
 (0)