From c26c463ac92682dcf01ddbdc11cc1109b183eb0a Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Mon, 1 Nov 2021 16:04:28 -0400 Subject: [PATCH 07/12] Issue 4973 - update snmp to use /run/dirsrv for PID file Description: Previously SNMP would write the agent PID file directly under /run (or /var/run), but this broke a CI test after updating lib389/defaults.inf to use /run/dirsrv. Instead of hacking the CI test, I changed the path snmp uses to: /run/dirsrv/ Which is where it should really be written anyway. relates: https://github.com/389ds/389-ds-base/issues/4973 Reviewed by: vashirov(Thanks!) --- ldap/servers/snmp/main.c | 4 ++-- wrappers/systemd-snmp.service.in | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c index e6271a8a9..d8eb918f6 100644 --- a/ldap/servers/snmp/main.c +++ b/ldap/servers/snmp/main.c @@ -287,14 +287,14 @@ load_config(char *conf_path) } /* set pidfile path */ - if ((pidfile = malloc(strlen(LOCALRUNDIR) + strlen("/") + + if ((pidfile = malloc(strlen(LOCALRUNDIR) + strlen("/dirsrv/") + strlen(LDAP_AGENT_PIDFILE) + 1)) != NULL) { strncpy(pidfile, LOCALRUNDIR, strlen(LOCALRUNDIR) + 1); /* The above will likely not be NULL terminated, but we need to * be sure that we're properly NULL terminated for the below * strcat() to work properly. */ pidfile[strlen(LOCALRUNDIR)] = (char)0; - strcat(pidfile, "/"); + strcat(pidfile, "/dirsrv/"); strcat(pidfile, LDAP_AGENT_PIDFILE); } else { printf("ldap-agent: malloc error processing config file\n"); diff --git a/wrappers/systemd-snmp.service.in b/wrappers/systemd-snmp.service.in index 477bc623d..f18766cb4 100644 --- a/wrappers/systemd-snmp.service.in +++ b/wrappers/systemd-snmp.service.in @@ -1,7 +1,7 @@ # do not edit this file in /lib/systemd/system - instead do the following: # cp /lib/systemd/system/dirsrv-snmp.service /etc/systemd/system/ # edit /etc/systemd/system/dirsrv-snmp.service -# systemctl daemon-reload +# systemctl daemon-reload # systemctl (re)start dirsrv-snmp.service [Unit] Description=@capbrand@ Directory Server SNMP Subagent. @@ -9,8 +9,8 @@ After=network.target [Service] Type=forking -PIDFile=/run/ldap-agent.pid -ExecStart=@sbindir@/ldap-agent @configdir@/ldap-agent.conf +PIDFile=/run/dirsrv/ldap-agent.pid +ExecStart=@sbindir@/ldap-agent @configdir@/ldap-agent.conf [Install] WantedBy=multi-user.target -- 2.31.1