You are not logged in.
Pages: 1
ok so im trying to make a systemd service,
this is my service file
[Unit]
Description=Honeygain on boot
After=network.target
StartLimitIntervalSec=0[Service]
Type=simple
Restart=always
RestartSec=1
User=kamey
ExecStart=/bin/bash /usr/bin/honeygain.sh[Install]
WantedBy=multi-user.target
and this is the SH file it runs
docker run honeygain/honeygain -tou-accept -email removed -pass removed -device kamey-arch
but it doenst work, status shows
kamey@arch-linux:~]$ systemctl status honeygain
● honeygain.service - Honeygain on boot
Loaded: loaded (/etc/systemd/system/honeygain.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2021-01-29 03:11:48 CET; 9ms ago
Process: 17532 ExecStart=/bin/bash /usr/bin/honeygain.sh (code=exited, status=126)
Main PID: 17532 (code=exited, status=126)
why doesnt it work?
Last edited by Nikita790 (2021-01-29 17:39:54)
Offline
It exited because of some errors. Unfortunately, the given information is not enough for us to answer the reason.
Show us the output of this command, which will give the systemd log only related to your service:
journalctl -uhoneygain.serviceEDIT: typo, existed -> exited
Last edited by ArleCamille (2021-01-29 02:02:42)
Offline
Jan 29 02:43:12 arch-linux docker[7717]: See 'docker run --help'.
Jan 29 02:43:12 arch-linux systemd[1]: honeygain.service: Main process exited, code=exited, status=126/n/a
Jan 29 02:43:12 arch-linux systemd[1]: honeygain.service: Failed with result 'exit-code'.
Jan 29 02:43:13 arch-linux systemd[1]: honeygain.service: Scheduled restart job, restart counter is at 5.
Jan 29 02:43:13 arch-linux systemd[1]: Stopped Honeygain on boot.
Jan 29 02:43:13 arch-linux systemd[1]: Started Honeygain on boot.
Jan 29 02:43:14 arch-linux docker[7727]: docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http:>
im not sure why this is happening, as
sudo docker ps
works fine
Offline
[Service]
Type=simple
Restart=always
RestartSec=1
User=kamey
ExecStart=/bin/bash /usr/bin/honeygain.sh
That is because you are running it as a non-superuser. Docker is running but refusing to communicate with an ordinary user.
Do you have a reason to run the daemon in your own home folder? If not, remove the offending line (marked bold) to let systemd run the service as root.
EDIT: maybe instead specifying the same user as docker.service does would suffice, but since I don't know how docker.service is managed, I think we need attention of docker users here.
Last edited by ArleCamille (2021-01-29 03:14:07)
Offline
it fixed after doing
sudo chmod 666 /var/run/docker.sock
thanks!
Offline
it fixed after doing
sudo chmod 666 /var/run/docker.sock
thanks!
No. Don't do that. It is dangerous. Everyone, including the remote attacker, can access the docker's socket. Rather running the offending service as the superuser is a little bit more secure.
If you really worry about running the service as root, rather run the service as the same user as docker.service (you can see the unit file by systemctl cat docker), or use the NoNewPrivileges= option. Man page of systemd.exec(5) says:
NoNewPrivileges=
Takes a boolean argument. If true, ensures that the service
process and all its children can never gain new privileges
through execve() (e.g. via setuid or setgid bits, or
filesystem capabilities). This is the simplest and most
effective way to ensure that a process and its children can
never elevate privileges again. Defaults to false, but
certain settings override this and ignore the value of this
setting. This is the case when SystemCallFilter=,
SystemCallArchitectures=, RestrictAddressFamilies=,
RestrictNamespaces=, PrivateDevices=, ProtectKernelTunables=,
ProtectKernelModules=, ProtectKernelLogs=, ProtectClock=,
MemoryDenyWriteExecute=, RestrictRealtime=,
RestrictSUIDSGID=, DynamicUser= or LockPersonality= are
specified. Note that even if this setting is overridden by
them, systemctl show shows the original value of this
setting. Also see No New Privileges Flag[4].
If you care about security, the unit file should be something like:
EDIT: deleted incorrect information. Please refer to the next post.
This is a less secure version which runs the service as root.
[Unit]
Description=Honeygain on boot
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/bin/bash /usr/bin/honeygain.sh
[Install]
WantedBy=multi-user.targetLast edited by ArleCamille (2021-01-29 03:44:01)
Offline
ooh, i see, that was really stupid of me. I will try to make it secure useing the methods you provided, thanks!
Offline
Oops, I also made a mistake; docker runs on root actually.
So a canonical solution would be:
[Unit]
Description=Honeygain on boot
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=root
NoNewPrivileges=yes
ExecStart=/bin/bash /usr/bin/honeygain.sh
[Install]
WantedBy=multi-user.targetLast edited by ArleCamille (2021-01-29 04:03:43)
Offline
ah thats why it wasnt working, my friend who im making this for has gone to sleep now, i will update you if this works tommorow, thanks a lot!
Last edited by Nikita790 (2021-01-29 03:46:00)
Offline
There's no need for "User=root" as that is a given. There's also no need for either for the script or the /bin/bash in the ExecStart line. Just run the docker command from the ExecStart line and cut out the middle man.
Last edited by Trilby (2021-01-29 04:30:34)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
hmm, ok, i will keep the user as it makes it easer for me to understand whats going on,
would this be a good service file?
[Unit]
Description=Honeygain
After=network.target
StartLimitIntervalSec=0[Service]
Type=simple
Restart=always
RestartSec=1
User=root
NoNewPrivileges=yes
ExecStart=/bin/bash docker run honeygain/honeygain -tou-accept -email removed -pass removed -device kamey-arch[Install]
WantedBy=multi-user.target
Offline
No. Get rid of /bin/bash.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
ok, current file
[Unit]
Description=Honeygain
After=network.target
StartLimitIntervalSec=0[Service]
Type=simple
Restart=always
RestartSec=1
User=root
NoNewPrivileges=yes
ExecStart=docker run honeygain/honeygain -tou-accept -email removed -pass removed -device kamey-arch[Install]
WantedBy=multi-user.target
thanks for all of your help! I will update when my friend wakes up
Last edited by Nikita790 (2021-01-29 04:34:33)
Offline
ok it works! thanks you guys for all of your help!
Offline
Pages: 1