]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Make sure 'sss_cache' can get both 'U' and 'G' args
authorAlexey Tikhonov <atikhono@redhat.com>
Fri, 3 Oct 2025 14:46:49 +0000 (16:46 +0200)
committerAlejandro Colomar <foss+github@alejandro-colomar.es>
Mon, 6 Oct 2025 08:36:55 +0000 (10:36 +0200)
Fixes: 59e5eef38f89 (2024-07-03; "contrib, lib/, src/, tests/: Use stpcpy(3) instead of its pattern")
Reviewed-by: Alejandro Colomar <alx@kernel.org>
lib/sssd.c

index 2ca84eda17b45366a15ef845d5206668e445e01c..7b6dba41a99c46ae8cebcd65b81d52c5e3af2ea6 100644 (file)
@@ -32,6 +32,10 @@ sssd_flush_cache(int dbflags)
        const char   *spawnedEnv[] = {NULL};
        struct stat  sb;
 
+       if ((dbflags & (SSSD_DB_PASSWD|SSSD_DB_GROUP)) == 0)
+           /* Neither passwd nor group, nothing to do */
+           return 0;
+
        rv = stat(cmd, &sb);
        if (rv == -1 && errno == ENOENT)
                return 0;
@@ -43,15 +47,10 @@ sssd_flush_cache(int dbflags)
 
        p = stpcpy(sss_cache_args, "-");
        if (dbflags & SSSD_DB_PASSWD)
-               stpcpy(p, "U");
+               p = stpcpy(p, "U");
        if (dbflags & SSSD_DB_GROUP)
-               stpcpy(p, "G");
+               p = stpcpy(p, "G");
 
-       if (streq(p, "")) {
-               /* Neither passwd nor group, nothing to do */
-               free(sss_cache_args);
-               return 0;
-       }
        spawnedArgs[1] = sss_cache_args;
 
        rv = run_command (cmd, spawnedArgs, spawnedEnv, &status);