[SSSD] [PATCH] do not default fullname to gecos when schema = ad

Pavel Březina pbrezina at redhat.com
Fri Oct 26 14:18:28 UTC 2012


On 10/25/2012 12:27 PM, Sumit Bose wrote:
> On Thu, Oct 18, 2012 at 01:11:00PM +0200, Pavel Březina wrote:
>> https://fedorahosted.org/sssd/ticket/1482
>
>>  From b40a0e4d5a05e78adce3c2eff0e981333a1a6e40 Mon Sep 17 00:00:00 2001
>> From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina at redhat.com>
>> Date: Thu, 18 Oct 2012 12:42:50 +0200
>> Subject: [PATCH] do not default fullname to gecos when schema = ad
>>
>> https://fedorahosted.org/sssd/ticket/1482
>> ---
>>   src/db/sysdb.h                        |    3 +++
>>   src/db/sysdb_ops.c                    |   29 ++++++++++++++++++++---------
>>   src/db/sysdb_subdomains.c             |    5 +++--
>>   src/providers/ldap/sdap_async_users.c |   21 +++++++++++++++++++--
>>   src/providers/proxy/proxy_id.c        |    1 +
>>   src/responder/pac/pacsrv_cmd.c        |    2 +-
>>   src/tests/sysdb-tests.c               |   18 +++++++++++-------
>>   src/tools/sss_seed.c                  |    2 +-
>>   src/tools/sss_sync_ops.c              |    2 +-
>>   9 files changed, 60 insertions(+), 23 deletions(-)
>>
>> diff --git a/src/db/sysdb.h b/src/db/sysdb.h
>> index 0ce6beaa361bcb5930e64c31fc3763a230881e9a..6b36db0fa3567ed1d6b3d0deb6313154b57265b1 100644
>> --- a/src/db/sysdb.h
>> +++ b/src/db/sysdb.h
>> @@ -609,6 +609,7 @@ int sysdb_get_new_id(struct sysdb_ctx *sysdb,
>>   /* Add user (only basic attrs and w/o checks) */
>>   int sysdb_add_basic_user(struct sysdb_ctx *sysdb,
>>                            const char *name,
>> +                         const char *fullname,
>>                            uid_t uid, gid_t gid,
>>                            const char *gecos,
>>                            const char *homedir,
>> @@ -617,6 +618,7 @@ int sysdb_add_basic_user(struct sysdb_ctx *sysdb,
>>   /* Add user (all checks) */
>>   int sysdb_add_user(struct sysdb_ctx *sysdb,
>>                      const char *name,
>> +                   const char *fullname,
>>                      uid_t uid, gid_t gid,
>>                      const char *gecos,
>>                      const char *homedir,
>> @@ -662,6 +664,7 @@ int sysdb_mod_group_member(struct sysdb_ctx *sysdb,
>>
>>   int sysdb_store_user(struct sysdb_ctx *sysdb,
>>                        const char *name,
>> +                     const char *fullname,
>>                        const char *pwd,
>>                        uid_t uid, gid_t gid,
>>                        const char *gecos,
>> diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
>> index 52f0cef54b9819b1f5d754dcbd56abd1d7cb0e96..859d1d58b9959da778fac08b6f5cf426d2433d25 100644
>> --- a/src/db/sysdb_ops.c
>> +++ b/src/db/sysdb_ops.c
>> @@ -776,6 +776,7 @@ done:
>>
>>   int sysdb_add_basic_user(struct sysdb_ctx *sysdb,
>>                            const char *name,
>> +                         const char *fullname,
>>                            uid_t uid, gid_t gid,
>>                            const char *gecos,
>>                            const char *homedir,
>
> I would prefer not to add another argument to sysdb_add_user(),
> sysdb_store_user() and especially not to sysdb_add_basic_user(). I think
> the same result can be reached with fewer changes if ...
>
>>
>>   errno_t sysdb_delete_domuser(struct sss_domain_info *domain,
>> diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c
>> index 8974e6a249f1c7db94a7dda63762d84ddd4f0347..f392b594a2fbf043a7dca963161715197639b36b 100644
>> --- a/src/providers/ldap/sdap_async_users.c
>> +++ b/src/providers/ldap/sdap_async_users.c
>> @@ -42,6 +42,7 @@ int sdap_save_user(TALLOC_CTX *memctx,
>>       struct ldb_message_element *el;
>>       int ret;
>>       const char *name = NULL;
>> +    const char *fullname = NULL;
>>       const char *pwd;
>>       const char *gecos;
>>       const char *homedir;
>> @@ -82,6 +83,22 @@ int sdap_save_user(TALLOC_CTX *memctx,
>>           goto fail;
>>       }
>>
>> +    if (opts->schema_type == SDAP_SCHEMA_AD) {
>> +        ret = sysdb_attrs_get_el(attrs,
>> +                         opts->user_map[SDAP_AT_USER_FULLNAME].sys_name, &el);
>> +        if (ret == EOK) {
>> +            if (el->num_values == 0) {
>> +                fullname = NULL;
>> +            } else {
>> +                fullname = (const char *)el->values[0].data;
>> +            }
>> +        } else if (ret == ENOENT) {
>> +            fullname = NULL;
>> +        } else {
>> +            goto fail;
>> +        }
>> +    }
>> +
>>       ret = sysdb_attrs_get_el(attrs,
>>                                opts->user_map[SDAP_AT_USER_PWD].sys_name, &el);
>>       if (ret) goto fail;
>> @@ -343,8 +360,8 @@ int sdap_save_user(TALLOC_CTX *memctx,
>>
>>       DEBUG(6, ("Storing info for user %s\n", name));
>>
>> -    ret = sysdb_store_user(ctx, name, pwd, uid, gid, gecos, homedir, shell,
>> -                           user_attrs, missing, cache_timeout, now);
>> +    ret = sysdb_store_user(ctx, name, fullname, pwd, uid, gid, gecos, homedir,
>> +                           shell, user_attrs, missing, cache_timeout, now);
>>       if (ret) goto fail;
>>
>>       if (_usn_value) {
>
> ... you add fullname to the user_attrs. Then sysdb_add_basic_user() will
> set fullname==gecos when it initially creates the user object in the
> cache, but it will be overwritten in the same transaction when
> sysdb_store_user() add all the user_attrs.

Hi,
that's a good idea. I'm sending the patch. I did not test it though, 
because I need to leave now. But it is pretty straightforward so I hope 
it's OK.

Thanks,
Pavel.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-do-not-default-fullname-to-gecos-when-schema-ad.patch
Type: text/x-patch
Size: 1674 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/sssd-devel/attachments/20121026/24671483/attachment.bin>


More information about the sssd-devel mailing list