-
Notifications
You must be signed in to change notification settings - Fork 396
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
Tilde ('~') does not expand to home of user actually running service start script #45
Comments
I ran into a similar issue a few months ago- one of my systemd services was failing because some standard environment variables were missing. I made my own fix manics@524ce62 but didn't have time to submit it as a PR, you've just reminded me about it. The more general problem is the handling of environment variables. The systemd docs say only a fixed set should be defined. I did some investigation using this service file
|
Oh well, that points back to the HISTORY of systemctl.py as a simple wrapper looking for ExecStart statements in the In any case, the environment variables referenced in the standard systemd documentation should be atleast on a value that matches expectations. So when $USER / $HOME should be overridden then it is the way to go. |
@gdraheim Do you want me to go ahead and open a PR with my fix once I've retested it? Or do you have some other solution in mind? |
I had similar issues while compiling programs like freepbx under docker, I ended up doing something like this:
I create the user, i needed an asterisk user
At this point i have my *.service files already copied over.
End build with:
And other things I found to cause issues and not usable in docker. Start container up with.
|
@manics .... reviewing your patch, I see that you had completely replaced the Your link to the standard docs is extremely helpful for that. => |
and please guys (include @techno-express ), do report such problems, there's no need to make up a workaround when it can get fixed in the upstream project. ;) |
So, what do we have:
Probably we can also support $USER/$HOME for the default root-user as well. |
I added some code, present in v1.4.2416, that may fix this problem. I don't have testcase so far, so it is up to you to give it a try. |
Already in release v1.4.2456 |
I discovered this issue while debugging why the PostgreSQL service would not start in my Docker container using
systemctl.py
.The service definition specifies that the startup script should be run as user
postgres
who exists in the container and has the home directory /var/lib/pgsql.The startup script (/usr/lib/postgresql-init) apparently expects to be run as user
postgres
and, at one point, does the following:A few lines later, it attempts to initialise the DB (if that hasn't been done before) sending stdout to a file named initlog, in the local working directory.
That all works fine, when the script is run by regular
systemd
, butsystemctl.py
apparently sets up the environment differently, so that~
does not expand to thepostgres
user's home, but rather to /root.This leads to the following errors being logged by the startup script:
… and lets the initialisation (and thus the service start) fail.
I was able to work around this issue, by putting a drop-in unit file into /usr/lib/systemd/system/postgresql.service.d that explicitly sets
… but I really consider this a workaround, rather than a fix.
Ideally, when
systemctl.py
runs a shell script as some user, the tilde character~
should expand to that users home directory (as specified in /etc/passwd) if used within the script. If only, because that seems to be the waysystemd
does it and there's at least one startup script out there that relies on this behaviour.The text was updated successfully, but these errors were encountered: