Score:1

systemd CREDENTIALS_DIRECTORY specified in LoadCredential= is not being passed through ExecStart command line

rs flag

I have the following systemd config file salt_server.service

[Unit]
Description=Salt Sensor Service
After=mysql.service
StartLimitBurst=5
StartLimitIntervalSec=10

[Service]
SyslogIdentifier=salt_sensor_service
Type=simple
Restart=always
RestartSec=1
User=salty
LoadCredential=credentials.json:/home/salty/private/salty_credentials.json
ExecStart=/usr/local/bin/salt_server -credentials=${CREDENTIALS_DIRECTORY}/credentials.json -log_level=debug
StandardOutput=syslog
StandardError=syslog
ProtectSystem=strict
ProtectHome=true
PrivateUsers=true
PrivateTmp=true

[Install]
WantedBy=multi-user.target

The command line resulting from the ExecStart line is

/usr/local/bin/salt_server -credentials=/credentials.json -log_level=debug

i.e. the ${CREDENTIALS_DIRECTORY} is an empty string. What am I doing wrong? I've tried various combinations of Environment= and PassEnvironment= but can't get it to work.

I've also tried $CREDENTIALS_DIRECTORY and pretty much a load of other no-hope options.

Note that the credentials file and folder both exist and are readable by the user salty

Any ideas?

hr flag
What is your systemd version (as shown by `systemctl --version` for example)? The "credentials" logic appears to have been introduced in 247 whereas afaik Ubuntu 20.04 ships with version 245
Charlie Skilbeck avatar
rs flag
Nice catch! I am indeed on 245, I'll work out how to upgrade. If you post this as an answer I'll accept it.
Charlie Skilbeck avatar
rs flag
Bah, looks like upgrading systemd is basically not worth the hassle so I'm stuck with a hard coded path for now, thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.