|
|
14aacaf |
From 75d3fc60f88e08bf953063819a8a04b881d6db23 Mon Sep 17 00:00:00 2001
|
|
|
14aacaf |
From: Michal Schmidt <mschmidt@redhat.com>
|
|
|
14aacaf |
Date: Tue, 29 Nov 2011 23:14:36 +0100
|
|
|
14aacaf |
Subject: [PATCH 2/4] shutdownd: use PassCred=yes in the socket unit
|
|
|
14aacaf |
|
|
|
14aacaf |
Since Linux 3.2 in order to receive SCM_CREDENTIALS it is not sufficient
|
|
|
14aacaf |
to set SO_PASSCRED just before recvmsg(). The option has to be already
|
|
|
14aacaf |
set when the sender sends the message.
|
|
|
14aacaf |
|
|
|
14aacaf |
With socket activation it is too late to set the option in the service.
|
|
|
14aacaf |
It must be set on the socket right from the start.
|
|
|
14aacaf |
|
|
|
14aacaf |
See the kernel commit:
|
|
|
14aacaf |
16e57262 af_unix: dont send SCM_CREDENTIALS by default
|
|
|
14aacaf |
|
|
|
14aacaf |
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=757628
|
|
|
14aacaf |
---
|
|
|
14aacaf |
src/shutdownd.c | 6 ------
|
|
|
14aacaf |
units/systemd-shutdownd.socket | 1 +
|
|
|
14aacaf |
2 files changed, 1 insertions(+), 6 deletions(-)
|
|
|
14aacaf |
|
|
|
14aacaf |
Index: systemd-26/src/shutdownd.c
|
|
|
14aacaf |
===================================================================
|
|
|
14aacaf |
--- systemd-26.orig/src/shutdownd.c
|
|
|
14aacaf |
+++ systemd-26/src/shutdownd.c
|
|
|
14aacaf |
@@ -173,7 +173,6 @@ int main(int argc, char *argv[]) {
|
|
|
14aacaf |
};
|
|
|
14aacaf |
|
|
|
14aacaf |
int r = EXIT_FAILURE, n_fds;
|
|
|
14aacaf |
- int one = 1;
|
|
|
14aacaf |
struct shutdownd_command c;
|
|
|
14aacaf |
struct pollfd pollfd[_FD_MAX];
|
|
|
14aacaf |
bool exec_shutdown = false, unlink_nologin = false, failed = false;
|
|
|
14aacaf |
@@ -203,11 +202,6 @@ int main(int argc, char *argv[]) {
|
|
|
14aacaf |
return EXIT_FAILURE;
|
|
|
14aacaf |
}
|
|
|
14aacaf |
|
|
|
14aacaf |
- if (setsockopt(SD_LISTEN_FDS_START, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0) {
|
|
|
14aacaf |
- log_error("SO_PASSCRED failed: %m");
|
|
|
14aacaf |
- return EXIT_FAILURE;
|
|
|
14aacaf |
- }
|
|
|
14aacaf |
-
|
|
|
14aacaf |
zero(c);
|
|
|
14aacaf |
zero(pollfd);
|
|
|
14aacaf |
|
|
|
14aacaf |
Index: systemd-26/units/systemd-shutdownd.socket
|
|
|
14aacaf |
===================================================================
|
|
|
14aacaf |
--- systemd-26.orig/units/systemd-shutdownd.socket
|
|
|
14aacaf |
+++ systemd-26/units/systemd-shutdownd.socket
|
|
|
14aacaf |
@@ -14,3 +14,5 @@ Before=sockets.target
|
|
|
14aacaf |
|
|
|
14aacaf |
[Socket]
|
|
|
14aacaf |
ListenDatagram=/run/systemd/shutdownd
|
|
|
14aacaf |
+SocketMode=0600
|
|
|
14aacaf |
+PassCred=yes
|