[SSSD] [PATCH] Support flat name in the full_name_format

Sumit Bose sbose at redhat.com
Thu May 23 20:20:00 UTC 2013


On Thu, May 23, 2013 at 11:16:47AM +0200, Jakub Hrozek wrote:
> On Thu, May 23, 2013 at 11:13:19AM +0200, Jakub Hrozek wrote:
> > When I was rebasing the topic branch with these patches I realized the
> > patches would now require a 3way merge to apply correctly. Rebased
> > patches are attached.
> 
> And now let's attach the correct patches..

The patches looks good and mostly work as expected. Comments are inline.

bye,
Sumit

> diff --git a/src/responder/nss/nsssrv_cmd.c b/src/responder/nss/nsssrv_cmd.c
> index 57b5786f3106d3f9c307b25c1940520fd03be0c2..268cfc83e63c710661ac712a834e5a19ae12fdbd 100644
> --- a/src/responder/nss/nsssrv_cmd.c
> +++ b/src/responder/nss/nsssrv_cmd.c
> @@ -303,13 +303,10 @@ static int fill_pwent(struct sss_packet *packet,
>      int i, ret, num, t;
>      bool add_domain = (!IS_SUBDOMAIN(dom) && dom->fqnames);
>      const char *domain = dom->name;
> -    const char *namefmt;
>      bool packet_initialized = false;
>      int ncret;
>      TALLOC_CTX *tmp_ctx = NULL;
>  
> -    namefmt = dom->names->fq_fmt;
> -
>      if (add_domain) dom_len = strlen(domain);
>  
>      to_sized_string(&pwfield, nctx->pwfield);
> @@ -394,9 +391,8 @@ static int fill_pwent(struct sss_packet *packet,
>          SAFEALIGN_SET_UINT32(&body[rp], gid, &rp);
>  
>          if (add_domain) {
> -            ret = snprintf((char *)&body[rp],
> -                            name.len + delim + dom_len,
> -                            namefmt, name.str, domain);
> +            ret = sss_fqname((char *) &body[rp], name.len + delim + dom_len,
> +                             dom->names, dom, name.str);
>              if (ret >= (name.len + delim + dom_len)) {
>                  /* need more space, got creative with the print format ? */
>                  t = ret - (name.len + delim + dom_len) + 1;
> @@ -409,9 +405,8 @@ static int fill_pwent(struct sss_packet *packet,
>                  sss_packet_get_body(packet, &body, &blen);
>  
>                  /* retry */
> -                ret = snprintf((char *)&body[rp],
> -                            name.len + delim + dom_len,
> -                            namefmt, name.str, domain);
> +                ret = sss_fqname((char *) &body[rp], name.len + delim + dom_len,
> +                                 dom->names, dom, name.str);
>              }
>  
>              if (ret != name.len + delim + dom_len - 1) {

this check must be fixed because dom_len is currently only the length of
the domain name and not of the flat name. Same for fill_member() and
fill_grent().


>  
>  noinst_PROGRAMS = pam_test_client
> diff --git a/src/man/sssd.conf.5.xml b/src/man/sssd.conf.5.xml
> index 99337fbba9fb8d39a62eb84313c5b89761ee950d..85ed1fe55f2d14dddcf960795ab4469f82a9525b 100644
> --- a/src/man/sssd.conf.5.xml
> +++ b/src/man/sssd.conf.5.xml
> @@ -143,12 +143,36 @@
>                          <term>full_name_format (string)</term>
>                          <listitem>
>                              <para>
> -                                The default <citerefentry>
> +                                A <citerefentry>
>                                      <refentrytitle>printf</refentrytitle>
>                                      <manvolnum>3</manvolnum>
>                                  </citerefentry>-compatible format that describes how to
> -                                translate a (name, domain) tuple into a fully qualified
> -                                name.
> +                                compose a fully qualified name from user name
> +                                and domain name components.
> +                            </para>
> +                            <para>
> +                                The following expansions are supported :
> +                                <variablelist>
> +                                    <varlistentry>
> +                                        <term>%1$s</term>
> +                                        <listitem><para>user name</para></listitem>
> +                                    </varlistentry>
> +                                    <varlistentry>
> +                                        <term>%2$s</term>
> +                                        <listitem><para>domain name</para></listitem>
> +                                    </varlistentry>

maybe it should be added that this is the domain name used in sssd.conf
and not a discovered domain name like the flat name.

> +                                    <varlistentry>
> +                                        <term>%3$s</term>
> +                                        <listitem>
> +                                            <para>
> +                                                domain flat name. Mostly usable
> +                                                for Active Directory domains, both
> +                                                directly configured or disovered
> +                                                via IPA trusts.
> +                                            </para>
> +                                        </listitem>
> +                                    </varlistentry>
> +                                </variablelist>
>                              </para>
>                              <para>
>                                  Each domain can have an individual format string configured.
> @@ -1533,8 +1557,32 @@ override_homedir = /home/%u
>                                  <refentrytitle>printf</refentrytitle>
>                                  <manvolnum>3</manvolnum>
>                              </citerefentry>-compatible format that describes how to
> -                             translate a (name, domain) tuple for this domain into a fully
> -                             qualified name.
> +                            compose a fully qualified name from user name
> +                            and domain name components.
> +                        </para>
> +                        <para>
> +                            The following expansions are supported :
> +                            <variablelist>
> +                                <varlistentry>
> +                                    <term>%1$s</term>
> +                                    <listitem><para>user name</para></listitem>
> +                                </varlistentry>
> +                                <varlistentry>
> +                                    <term>%2$s</term>
> +                                    <listitem><para>domain name</para></listitem>
> +                                </varlistentry>
> +                                <varlistentry>
> +                                    <term>%3$s</term>
> +                                    <listitem>
> +                                        <para>
> +                                            domain flat name. Mostly usable
> +                                            for Active Directory domains, both
> +                                            directly configured or disovered
> +                                            via IPA trusts.
> +                                        </para>
> +                                    </listitem>
> +                                </varlistentry>
> +                            </variablelist>
>                          </para>
>                          <para>
>                              Default: <quote>%1$s@%2$s</quote>.

maybe it should be added that it is expected that there is a delimiter
of one character not more or less.




More information about the sssd-devel mailing list