]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:winbind: Also support %{uid} substitution for krb5_ccache_type
authorAndreas Schneider <asn@samba.org>
Mon, 9 Feb 2026 10:00:45 +0000 (11:00 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 26 Mar 2026 09:56:29 +0000 (09:56 +0000)
Pair-Programmed-With: Pavel Filipenský <pfilipen@redhat.com>
Signed-off-by: Pavel Filipenský <pfilipen@redhat.com>
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
docs-xml/manpages/pam_winbind.conf.5.xml
source3/winbindd/winbindd_pam.c

index b87c210c13c445fb27530ceb1026094eb767f03b..58419e89384a343de7579b5444415c48a55c47c1 100644 (file)
                <parameter>DIR:/path</parameter>,
                <parameter>FILE:/path</parameter>, and
                <parameter>WRFILE:/path</parameter>.
-               You can use the <quote>%u</quote> pattern to substitute the
-               numeric user ID. Examples:</para>
+               You can use the <quote>%u</quote> or <quote>%{uid}</quote> pattern to
+               substitute the numeric user ID. Examples:</para>
 
                <variablelist>
                        <varlistentry>
index 050d8655845ed2abfded7521acfb797b8d43aabd..68ffebe7e16e14c70f9ce0f1e9dca34757009869 100644 (file)
@@ -649,16 +649,25 @@ static bool generate_krb5_ccache(TALLOC_CTX *mem_ctx,
                }
        }
 
-       /* Handle types with explicit paths and %u substitution */
+       /* Handle types with explicit paths and %u or %{uid} substitution */
        if (has_prefix) {
                char *p;
+               const char *subst_pattern = NULL;
 
                p = strchr(type, '%');
                if (p != NULL) {
                        p++;
 
-                       /* We support only one "%u" substitution */
+                       /* We support "%u" or "%{uid}" substitution */
                        if (p != NULL && *p == 'u' && strchr(p, '%') == NULL) {
+                               subst_pattern = "%u";
+                       } else if (p != NULL &&
+                                  strncmp(p, "{uid}", 5) == 0 &&
+                                  strchr(p + 5, '%') == NULL) {
+                               subst_pattern = "%{uid}";
+                       }
+
+                       if (subst_pattern != NULL) {
                                char uid_str[sizeof("18446744073709551615")];
                                int rc;
 
@@ -678,7 +687,7 @@ static bool generate_krb5_ccache(TALLOC_CTX *mem_ctx,
                                gen_cc = talloc_string_sub2(
                                        mem_ctx,
                                        type,
-                                       "%u",
+                                       subst_pattern,
                                        uid_str,
                                        false, /* remove_unsafe_characters */
                                        true, /* replace_once */