From: Alexey Tikhonov Date: Fri, 3 Oct 2025 14:46:49 +0000 (+0200) Subject: Make sure 'sss_cache' can get both 'U' and 'G' args X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=920b2181421558bf1ce4ab6457d5068c9eb22713;p=thirdparty%2Fshadow.git Make sure 'sss_cache' can get both 'U' and 'G' args Fixes: 59e5eef38f89 (2024-07-03; "contrib, lib/, src/, tests/: Use stpcpy(3) instead of its pattern") Reviewed-by: Alejandro Colomar --- diff --git a/lib/sssd.c b/lib/sssd.c index 2ca84eda1..7b6dba41a 100644 --- a/lib/sssd.c +++ b/lib/sssd.c @@ -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);