]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
sssd: skip flushing if executable does not exist
authorChristian Göttsche <cgzones@googlemail.com>
Sat, 1 Apr 2023 11:44:48 +0000 (13:44 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Mon, 3 Apr 2023 11:05:30 +0000 (13:05 +0200)
Avoid unnecessary syslog output, like:

    Apr 01 13:35:09 dlaptop userdel[45872]: userdel: sss_cache exited with status 1
    Apr 01 13:35:09 dlaptop userdel[45872]: userdel: Failed to flush the sssd cache.

lib/sssd.c

index 2da920a867bc4f9cb12bdefb3ad2dc50ee17f335..dd547290f20c7b54c795ba1caaa15e9e5771e1a1 100644 (file)
@@ -4,6 +4,7 @@
 #ifdef USE_SSSD
 
 #include <stdio.h>
+#include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/types.h>
 
@@ -21,11 +22,16 @@ int sssd_flush_cache (int dbflags)
 {
        int status, code, rv;
        const char *cmd = "/usr/sbin/sss_cache";
+       struct stat sb;
        char *sss_cache_args = NULL;
        const char *spawnedArgs[] = {"sss_cache", NULL, NULL};
        const char *spawnedEnv[] = {NULL};
        int i = 0;
 
+       rv = stat(cmd, &sb);
+       if (rv == -1 && errno == ENOENT)
+               return 0;
+
        sss_cache_args = MALLOCARRAY(4, char);
        if (sss_cache_args == NULL) {
            return -1;