Ignore:
Timestamp:
Apr 9, 2010, 3:20:58 PM (15 years ago)
Author:
Silvan Scherrer
Message:

Samba 3.5.x: update to 3.5.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/passdb/passdb.c

    r414 r427  
    123123}
    124124
     125static int count_commas(const char *str)
     126{
     127        int num_commas = 0;
     128        const char *comma = str;
     129
     130        while ((comma = strchr(comma, ',')) != NULL) {
     131                comma += 1;
     132                num_commas += 1;
     133        }
     134        return num_commas;
     135}
     136
    125137/*********************************************************************
    126138 Initialize a struct samu from a struct passwd including the user
     
    133145        const char *guest_account = lp_guestaccount();
    134146        const char *domain = global_myname();
     147        char *fullname;
    135148        uint32 urid;
    136149
     
    142155
    143156        pdb_set_username(user, pwd->pw_name, PDB_SET);
    144         pdb_set_fullname(user, pwd->pw_gecos, PDB_SET);
     157
     158        fullname = NULL;
     159
     160        if (count_commas(pwd->pw_gecos) == 3) {
     161                /*
     162                 * Heuristic: This seems to be a gecos field that has been
     163                 * edited by chfn(1). Only use the part before the first
     164                 * comma. Fixes bug 5198.
     165                 */
     166                fullname = talloc_strndup(
     167                        talloc_tos(), pwd->pw_gecos,
     168                        strchr(pwd->pw_gecos, ',') - pwd->pw_gecos);
     169        }
     170
     171        if (fullname != NULL) {
     172                pdb_set_fullname(user, fullname, PDB_SET);
     173        } else {
     174                pdb_set_fullname(user, pwd->pw_gecos, PDB_SET);
     175        }
     176        TALLOC_FREE(fullname);
     177
    145178        pdb_set_domain (user, get_global_sam_name(), PDB_DEFAULT);
    146179#if 0
Note: See TracChangeset for help on using the changeset viewer.