Skip to content

Multiline Environment= declarations aren't properly parsed #183

@piotrp

Description

@piotrp

I am trying to use systemctl3.py with services that need long environment variables with newlines, and I noticed that newlines aren't supported.

Example from my service:

Environment="FLINK_ENV_JAVA_OPTS_JM=-Dcom.sun.management.jmxremote \
              -Dcom.sun.management.jmxremote.port=9951 \
              -Dcom.sun.management.jmxremote.rmi.port=9951 \
              -Dcom.sun.management.jmxremote.authenticate=false \
              -Dcom.sun.management.jmxremote.ssl=false \
              -Dcom.sun.management.jmxremote.local.only=false \
              -Djava.rmi.server.hostname=172.20.128.132"

A shorter standalone test case:

[Unit]
Description=Env test

[Service]
Environment="MULTILINE=line1 \
  line2"
ExecStart=/usr/bin/env

[Install]
WantedBy=default.target

Output logged after starting this service:

...
OLDPWD=/root
MULTILINE=line1
MAINPID=
...

A quick test with additional logging in read_env_part (logg.info("env part: %s", env_part)) shows that the value is read correctly, and the only issue is with the way that read_env_part interprets this data:

$ systemctl --user -vv start envtest
INFO:systemctl:EXEC BEGIN /usr/bin/systemctl start envtest --user
INFO:systemctl:env part: "MULTILINE=line1 \
  line2"

INFO:systemctl:simple start '/usr/bin/env'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions