ServiceDescription(const char *path,
const char *smackLabel,
InterfaceID interfaceID = 0,
- bool useSendMsg = false)
+ bool useSendMsg = false,
+ bool systemdOnly = false)
: smackLabel(smackLabel)
, interfaceID(interfaceID)
, serviceHandlerPath(path)
, useSendMsg(useSendMsg)
+ , systemdOnly(systemdOnly)
{}
SmackLabel smackLabel; // Smack label for socket
InterfaceID interfaceID; // All data from serviceHandlerPath will be marked with this interfaceHandler
ServiceHandlerPath serviceHandlerPath; // Path to file
bool useSendMsg;
+ bool systemdOnly;
};
typedef std::vector<ServiceDescription> ServiceDescriptionVector;
const GenericSocketService::ServiceDescription &desc)
{
int sockfd = GetSocketFromSystemD(desc);
- if (-1 == sockfd)
+ if (-1 == sockfd) {
+ if (desc.systemdOnly) {
+ LogError("Socket " << desc.serviceHandlerPath << " not provided by systemd.");
+ ThrowMsg(Exception::InitFailed, "Socket " << desc.serviceHandlerPath <<
+ " must be provided by systemd, but it was not.");
+ }
sockfd = CreateDomainSocketHelp(desc);
+ }
auto &description = CreateDefaultReadSocketDescription(sockfd, false);
GenericSocketService::ServiceDescriptionVector Service::GetServiceDescription()
{
return ServiceDescriptionVector {
- {SERVICE_SOCKET, "security-manager", IFACE},
+ {SERVICE_SOCKET, /* path */
+ "*", /* smackLabel label (not used, we rely on systemd) */
+ IFACE, /* InterfaceID */
+ false, /* useSendMsg */
+ true}, /* systemdOnly */
};
}