Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source3/libnet
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libnet/libnet_dssync.c

    r740 r988  
    5555        struct dssync_context *ctx;
    5656
    57         ctx = TALLOC_ZERO_P(mem_ctx, struct dssync_context);
     57        ctx = talloc_zero(mem_ctx, struct dssync_context);
    5858        NT_STATUS_HAVE_NO_MEMORY(ctx);
    5959
     
    114114                                                  session_key,
    115115                                                  rid,
     116                                                  0,
    116117                                                  attr);
    117118                }
     
    196197                break;
    197198        }
    198         case 28:
     199        case 28: {
    199200                ctx->remote_info28 = bind_info.info.info28;
    200201                break;
     202        }
     203        case 32: {
     204                struct drsuapi_DsBindInfo32 *info32;
     205                info32 = &bind_info.info.info32;
     206                ctx->remote_info28.site_guid            = info32->site_guid;
     207                ctx->remote_info28.supported_extensions = info32->supported_extensions;
     208                ctx->remote_info28.pid                  = info32->pid;
     209                ctx->remote_info28.repl_epoch           = info32->repl_epoch;
     210                break;
     211        }
    201212        case 48: {
    202213                struct drsuapi_DsBindInfo48 *info48;
     
    206217                ctx->remote_info28.pid                  = info48->pid;
    207218                ctx->remote_info28.repl_epoch           = info48->repl_epoch;
     219                break;
     220        }
     221        case 52: {
     222                struct drsuapi_DsBindInfo52 *info52;
     223                info52 = &bind_info.info.info52;
     224                ctx->remote_info28.site_guid            = info52->site_guid;
     225                ctx->remote_info28.supported_extensions = info52->supported_extensions;
     226                ctx->remote_info28.pid                  = info52->pid;
     227                ctx->remote_info28.repl_epoch           = info52->repl_epoch;
    208228                break;
    209229        }
     
    340360        }
    341361
    342         nc = TALLOC_ZERO_P(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
     362        nc = talloc_zero(mem_ctx, struct drsuapi_DsReplicaObjectIdentifier);
    343363        if (!nc) {
    344364                status = NT_STATUS_NO_MEMORY;
     
    352372            !ctx->force_full_replication && utdv)
    353373        {
    354                 cursors = TALLOC_ZERO_P(mem_ctx,
     374                cursors = talloc_zero(mem_ctx,
    355375                                         struct drsuapi_DsReplicaCursorCtrEx);
    356376                if (!cursors) {
     
    443463
    444464        if (!ctx->single_object_replication) {
    445                 new_utdv = TALLOC_ZERO_P(mem_ctx, struct replUpToDateVectorBlob);
     465                new_utdv = talloc_zero(mem_ctx, struct replUpToDateVectorBlob);
    446466                if (!new_utdv) {
    447467                        status = NT_STATUS_NO_MEMORY;
     
    653673                                                    &pnew_utdv);
    654674                if (!NT_STATUS_IS_OK(status)) {
    655                         ctx->error_message = talloc_asprintf(ctx,
    656                                 "Failed to call DsGetNCCHanges: %s",
    657                                 nt_errstr(status));
     675                        if (!ctx->error_message) {
     676                                ctx->error_message = talloc_asprintf(ctx,
     677                                        "Failed to call DsGetNCCHanges: %s",
     678                                        nt_errstr(status));
     679                        }
    658680                        goto out;
    659681                }
  • vendor/current/source3/libnet/libnet_dssync_keytab.c

    r740 r988  
    2121#include "includes.h"
    2222#include "smb_krb5.h"
    23 #include "ads.h"
    2423#include "libnet/libnet_dssync.h"
    2524#include "libnet/libnet_keytab.h"
     
    201200        }
    202201
    203         pkb = TALLOC_ZERO_P(mem_ctx, struct package_PrimaryKerberosBlob);
     202        pkb = talloc_zero(mem_ctx, struct package_PrimaryKerberosBlob);
    204203        if (!pkb) {
    205204                status = NT_STATUS_NO_MEMORY;
     
    277276                        uint32_t count;
    278277                        num_spns = attr->value_ctr.num_values;
    279                         spn = TALLOC_ARRAY(mem_ctx, char *, num_spns);
     278                        spn = talloc_array(mem_ctx, char *, num_spns);
    280279                        for (count = 0; count < num_spns; count++) {
    281280                                blob = attr->value_ctr.values[count].blob;
     
    388387                                             mem_ctx);
    389388                if (entry) {
    390                         name = (char *)TALLOC_MEMDUP(mem_ctx,
     389                        name = (char *)talloc_memdup(mem_ctx,
    391390                                                     entry->password.data,
    392391                                                     entry->password.length);
  • vendor/current/source3/libnet/libnet_dssync_passdb.c

    r740 r988  
    2525#include "../librpc/gen_ndr/ndr_drsuapi.h"
    2626#include "util_tdb.h"
    27 #include "dbwrap.h"
     27#include "dbwrap/dbwrap.h"
     28#include "dbwrap/dbwrap_rbt.h"
    2829#include "../libds/common/flag_mapping.h"
    2930#include "passdb.h"
     
    6364        NTSTATUS status;
    6465        struct db_record *rec;
    65 
    66         rec = db->fetch_locked(db, talloc_tos(), obj->key);
     66        TDB_DATA value;
     67
     68        rec = dbwrap_fetch_locked(db, talloc_tos(), obj->key);
    6769        if (rec == NULL) {
    6870                return NT_STATUS_NO_MEMORY;
    6971        }
    70         if (rec->value.dsize != 0) {
     72
     73        value = dbwrap_record_get_value(rec);
     74        if (value.dsize != 0) {
    7175                abort();
    7276        }
    7377
    74         status = rec->store(rec, obj->data, TDB_INSERT);
     78        status = dbwrap_record_store(rec, obj->data, TDB_INSERT);
    7579        if (!NT_STATUS_IS_OK(status)) {
    7680                TALLOC_FREE(rec);
     
    103107{
    104108        struct dssync_passdb_obj *obj;
    105         int ret;
    106109        TDB_DATA key;
    107110        TDB_DATA data;
    108 
    109         key = make_tdb_data((const uint8_t *)(void *)guid,
     111        NTSTATUS status;
     112
     113        key = make_tdb_data((const uint8_t *)(const void *)guid,
    110114                             sizeof(*guid));
    111115
    112         ret = db->fetch(db, talloc_tos(), key, &data);
    113         if (ret != 0) {
     116        status = dbwrap_fetch(db, talloc_tos(), key, &data);
     117        if (!NT_STATUS_IS_OK(status)) {
    114118                return NULL;
    115119        }
     
    160164        NTSTATUS status;
    161165        struct db_record *rec;
    162 
    163         rec = obj->members->fetch_locked(obj->members, talloc_tos(), mem->key);
     166        TDB_DATA value;
     167
     168        rec = dbwrap_fetch_locked(obj->members, talloc_tos(), mem->key);
    164169        if (rec == NULL) {
    165170                return NT_STATUS_NO_MEMORY;
    166171        }
    167         if (rec->value.dsize != 0) {
     172
     173        value = dbwrap_record_get_value(rec);
     174        if (value.dsize != 0) {
    168175                abort();
    169176        }
    170177
    171         status = rec->store(rec, mem->data, TDB_INSERT);
     178        status = dbwrap_record_store(rec, mem->data, TDB_INSERT);
    172179        if (!NT_STATUS_IS_OK(status)) {
    173180                TALLOC_FREE(rec);
     
    299306        bool is_member = false;
    300307        const char *action;
     308        TDB_DATA value;
    301309
    302310        state->idx++;
     
    304312        alias_sid = state->obj->cur->object.identifier->sid;
    305313
    306         mem = dssync_parse_mem(rec->value);
     314        value = dbwrap_record_get_value(rec);
     315        mem = dssync_parse_mem(value);
    307316        if (mem == NULL) {
    308317                return -1;
     
    387396        struct dssync_passdb_traverse_amembers mstate;
    388397        struct dssync_passdb_obj *obj;
    389         int ret;
     398        TDB_DATA value;
     399        NTSTATUS status;
    390400
    391401        state->idx++;
     
    394404        }
    395405
    396         obj = dssync_parse_obj(rec->value);
     406        value = dbwrap_record_get_value(rec);
     407        obj = dssync_parse_obj(value);
    397408        if (obj == NULL) {
    398409                return -1;
     
    403414        mstate.name = "members";
    404415        mstate.obj = obj;
    405         ret = obj->members->traverse_read(obj->members,
    406                                           dssync_passdb_traverse_amembers,
    407                                           &mstate);
    408         if (ret < 0) {
     416        status = dbwrap_traverse_read(obj->members,
     417                                      dssync_passdb_traverse_amembers,
     418                                      &mstate, NULL);
     419        if (!NT_STATUS_IS_OK(status)) {
    409420                return -1;
    410421        }
     
    442453        struct samu *member = NULL;
    443454        const char *member_dn = NULL;
    444         GROUP_MAP map;
     455        GROUP_MAP *map;
    445456        struct group *grp;
    446457        uint32_t rid;
    447458        bool is_unix_member = false;
     459        TDB_DATA value;
    448460
    449461        state->idx++;
     
    456468        }
    457469
    458         mem = dssync_parse_mem(rec->value);
     470        value = dbwrap_record_get_value(rec);
     471
     472        mem = dssync_parse_mem(value);
    459473        if (mem == NULL) {
    460474                return -1;
     
    495509        }
    496510
    497         if (!get_domain_group_from_sid(group_sid, &map)) {
     511        map = talloc_zero(NULL, GROUP_MAP);
     512        if (!map) {
     513                return -1;
     514        }
     515
     516        if (!get_domain_group_from_sid(group_sid, map)) {
    498517                DEBUG(0, ("Could not find global group %s\n",
    499518                          sid_string_dbg(&group_sid)));
    500519                //return NT_STATUS_NO_SUCH_GROUP;
     520                TALLOC_FREE(map);
    501521                return -1;
    502522        }
    503523
    504         if (!(grp = getgrgid(map.gid))) {
    505                 DEBUG(0, ("Could not find unix group %lu\n", (unsigned long)map.gid));
     524        if (!(grp = getgrgid(map->gid))) {
     525                DEBUG(0, ("Could not find unix group %lu\n",
     526                                                (unsigned long)map->gid));
    506527                //return NT_STATUS_NO_SUCH_GROUP;
     528                TALLOC_FREE(map);
    507529                return -1;
    508530        }
     531
     532        TALLOC_FREE(map);
    509533
    510534        DEBUG(0,("Group members of %s: ", grp->gr_name));
     
    563587        struct dssync_passdb_traverse_gmembers mstate;
    564588        struct dssync_passdb_obj *obj;
    565         int ret;
     589        TDB_DATA value;
     590        NTSTATUS status;
    566591
    567592        state->idx++;
     
    570595        }
    571596
    572         obj = dssync_parse_obj(rec->value);
     597        value = dbwrap_record_get_value(rec);
     598
     599        obj = dssync_parse_obj(value);
    573600        if (obj == NULL) {
    574601                return -1;
     
    579606        mstate.name = "members";
    580607        mstate.obj = obj;
    581         ret = obj->members->traverse_read(obj->members,
    582                                           dssync_passdb_traverse_gmembers,
    583                                           &mstate);
    584         if (ret < 0) {
     608        status = dbwrap_traverse_read(obj->members,
     609                                      dssync_passdb_traverse_gmembers,
     610                                      &mstate, NULL);
     611        if (!NT_STATUS_IS_OK(status)) {
    585612                return -1;
    586613        }
     
    597624        struct dssync_passdb_traverse_aliases astate;
    598625        struct dssync_passdb_traverse_groups gstate;
    599         int ret;
     626        NTSTATUS status;
    600627
    601628        ZERO_STRUCT(astate);
    602629        astate.ctx = ctx;
    603630        astate.name = "aliases";
    604         ret = pctx->aliases->traverse_read(pctx->aliases,
    605                                            dssync_passdb_traverse_aliases,
    606                                            &astate);
    607         if (ret < 0) {
     631        status = dbwrap_traverse_read(pctx->aliases,
     632                                      dssync_passdb_traverse_aliases,
     633                                      &astate, NULL);
     634        if (!NT_STATUS_IS_OK(status)) {
    608635                return NT_STATUS_INTERNAL_ERROR;
    609636        }
     
    612639        gstate.ctx = ctx;
    613640        gstate.name = "groups";
    614         ret = pctx->groups->traverse_read(pctx->groups,
    615                                           dssync_passdb_traverse_groups,
    616                                           &gstate);
    617         if (ret < 0) {
     641        status = dbwrap_traverse_read(pctx->groups,
     642                                      dssync_passdb_traverse_groups,
     643                                      &gstate, NULL);
     644        if (!NT_STATUS_IS_OK(status)) {
    618645                return NT_STATUS_INTERNAL_ERROR;
    619646        }
     
    644671        /* Create appropriate user */
    645672        if (acct_flags & ACB_NORMAL) {
    646                 add_script = talloc_strdup(mem_ctx, lp_adduser_script());
     673                add_script = lp_add_user_script(mem_ctx);
    647674        } else if ( (acct_flags & ACB_WSTRUST) ||
    648675                    (acct_flags & ACB_SVRTRUST) ||
    649676                    (acct_flags & ACB_DOMTRUST) ) {
    650                 add_script = talloc_strdup(mem_ctx, lp_addmachine_script());
     677                add_script = lp_add_machine_script(mem_ctx);
    651678        } else {
    652679                DEBUG(1, ("Unknown user type: %s\n",
     
    10931120        const char *description;
    10941121        const char *userWorkstations;
    1095         const char *comment;
    10961122        DATA_BLOB userParameters;
    10971123        struct dom_sid objectSid;
     
    11251151        GET_STRING(description);
    11261152        GET_STRING(userWorkstations);
    1127         GET_STRING(comment);
    11281153        GET_BLOB(userParameters);
    11291154        GET_UINT32(primaryGroupID);
     
    13321357        fstring account;
    13331358        struct samu *sam_account=NULL;
    1334         GROUP_MAP map;
     1359        GROUP_MAP *map;
    13351360        struct group *grp;
    13361361        struct dom_sid user_sid;
     
    13411366
    13421367        const char *sAMAccountName;
    1343         uint32_t sAMAccountType;
    13441368        uint32_t userAccountControl;
    13451369
    13461370        user_sid = cur->object.identifier->sid;
    13471371        GET_STRING_EX(sAMAccountName, true);
    1348         GET_UINT32_EX(sAMAccountType, true);
    13491372        GET_UINT32_EX(userAccountControl, true);
    13501373
     
    14141437        group_sid = *pdb_get_group_sid(sam_account);
    14151438
    1416         if (!pdb_getgrsid(&map, group_sid)) {
     1439        map = talloc_zero(NULL, GROUP_MAP);
     1440        if (!map) {
     1441                return NT_STATUS_NO_MEMORY;
     1442        }
     1443
     1444        if (!pdb_getgrsid(map, group_sid)) {
    14171445                DEBUG(0, ("Primary group of %s has no mapping!\n",
    14181446                          pdb_get_username(sam_account)));
    14191447        } else {
    1420                 if (map.gid != passwd->pw_gid) {
    1421                         if (!(grp = getgrgid(map.gid))) {
     1448                if (map->gid != passwd->pw_gid) {
     1449                        if (!(grp = getgrgid(map->gid))) {
    14221450                                DEBUG(0, ("Could not find unix group %lu for user %s (group SID=%s)\n",
    1423                                           (unsigned long)map.gid, pdb_get_username(sam_account),
     1451                                          (unsigned long)map->gid, pdb_get_username(sam_account),
    14241452                                          sid_string_dbg(&group_sid)));
    14251453                        } else {
     
    14291457        }
    14301458
     1459        TALLOC_FREE(map);
     1460
    14311461        if ( !passwd ) {
    14321462                DEBUG(1, ("No unix user for this account (%s), cannot adjust mappings\n",
     
    14471477        struct drsuapi_DsReplicaObjectListItemEx *cur = obj->cur;
    14481478        NTSTATUS status;
    1449         fstring name;
    1450         fstring comment;
    14511479        struct group *grp = NULL;
    14521480        struct dom_sid group_sid;
     
    14541482        struct dom_sid *dom_sid = NULL;
    14551483        fstring sid_string;
    1456         GROUP_MAP map;
     1484        GROUP_MAP *map;
    14571485        bool insert = true;
    14581486
    14591487        const char *sAMAccountName;
    1460         uint32_t sAMAccountType;
    1461         uint32_t groupType;
    14621488        const char *description;
    14631489        uint32_t i;
     
    14671493        group_sid = cur->object.identifier->sid;
    14681494        GET_STRING_EX(sAMAccountName, true);
    1469         GET_UINT32_EX(sAMAccountType, true);
    1470         GET_UINT32_EX(groupType, true);
    14711495        GET_STRING(description);
    14721496
     
    14801504        }
    14811505
    1482         fstrcpy(name, sAMAccountName);
    1483         fstrcpy(comment, description);
    1484 
    14851506        dom_sid_split_rid(mem_ctx, &group_sid, &dom_sid, &rid);
     1507
     1508        map = talloc_zero(mem_ctx, GROUP_MAP);
     1509        if (map == NULL) {
     1510                status = NT_STATUS_NO_MEMORY;
     1511                goto done;
     1512        }
     1513
     1514        map->nt_name = talloc_strdup(map, sAMAccountName);
     1515        if (map->nt_name == NULL) {
     1516                status = NT_STATUS_NO_MEMORY;
     1517                goto done;
     1518        }
     1519
     1520        if (description) {
     1521                map->comment = talloc_strdup(map, description);
     1522        } else {
     1523                map->comment = talloc_strdup(map, "");
     1524        }
     1525        if (map->comment == NULL) {
     1526                status = NT_STATUS_NO_MEMORY;
     1527                goto done;
     1528        }
    14861529
    14871530        sid_to_fstring(sid_string, &group_sid);
    14881531        DEBUG(0,("Creating alias[%s] - %s members[%u]\n",
    1489                   name, sid_string, num_members));
     1532                  map->nt_name, sid_string, num_members));
    14901533
    14911534        status = dssync_insert_obj(pctx, pctx->aliases, obj);
    14921535        if (!NT_STATUS_IS_OK(status)) {
    1493                 return status;
    1494         }
    1495 
    1496         if (pdb_getgrsid(&map, group_sid)) {
    1497                 if ( map.gid != -1 )
    1498                         grp = getgrgid(map.gid);
     1536                goto done;
     1537        }
     1538
     1539        if (pdb_getgrsid(map, group_sid)) {
     1540                if (map->gid != -1) {
     1541                        grp = getgrgid(map->gid);
     1542                }
    14991543                insert = false;
    15001544        }
     
    15041548
    15051549                /* No group found from mapping, find it from its name. */
    1506                 if ((grp = getgrnam(name)) == NULL) {
     1550                if ((grp = getgrnam(map->nt_name)) == NULL) {
    15071551
    15081552                        /* No appropriate group found, create one */
    15091553
    1510                         DEBUG(0,("Creating unix group: '%s'\n", name));
    1511 
    1512                         if (smb_create_group(name, &gid) != 0)
    1513                                 return NT_STATUS_ACCESS_DENIED;
    1514 
    1515                         if ((grp = getgrgid(gid)) == NULL)
    1516                                 return NT_STATUS_ACCESS_DENIED;
    1517                 }
    1518         }
    1519 
    1520         map.gid = grp->gr_gid;
    1521         map.sid = group_sid;
     1554                        DEBUG(0, ("Creating unix group: '%s'\n",
     1555                                                        map->nt_name));
     1556
     1557                        if (smb_create_group(map->nt_name, &gid) != 0) {
     1558                                status = NT_STATUS_ACCESS_DENIED;
     1559                                goto done;
     1560                        }
     1561
     1562                        if ((grp = getgrgid(gid)) == NULL) {
     1563                                status = NT_STATUS_ACCESS_DENIED;
     1564                                goto done;
     1565                        }
     1566                }
     1567        }
     1568
     1569        map->gid = grp->gr_gid;
     1570        map->sid = group_sid;
    15221571
    15231572        if (dom_sid_equal(dom_sid, &global_sid_Builtin)) {
     
    15271576                 * map.sid_name_use = SID_NAME_WKN_GRP;
    15281577                 */
    1529                 map.sid_name_use = SID_NAME_ALIAS;
     1578                map->sid_name_use = SID_NAME_ALIAS;
    15301579        } else {
    1531                 map.sid_name_use = SID_NAME_ALIAS;
    1532         }
    1533 
    1534         fstrcpy(map.nt_name, name);
    1535         if (description) {
    1536                 fstrcpy(map.comment, comment);
     1580                map->sid_name_use = SID_NAME_ALIAS;
     1581        }
     1582
     1583        if (insert) {
     1584                pdb_add_group_mapping_entry(map);
    15371585        } else {
    1538                 fstrcpy(map.comment, "");
    1539         }
    1540 
    1541         if (insert)
    1542                 pdb_add_group_mapping_entry(&map);
    1543         else
    1544                 pdb_update_group_mapping_entry(&map);
     1586                pdb_update_group_mapping_entry(map);
     1587        }
    15451588
    15461589        for (i=0; i < num_members; i++) {
     
    15511594                                           &members[i], &mem);
    15521595                if (!NT_STATUS_IS_OK(status)) {
    1553                         return status;
    1554                 }
    1555         }
    1556 
    1557         return NT_STATUS_OK;
     1596                        goto done;
     1597                }
     1598        }
     1599
     1600        status = NT_STATUS_OK;
     1601
     1602done:
     1603        TALLOC_FREE(map);
     1604        return status;
    15581605}
    15591606
     
    15671614        struct drsuapi_DsReplicaObjectListItemEx *cur = obj->cur;
    15681615        NTSTATUS status;
    1569         fstring name;
    1570         fstring comment;
    15711616        struct group *grp = NULL;
    15721617        struct dom_sid group_sid;
    15731618        fstring sid_string;
    1574         GROUP_MAP map;
     1619        GROUP_MAP *map;
    15751620        bool insert = true;
    15761621
    15771622        const char *sAMAccountName;
    1578         uint32_t sAMAccountType;
    1579         uint32_t groupType;
    15801623        const char *description;
    15811624        uint32_t i;
     
    15851628        group_sid = cur->object.identifier->sid;
    15861629        GET_STRING_EX(sAMAccountName, true);
    1587         GET_UINT32_EX(sAMAccountType, true);
    1588         GET_UINT32_EX(groupType, true);
    15891630        GET_STRING(description);
    15901631
     
    15981639        }
    15991640
    1600         fstrcpy(name, sAMAccountName);
    1601         fstrcpy(comment, description);
     1641        map = talloc_zero(NULL, GROUP_MAP);
     1642        if (!map) {
     1643                return NT_STATUS_NO_MEMORY;
     1644        }
     1645
     1646        map->nt_name = talloc_strdup(map, sAMAccountName);
     1647        if (!map->nt_name) {
     1648                status = NT_STATUS_NO_MEMORY;
     1649                goto done;
     1650        }
     1651        if (description) {
     1652                map->comment = talloc_strdup(map, description);
     1653        } else {
     1654                map->comment = talloc_strdup(map, "");
     1655        }
     1656        if (!map->comment) {
     1657                status = NT_STATUS_NO_MEMORY;
     1658                goto done;
     1659        }
    16021660
    16031661        sid_to_fstring(sid_string, &group_sid);
    16041662        DEBUG(0,("Creating group[%s] - %s members [%u]\n",
    1605                   name, sid_string, num_members));
     1663                  map->nt_name, sid_string, num_members));
    16061664
    16071665        status = dssync_insert_obj(pctx, pctx->groups, obj);
    16081666        if (!NT_STATUS_IS_OK(status)) {
    1609                 return status;
    1610         }
    1611 
    1612         if (pdb_getgrsid(&map, group_sid)) {
    1613                 if ( map.gid != -1 )
    1614                         grp = getgrgid(map.gid);
     1667                goto done;
     1668        }
     1669
     1670        if (pdb_getgrsid(map, group_sid)) {
     1671                if (map->gid != -1) {
     1672                        grp = getgrgid(map->gid);
     1673                }
    16151674                insert = false;
    16161675        }
     
    16201679
    16211680                /* No group found from mapping, find it from its name. */
    1622                 if ((grp = getgrnam(name)) == NULL) {
     1681                if ((grp = getgrnam(map->nt_name)) == NULL) {
    16231682
    16241683                        /* No appropriate group found, create one */
    16251684
    1626                         DEBUG(0,("Creating unix group: '%s'\n", name));
    1627 
    1628                         if (smb_create_group(name, &gid) != 0)
    1629                                 return NT_STATUS_ACCESS_DENIED;
    1630 
    1631                         if ((grp = getgrnam(name)) == NULL)
    1632                                 return NT_STATUS_ACCESS_DENIED;
    1633                 }
    1634         }
    1635 
    1636         map.gid = grp->gr_gid;
    1637         map.sid = group_sid;
    1638         map.sid_name_use = SID_NAME_DOM_GRP;
    1639         fstrcpy(map.nt_name, name);
    1640         if (description) {
    1641                 fstrcpy(map.comment, comment);
     1685                        DEBUG(0, ("Creating unix group: '%s'\n",
     1686                                                        map->nt_name));
     1687
     1688                        if (smb_create_group(map->nt_name, &gid) != 0) {
     1689                                status = NT_STATUS_ACCESS_DENIED;
     1690                                goto done;
     1691                        }
     1692
     1693                        if ((grp = getgrnam(map->nt_name)) == NULL) {
     1694                                status = NT_STATUS_ACCESS_DENIED;
     1695                                goto done;
     1696                        }
     1697                }
     1698        }
     1699
     1700        map->gid = grp->gr_gid;
     1701        map->sid = group_sid;
     1702        map->sid_name_use = SID_NAME_DOM_GRP;
     1703
     1704        if (insert) {
     1705                pdb_add_group_mapping_entry(map);
    16421706        } else {
    1643                 fstrcpy(map.comment, "");
    1644         }
    1645 
    1646         if (insert)
    1647                 pdb_add_group_mapping_entry(&map);
    1648         else
    1649                 pdb_update_group_mapping_entry(&map);
     1707                pdb_update_group_mapping_entry(map);
     1708        }
    16501709
    16511710        for (i=0; i < num_members; i++) {
     
    16561715                                           &members[i], &mem);
    16571716                if (!NT_STATUS_IS_OK(status)) {
    1658                         return status;
    1659                 }
    1660         }
    1661 
    1662         return NT_STATUS_OK;
     1717                        goto done;
     1718                }
     1719        }
     1720
     1721        status = NT_STATUS_OK;
     1722
     1723done:
     1724        TALLOC_FREE(map);
     1725        return status;
    16631726}
    16641727
     
    17071770
    17081771        char *name = NULL;
    1709         uint32_t uacc = 0;
    17101772        uint32_t sam_type = 0;
    17111773
     
    17341796                        case DRSUAPI_ATTID_sAMAccountType:
    17351797                                sam_type = IVAL(blob->data, 0);
    1736                                 break;
    1737                         case DRSUAPI_ATTID_userAccountControl:
    1738                                 uacc = IVAL(blob->data, 0);
    17391798                                break;
    17401799                        default:
  • vendor/current/source3/libnet/libnet_join.c

    r860 r988  
    3939#include "passdb.h"
    4040#include "libsmb/libsmb.h"
     41#include "../libcli/smb/smbXcli_base.h"
     42#include "lib/param/loadparm.h"
     43#include "libcli/auth/netlogon_creds_cli.h"
     44#include "auth/credentials/credentials.h"
     45#include "krb5_env.h"
    4146
    4247/****************************************************************
     
    115120                                     const char *user_name,
    116121                                     const char *password,
     122                                     const char *ccname,
    117123                                     ADS_STRUCT **ads)
    118124{
     
    135141                        SAFE_FREE(my_ads->auth.realm);
    136142                        my_ads->auth.realm = smb_xstrdup(cp);
    137                         strupper_m(my_ads->auth.realm);
     143                        if (!strupper_m(my_ads->auth.realm)) {
     144                                ads_destroy(&my_ads);
     145                                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
     146                        }
    138147                }
    139148        }
     
    144153        }
    145154
     155        if (ccname != NULL) {
     156                SAFE_FREE(my_ads->auth.ccache_name);
     157                my_ads->auth.ccache_name = SMB_STRDUP(ccname);
     158                setenv(KRB5_ENV_CCNAME, my_ads->auth.ccache_name, 1);
     159        }
     160
    146161        status = ads_connect_user_creds(my_ads);
    147162        if (!ADS_ERR_OK(status)) {
     
    158173
    159174static ADS_STATUS libnet_join_connect_ads(TALLOC_CTX *mem_ctx,
    160                                           struct libnet_JoinCtx *r)
     175                                          struct libnet_JoinCtx *r,
     176                                          bool use_machine_creds)
    161177{
    162178        ADS_STATUS status;
     179        const char *username;
     180        const char *password;
     181        const char *ccname = NULL;
     182
     183        if (use_machine_creds) {
     184                if (r->in.machine_name == NULL ||
     185                    r->in.machine_password == NULL) {
     186                        return ADS_ERROR_NT(NT_STATUS_INVALID_PARAMETER);
     187                }
     188                username = talloc_strdup(mem_ctx, r->in.machine_name);
     189                if (username == NULL) {
     190                        return ADS_ERROR(LDAP_NO_MEMORY);
     191                }
     192                if (username[strlen(username)] != '$') {
     193                        username = talloc_asprintf(username, "%s$", username);
     194                        if (username == NULL) {
     195                                return ADS_ERROR(LDAP_NO_MEMORY);
     196                        }
     197                }
     198                password = r->in.machine_password;
     199                ccname = "MEMORY:libnet_join_machine_creds";
     200        } else {
     201                username = r->in.admin_account;
     202                password = r->in.admin_password;
     203
     204                /*
     205                 * when r->in.use_kerberos is set to allow "net ads join -k" we
     206                 * may not override the provided credential cache - gd
     207                 */
     208
     209                if (!r->in.use_kerberos) {
     210                        ccname = "MEMORY:libnet_join_user_creds";
     211                }
     212        }
    163213
    164214        status = libnet_connect_ads(r->out.dns_domain_name,
    165215                                    r->out.netbios_domain_name,
    166216                                    r->in.dc_name,
    167                                     r->in.admin_account,
    168                                     r->in.admin_password,
     217                                    username,
     218                                    password,
     219                                    ccname,
    169220                                    &r->in.ads);
    170221        if (!ADS_ERR_OK(status)) {
     
    195246****************************************************************/
    196247
     248static ADS_STATUS libnet_join_connect_ads_user(TALLOC_CTX *mem_ctx,
     249                                               struct libnet_JoinCtx *r)
     250{
     251        return libnet_join_connect_ads(mem_ctx, r, false);
     252}
     253
     254/****************************************************************
     255****************************************************************/
     256
     257static ADS_STATUS libnet_join_connect_ads_machine(TALLOC_CTX *mem_ctx,
     258                                                  struct libnet_JoinCtx *r)
     259{
     260        return libnet_join_connect_ads(mem_ctx, r, true);
     261}
     262
     263/****************************************************************
     264****************************************************************/
     265
    197266static ADS_STATUS libnet_unjoin_connect_ads(TALLOC_CTX *mem_ctx,
    198267                                            struct libnet_UnjoinCtx *r)
     
    205274                                    r->in.admin_account,
    206275                                    r->in.admin_password,
     276                                    NULL,
    207277                                    &r->in.ads);
    208278        if (!ADS_ERR_OK(status)) {
     
    249319        status = ads_create_machine_acct(r->in.ads,
    250320                                         r->in.machine_name,
    251                                          r->in.account_ou);
     321                                         r->in.account_ou,
     322                                         r->in.desired_encryption_types);
    252323
    253324        if (ADS_ERR_OK(status)) {
     
    347418        }
    348419
     420        if (!ads_pull_uint32(r->in.ads, res, "msDS-SupportedEncryptionTypes",
     421                             &r->out.set_encryption_types)) {
     422                r->out.set_encryption_types = 0;
     423        }
     424
    349425 done:
    350426        ads_msgfree(r->in.ads, res);
     
    354430}
    355431
     432static ADS_STATUS libnet_join_get_machine_spns(TALLOC_CTX *mem_ctx,
     433                                               struct libnet_JoinCtx *r,
     434                                               char ***spn_array,
     435                                               size_t *num_spns)
     436{
     437        ADS_STATUS status;
     438
     439        if (r->in.machine_name == NULL) {
     440                return ADS_ERROR_SYSTEM(EINVAL);
     441        }
     442
     443        status = ads_get_service_principal_names(mem_ctx,
     444                                                 r->in.ads,
     445                                                 r->in.machine_name,
     446                                                 spn_array,
     447                                                 num_spns);
     448
     449        return status;
     450}
     451
    356452/****************************************************************
    357453 Set a machines dNSHostName and servicePrincipalName attributes
     
    364460        ADS_MODLIST mods;
    365461        fstring my_fqdn;
    366         const char *spn_array[3] = {NULL, NULL, NULL};
     462        const char **spn_array = NULL;
     463        size_t num_spns = 0;
    367464        char *spn = NULL;
     465        bool ok;
    368466
    369467        /* Find our DN */
     
    372470        if (!ADS_ERR_OK(status)) {
    373471                return status;
     472        }
     473
     474        status = libnet_join_get_machine_spns(mem_ctx,
     475                                              r,
     476                                              discard_const_p(char **, &spn_array),
     477                                              &num_spns);
     478        if (!ADS_ERR_OK(status)) {
     479                DEBUG(5, ("Retrieving the servicePrincipalNames failed.\n"));
    374480        }
    375481
     
    380486                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
    381487        }
    382         strupper_m(spn);
    383         spn_array[0] = spn;
     488        if (!strupper_m(spn)) {
     489                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
     490        }
     491
     492        ok = ads_element_in_array(spn_array, num_spns, spn);
     493        if (!ok) {
     494                ok = add_string_to_array(spn_array, spn,
     495                                         &spn_array, &num_spns);
     496                if (!ok) {
     497                        return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
     498                }
     499        }
    384500
    385501        if (!name_to_fqdn(my_fqdn, r->in.machine_name)
     
    389505        }
    390506
    391         strlower_m(my_fqdn);
     507        if (!strlower_m(my_fqdn)) {
     508                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
     509        }
    392510
    393511        if (!strequal(my_fqdn, r->in.machine_name)) {
     
    396514                        return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
    397515                }
    398                 spn_array[1] = spn;
    399         }
     516
     517                ok = ads_element_in_array(spn_array, num_spns, spn);
     518                if (!ok) {
     519                        ok = add_string_to_array(spn_array, spn,
     520                                                 &spn_array, &num_spns);
     521                        if (!ok) {
     522                                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
     523                        }
     524                }
     525        }
     526
     527        /* make sure to NULL terminate the array */
     528        spn_array = talloc_realloc(mem_ctx, spn_array, const char *, num_spns + 1);
     529        if (spn_array == NULL) {
     530                return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
     531        }
     532        spn_array[num_spns] = NULL;
    400533
    401534        mods = ads_init_mods(mem_ctx);
     
    441574
    442575        if (!r->in.upn) {
     576                const char *realm = r->out.dns_domain_name;
     577
     578                /* in case we are about to generate a keytab during the join
     579                 * make sure the default upn we create is usable with kinit -k.
     580                 * gd */
     581
     582                if (USE_KERBEROS_KEYTAB) {
     583                        realm = talloc_strdup_upper(mem_ctx,
     584                                                    r->out.dns_domain_name);
     585                }
     586
     587                if (!realm) {
     588                        return ADS_ERROR(LDAP_NO_MEMORY);
     589                }
     590
    443591                r->in.upn = talloc_asprintf(mem_ctx,
    444592                                            "host/%s@%s",
    445593                                            r->in.machine_name,
    446                                             r->out.dns_domain_name);
     594                                            realm);
    447595                if (!r->in.upn) {
    448596                        return ADS_ERROR(LDAP_NO_MEMORY);
     
    496644        }
    497645
    498         os_sp = talloc_asprintf(mem_ctx, "Samba %s", samba_version_string());
    499         if (!os_sp) {
     646        if (r->in.os_servicepack) {
     647                /*
     648                 * if blank string then leave os_sp equal to NULL to force
     649                 * attribute delete (LDAP_MOD_DELETE)
     650                 */
     651                if (!strequal(r->in.os_servicepack,"")) {
     652                        os_sp = talloc_strdup(mem_ctx, r->in.os_servicepack);
     653                }
     654        } else {
     655                os_sp = talloc_asprintf(mem_ctx, "Samba %s",
     656                                        samba_version_string());
     657        }
     658        if (!os_sp && !strequal(r->in.os_servicepack,"")) {
    500659                return ADS_ERROR(LDAP_NO_MEMORY);
    501660        }
     
    522681
    523682        return ads_gen_mod(r->in.ads, r->out.dn, mods);
     683}
     684
     685/****************************************************************
     686****************************************************************/
     687
     688static ADS_STATUS libnet_join_set_etypes(TALLOC_CTX *mem_ctx,
     689                                         struct libnet_JoinCtx *r)
     690{
     691        ADS_STATUS status;
     692        ADS_MODLIST mods;
     693        const char *etype_list_str;
     694
     695        etype_list_str = talloc_asprintf(mem_ctx, "%d",
     696                                         r->in.desired_encryption_types);
     697        if (!etype_list_str) {
     698                return ADS_ERROR(LDAP_NO_MEMORY);
     699        }
     700
     701        /* Find our DN */
     702
     703        status = libnet_join_find_machine_acct(mem_ctx, r);
     704        if (!ADS_ERR_OK(status)) {
     705                return status;
     706        }
     707
     708        if (r->in.desired_encryption_types == r->out.set_encryption_types) {
     709                return ADS_SUCCESS;
     710        }
     711
     712        /* now do the mods */
     713
     714        mods = ads_init_mods(mem_ctx);
     715        if (!mods) {
     716                return ADS_ERROR(LDAP_NO_MEMORY);
     717        }
     718
     719        status = ads_mod_str(mem_ctx, &mods, "msDS-SupportedEncryptionTypes",
     720                             etype_list_str);
     721        if (!ADS_ERR_OK(status)) {
     722                return status;
     723        }
     724
     725        status = ads_gen_mod(r->in.ads, r->out.dn, mods);
     726        if (!ADS_ERR_OK(status)) {
     727                return status;
     728        }
     729
     730        r->out.set_encryption_types = r->in.desired_encryption_types;
     731
     732        return ADS_SUCCESS;
    524733}
    525734
     
    601810{
    602811        ADS_STATUS status;
     812        bool need_etype_update = false;
    603813
    604814        if (!r->in.ads) {
    605                 status = libnet_join_connect_ads(mem_ctx, r);
     815                status = libnet_join_connect_ads_user(mem_ctx, r);
    606816                if (!ADS_ERR_OK(status)) {
    607817                        return status;
     
    612822        if (!ADS_ERR_OK(status)) {
    613823                libnet_join_set_error_string(mem_ctx, r,
    614                         "failed to set machine spn: %s",
     824                        "Failed to set machine spn: %s\n"
     825                        "Do you have sufficient permissions to create machine "
     826                        "accounts?",
    615827                        ads_errstr(status));
    616828                return status;
     
    631843                        ads_errstr(status));
    632844                return status;
     845        }
     846
     847        status = libnet_join_find_machine_acct(mem_ctx, r);
     848        if (!ADS_ERR_OK(status)) {
     849                return status;
     850        }
     851
     852        if (r->in.desired_encryption_types != r->out.set_encryption_types) {
     853                uint32_t func_level = 0;
     854
     855                status = ads_domain_func_level(r->in.ads, &func_level);
     856                if (!ADS_ERR_OK(status)) {
     857                        libnet_join_set_error_string(mem_ctx, r,
     858                                "failed to query domain controller functional level: %s",
     859                                ads_errstr(status));
     860                        return status;
     861                }
     862
     863                if (func_level >= DS_DOMAIN_FUNCTION_2008) {
     864                        need_etype_update = true;
     865                }
     866        }
     867
     868        if (need_etype_update) {
     869                /*
     870                 * We need to reconnect as machine account in order
     871                 * to update msDS-SupportedEncryptionTypes reliable
     872                 */
     873
     874                if (r->in.ads->auth.ccache_name != NULL) {
     875                        ads_kdestroy(r->in.ads->auth.ccache_name);
     876                }
     877
     878                ads_destroy(&r->in.ads);
     879
     880                status = libnet_join_connect_ads_machine(mem_ctx, r);
     881                if (!ADS_ERR_OK(status)) {
     882                        libnet_join_set_error_string(mem_ctx, r,
     883                                "Failed to connect as machine account: %s",
     884                                ads_errstr(status));
     885                        return status;
     886                }
     887
     888                status = libnet_join_set_etypes(mem_ctx, r);
     889                if (!ADS_ERR_OK(status)) {
     890                        libnet_join_set_error_string(mem_ctx, r,
     891                                "failed to set machine kerberos encryption types: %s",
     892                                ads_errstr(status));
     893                        return status;
     894                }
    633895        }
    634896
     
    678940static NTSTATUS libnet_join_connect_dc_ipc(const char *dc,
    679941                                           const char *user,
     942                                           const char *domain,
    680943                                           const char *pass,
    681944                                           bool use_kerberos,
     
    697960                                   "IPC$", "IPC",
    698961                                   user,
    699                                    NULL,
     962                                   domain,
    700963                                   pass,
    701964                                   flags,
    702                                    Undefined);
     965                                   SMB_SIGNING_IPC_DEFAULT);
    703966}
    704967
     
    719982        status = libnet_join_connect_dc_ipc(r->in.dc_name,
    720983                                            r->in.admin_account,
     984                                            r->in.admin_domain,
    721985                                            r->in.admin_password,
    722986                                            r->in.use_kerberos,
     
    726990        }
    727991
    728         status = cli_rpc_pipe_open_noauth(*cli, &ndr_table_lsarpc.syntax_id,
     992        status = cli_rpc_pipe_open_noauth(*cli, &ndr_table_lsarpc,
    729993                                          &pipe_hnd);
    730994        if (!NT_STATUS_IS_OK(status)) {
     
    7901054                                                    struct cli_state *cli)
    7911055{
    792         struct rpc_pipe_client *pipe_hnd = NULL;
    793         unsigned char orig_trust_passwd_hash[16];
    794         unsigned char new_trust_passwd_hash[16];
    795         fstring trust_passwd;
     1056        TALLOC_CTX *frame = talloc_stackframe();
     1057        struct rpc_pipe_client *netlogon_pipe = NULL;
     1058        struct netlogon_creds_cli_context *netlogon_creds = NULL;
     1059        struct samr_Password current_nt_hash;
     1060        const char *account_name = NULL;
    7961061        NTSTATUS status;
    7971062
    798         status = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon.syntax_id,
    799                                           &pipe_hnd);
    800         if (!NT_STATUS_IS_OK(status)) {
     1063        status = cli_rpc_pipe_open_noauth(cli, &ndr_table_netlogon,
     1064                                          &netlogon_pipe);
     1065        if (!NT_STATUS_IS_OK(status)) {
     1066                TALLOC_FREE(frame);
    8011067                return status;
    8021068        }
    8031069
    8041070        if (!r->in.machine_password) {
    805                 r->in.machine_password = generate_random_str(mem_ctx, DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
    806                 NT_STATUS_HAVE_NO_MEMORY(r->in.machine_password);
    807         }
    808 
    809         E_md4hash(r->in.machine_password, new_trust_passwd_hash);
     1071                r->in.machine_password = generate_random_password(mem_ctx,
     1072                                DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH,
     1073                                DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
     1074                if (r->in.machine_password == NULL) {
     1075                        TALLOC_FREE(frame);
     1076                        return NT_STATUS_NO_MEMORY;
     1077                }
     1078        }
    8101079
    8111080        /* according to WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED */
    812         fstrcpy(trust_passwd, r->in.admin_password);
    813         strlower_m(trust_passwd);
    814 
    815         /*
    816          * Machine names can be 15 characters, but the max length on
    817          * a password is 14.  --jerry
    818          */
    819 
    820         trust_passwd[14] = '\0';
    821 
    822         E_md4hash(trust_passwd, orig_trust_passwd_hash);
    823 
    824         status = rpccli_netlogon_set_trust_password(pipe_hnd, mem_ctx,
    825                                                     r->in.machine_name,
    826                                                     orig_trust_passwd_hash,
    827                                                     r->in.machine_password,
    828                                                     new_trust_passwd_hash,
    829                                                     r->in.secure_channel_type);
    830 
    831         return status;
     1081        E_md4hash(r->in.admin_password, current_nt_hash.hash);
     1082
     1083        account_name = talloc_asprintf(frame, "%s$",
     1084                                       r->in.machine_name);
     1085        if (account_name == NULL) {
     1086                TALLOC_FREE(frame);
     1087                return NT_STATUS_NO_MEMORY;
     1088        }
     1089
     1090        status = rpccli_create_netlogon_creds(netlogon_pipe->desthost,
     1091                                              r->in.domain_name,
     1092                                              account_name,
     1093                                              r->in.secure_channel_type,
     1094                                              r->in.msg_ctx,
     1095                                              frame,
     1096                                              &netlogon_creds);
     1097        if (!NT_STATUS_IS_OK(status)) {
     1098                TALLOC_FREE(frame);
     1099                return status;
     1100        }
     1101
     1102        status = rpccli_setup_netlogon_creds(cli, NCACN_NP,
     1103                                             netlogon_creds,
     1104                                             true, /* force_reauth */
     1105                                             current_nt_hash,
     1106                                             NULL); /* previous_nt_hash */
     1107        if (!NT_STATUS_IS_OK(status)) {
     1108                TALLOC_FREE(frame);
     1109                return status;
     1110        }
     1111
     1112        status = netlogon_creds_cli_ServerPasswordSet(netlogon_creds,
     1113                                                      netlogon_pipe->binding_handle,
     1114                                                      r->in.machine_password,
     1115                                                      NULL); /* new_version */
     1116        if (!NT_STATUS_IS_OK(status)) {
     1117                TALLOC_FREE(frame);
     1118                return status;
     1119        }
     1120
     1121        TALLOC_FREE(frame);
     1122        return NT_STATUS_OK;
    8321123}
    8331124
     
    8531144        unsigned int old_timeout = 0;
    8541145
     1146        DATA_BLOB session_key = data_blob_null;
    8551147        struct samr_CryptPassword crypt_pwd;
    8561148        struct samr_CryptPasswordEx crypt_pwd_ex;
     
    8721164
    8731165        if (!r->in.machine_password) {
    874                 r->in.machine_password = generate_random_str(mem_ctx, DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
     1166                r->in.machine_password = generate_random_password(mem_ctx,
     1167                                DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH,
     1168                                DEFAULT_TRUST_ACCOUNT_PASSWORD_LENGTH);
    8751169                NT_STATUS_HAVE_NO_MEMORY(r->in.machine_password);
    8761170        }
     
    8781172        /* Open the domain */
    8791173
    880         status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
     1174        status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr,
    8811175                                          &pipe_hnd);
    8821176        if (!NT_STATUS_IS_OK(status)) {
     
    8871181
    8881182        b = pipe_hnd->binding_handle;
     1183
     1184        status = cli_get_session_key(mem_ctx, pipe_hnd, &session_key);
     1185        if (!NT_STATUS_IS_OK(status)) {
     1186                DEBUG(0,("Error getting session_key of SAM pipe. Error was %s\n",
     1187                        nt_errstr(status)));
     1188                goto done;
     1189        }
    8891190
    8901191        status = dcerpc_samr_Connect2(b, mem_ctx,
     
    9211222
    9221223        acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name);
    923         strlower_m(acct_name);
     1224        if (!strlower_m(acct_name)) {
     1225                status = NT_STATUS_INVALID_PARAMETER;
     1226                goto done;
     1227        }
    9241228
    9251229        init_lsa_String(&lsa_acct_name, acct_name);
     
    10781382
    10791383        init_samr_CryptPasswordEx(r->in.machine_password,
    1080                                   &cli->user_session_key,
     1384                                  &session_key,
    10811385                                  &crypt_pwd_ex);
    10821386
     
    10951399
    10961400                init_samr_CryptPassword(r->in.machine_password,
    1097                                         &cli->user_session_key,
     1401                                        &session_key,
    10981402                                        &crypt_pwd);
    10991403
     
    11411445        }
    11421446
     1447        data_blob_clear_free(&session_key);
     1448
    11431449        if (is_valid_policy_hnd(&sam_pol)) {
    11441450                dcerpc_samr_Close(b, mem_ctx, &sam_pol, &result);
     
    11581464****************************************************************/
    11591465
    1160 NTSTATUS libnet_join_ok(const char *netbios_domain_name,
    1161                         const char *machine_name,
    1162                         const char *dc_name)
    1163 {
    1164         uint32_t neg_flags = NETLOGON_NEG_AUTH2_ADS_FLAGS;
     1466NTSTATUS libnet_join_ok(struct messaging_context *msg_ctx,
     1467                        const char *netbios_domain_name,
     1468                        const char *dc_name,
     1469                        const bool use_kerberos)
     1470{
     1471        TALLOC_CTX *frame = talloc_stackframe();
    11651472        struct cli_state *cli = NULL;
    1166         struct rpc_pipe_client *pipe_hnd = NULL;
    11671473        struct rpc_pipe_client *netlogon_pipe = NULL;
     1474        struct cli_credentials *cli_creds = NULL;
     1475        struct netlogon_creds_cli_context *netlogon_creds = NULL;
     1476        struct netlogon_creds_CredentialState *creds = NULL;
     1477        uint32_t netlogon_flags = 0;
    11681478        NTSTATUS status;
    1169         char *machine_password = NULL;
    1170         char *machine_account = NULL;
     1479        const char *machine_account = NULL;
     1480        const char *machine_domain = NULL;
     1481        const char *machine_password = NULL;
     1482        int flags = 0;
    11711483
    11721484        if (!dc_name) {
     1485                TALLOC_FREE(frame);
    11731486                return NT_STATUS_INVALID_PARAMETER;
    11741487        }
    11751488
    11761489        if (!secrets_init()) {
     1490                TALLOC_FREE(frame);
    11771491                return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
    11781492        }
    11791493
    1180         machine_password = secrets_fetch_machine_password(netbios_domain_name,
    1181                                                           NULL, NULL);
    1182         if (!machine_password) {
    1183                 return NT_STATUS_NO_TRUST_LSA_SECRET;
    1184         }
    1185 
    1186         if (asprintf(&machine_account, "%s$", machine_name) == -1) {
    1187                 SAFE_FREE(machine_password);
    1188                 return NT_STATUS_NO_MEMORY;
    1189         }
     1494        status = pdb_get_trust_credentials(netbios_domain_name, NULL,
     1495                                           frame, &cli_creds);
     1496        if (!NT_STATUS_IS_OK(status)) {
     1497                TALLOC_FREE(frame);
     1498                return status;
     1499        }
     1500
     1501        /* we don't want any old password */
     1502        cli_credentials_set_old_password(cli_creds, NULL, CRED_SPECIFIED);
     1503
     1504        if (use_kerberos) {
     1505                flags |= CLI_FULL_CONNECTION_USE_KERBEROS;
     1506        }
     1507
     1508        machine_account = cli_credentials_get_username(cli_creds);
     1509        machine_domain = cli_credentials_get_domain(cli_creds);
     1510        machine_password = cli_credentials_get_password(cli_creds);
    11901511
    11911512        status = cli_full_connection(&cli, NULL,
     
    11941515                                     "IPC$", "IPC",
    11951516                                     machine_account,
    1196                                      NULL,
     1517                                     machine_domain,
    11971518                                     machine_password,
    1198                                      0,
    1199                                      Undefined);
    1200         free(machine_account);
    1201         free(machine_password);
     1519                                     flags,
     1520                                     SMB_SIGNING_IPC_DEFAULT);
    12021521
    12031522        if (!NT_STATUS_IS_OK(status)) {
     
    12101529                                             "",
    12111530                                             0,
    1212                                              Undefined);
    1213         }
    1214 
    1215         if (!NT_STATUS_IS_OK(status)) {
    1216                 return status;
    1217         }
    1218 
    1219         status = get_schannel_session_key(cli, netbios_domain_name,
    1220                                           &neg_flags, &netlogon_pipe);
    1221         if (!NT_STATUS_IS_OK(status)) {
    1222                 if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_NETWORK_RESPONSE)) {
    1223                         cli_shutdown(cli);
    1224                         return NT_STATUS_OK;
    1225                 }
    1226 
    1227                 DEBUG(0,("libnet_join_ok: failed to get schannel session "
    1228                         "key from server %s for domain %s. Error was %s\n",
    1229                 cli->desthost, netbios_domain_name, nt_errstr(status)));
     1531                                             SMB_SIGNING_IPC_DEFAULT);
     1532        }
     1533
     1534        if (!NT_STATUS_IS_OK(status)) {
     1535                TALLOC_FREE(frame);
     1536                return status;
     1537        }
     1538
     1539        status = rpccli_create_netlogon_creds_with_creds(cli_creds,
     1540                                                         dc_name,
     1541                                                         msg_ctx,
     1542                                                         frame,
     1543                                                         &netlogon_creds);
     1544        if (!NT_STATUS_IS_OK(status)) {
    12301545                cli_shutdown(cli);
    1231                 return status;
    1232         }
    1233 
    1234         if (!lp_client_schannel()) {
     1546                TALLOC_FREE(frame);
     1547                return status;
     1548        }
     1549
     1550        status = rpccli_setup_netlogon_creds_with_creds(cli, NCACN_NP,
     1551                                                        netlogon_creds,
     1552                                                        true, /* force_reauth */
     1553                                                        cli_creds);
     1554        if (!NT_STATUS_IS_OK(status)) {
     1555                DEBUG(0,("connect_to_domain_password_server: "
     1556                         "unable to open the domain client session to "
     1557                         "machine %s. Flags[0x%08X] Error was : %s.\n",
     1558                         dc_name, (unsigned)netlogon_flags,
     1559                         nt_errstr(status)));
    12351560                cli_shutdown(cli);
     1561                TALLOC_FREE(frame);
     1562                return status;
     1563        }
     1564
     1565        status = netlogon_creds_cli_get(netlogon_creds,
     1566                                        talloc_tos(),
     1567                                        &creds);
     1568        if (!NT_STATUS_IS_OK(status)) {
     1569                cli_shutdown(cli);
     1570                TALLOC_FREE(frame);
     1571                return status;
     1572        }
     1573        netlogon_flags = creds->negotiate_flags;
     1574        TALLOC_FREE(creds);
     1575
     1576        if (!(netlogon_flags & NETLOGON_NEG_AUTHENTICATED_RPC)) {
     1577                cli_shutdown(cli);
     1578                TALLOC_FREE(frame);
    12361579                return NT_STATUS_OK;
    12371580        }
    12381581
    1239         status = cli_rpc_pipe_open_schannel_with_key(
    1240                 cli, &ndr_table_netlogon.syntax_id, NCACN_NP,
    1241                 DCERPC_AUTH_LEVEL_PRIVACY,
    1242                 netbios_domain_name, &netlogon_pipe->dc, &pipe_hnd);
    1243 
    1244         cli_shutdown(cli);
     1582        status = cli_rpc_pipe_open_schannel_with_creds(
     1583                cli, &ndr_table_netlogon, NCACN_NP,
     1584                cli_creds,
     1585                netlogon_creds, &netlogon_pipe);
     1586
     1587        TALLOC_FREE(netlogon_pipe);
    12451588
    12461589        if (!NT_STATUS_IS_OK(status)) {
     
    12481591                        "on netlogon pipe to server %s for domain %s. "
    12491592                        "Error was %s\n",
    1250                         cli->desthost, netbios_domain_name, nt_errstr(status)));
    1251                 return status;
    1252         }
    1253 
     1593                        smbXcli_conn_remote_name(cli->conn),
     1594                        netbios_domain_name, nt_errstr(status)));
     1595                cli_shutdown(cli);
     1596                TALLOC_FREE(frame);
     1597                return status;
     1598        }
     1599
     1600        cli_shutdown(cli);
     1601        TALLOC_FREE(frame);
    12541602        return NT_STATUS_OK;
    12551603}
     
    12631611        NTSTATUS status;
    12641612
    1265         status = libnet_join_ok(r->out.netbios_domain_name,
    1266                                 r->in.machine_name,
    1267                                 r->in.dc_name);
     1613        status = libnet_join_ok(r->in.msg_ctx,
     1614                                r->out.netbios_domain_name,
     1615                                r->in.dc_name,
     1616                                r->in.use_kerberos);
    12681617        if (!NT_STATUS_IS_OK(status)) {
    12691618                libnet_join_set_error_string(mem_ctx, r,
     
    13171666        status = libnet_join_connect_dc_ipc(r->in.dc_name,
    13181667                                            r->in.admin_account,
     1668                                            r->in.admin_domain,
    13191669                                            r->in.admin_password,
    13201670                                            r->in.use_kerberos,
     
    13261676        /* Open the domain */
    13271677
    1328         status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr.syntax_id,
     1678        status = cli_rpc_pipe_open_noauth(cli, &ndr_table_samr,
    13291679                                          &pipe_hnd);
    13301680        if (!NT_STATUS_IS_OK(status)) {
     
    13661716
    13671717        acct_name = talloc_asprintf(mem_ctx, "%s$", r->in.machine_name);
    1368         strlower_m(acct_name);
     1718        if (!strlower_m(acct_name)) {
     1719                status = NT_STATUS_INVALID_PARAMETER;
     1720                goto done;
     1721        }
    13691722
    13701723        init_lsa_String(&lsa_acct_name, acct_name);
     
    15991952        }
    16001953
    1601         lp_load(get_dyn_CONFIGFILE(),true,false,false,true);
     1954        lp_load_global(get_dyn_CONFIGFILE());
    16021955
    16031956        r->out.modified_config = true;
     
    16271980        }
    16281981
    1629         lp_load(get_dyn_CONFIGFILE(),true,false,false,true);
     1982        lp_load_global(get_dyn_CONFIGFILE());
    16301983
    16311984        r->out.modified_config = true;
     
    16892042        }
    16902043
     2044        if (strlen(r->in.machine_name) > 15) {
     2045                libnet_join_set_error_string(mem_ctx, r,
     2046                        "Our netbios name can be at most 15 chars long, "
     2047                         "\"%s\" is %u chars long\n",
     2048                         r->in.machine_name,
     2049                         (unsigned int)strlen(r->in.machine_name));
     2050                return WERR_INVALID_PARAM;
     2051        }
     2052
    16912053        if (!libnet_parse_domain_dc(mem_ctx, r->in.domain_name,
    16922054                                    &r->in.domain_name,
     
    16972059        }
    16982060
    1699         if (IS_DC) {
    1700                 return WERR_SETUP_DOMAIN_CONTROLLER;
     2061        if (!r->in.admin_domain) {
     2062                char *admin_domain = NULL;
     2063                char *admin_account = NULL;
     2064                split_domain_user(mem_ctx,
     2065                                  r->in.admin_account,
     2066                                  &admin_domain,
     2067                                  &admin_account);
     2068                r->in.admin_domain = admin_domain;
     2069                r->in.admin_account = admin_account;
    17012070        }
    17022071
     
    17222091                DEBUG(10,("Unable to auto-add domain administrators to "
    17232092                          "BUILTIN\\Administrators during join because "
    1724                           "winbindd must be running."));
     2093                          "winbindd must be running.\n"));
    17252094        } else if (!NT_STATUS_IS_OK(status)) {
    17262095                DEBUG(5, ("Failed to auto-add domain administrators to "
     
    17332102        if (NT_STATUS_EQUAL(status, NT_STATUS_PROTOCOL_UNREACHABLE)) {
    17342103                DEBUG(10,("Unable to auto-add domain users to BUILTIN\\users "
    1735                           "during join because winbindd must be running."));
     2104                          "during join because winbindd must be running.\n"));
    17362105        } else if (!NT_STATUS_IS_OK(status)) {
    17372106                DEBUG(5, ("Failed to auto-add domain administrators to "
     
    18232192        talloc_set_destructor(ctx, libnet_destroy_JoinCtx);
    18242193
    1825         ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname());
     2194        ctx->in.machine_name = talloc_strdup(mem_ctx, lp_netbios_name());
    18262195        W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name);
    18272196
    18282197        ctx->in.secure_channel_type = SEC_CHAN_WKSTA;
     2198
     2199        ctx->in.desired_encryption_types = ENC_CRC32 |
     2200                                           ENC_RSA_MD5 |
     2201                                           ENC_RC4_HMAC_MD5;
     2202#ifdef HAVE_ENCTYPE_AES128_CTS_HMAC_SHA1_96
     2203        ctx->in.desired_encryption_types |= ENC_HMAC_SHA1_96_AES128;
     2204#endif
     2205#ifdef HAVE_ENCTYPE_AES256_CTS_HMAC_SHA1_96
     2206        ctx->in.desired_encryption_types |= ENC_HMAC_SHA1_96_AES256;
     2207#endif
    18292208
    18302209        *r = ctx;
     
    18482227        talloc_set_destructor(ctx, libnet_destroy_UnjoinCtx);
    18492228
    1850         ctx->in.machine_name = talloc_strdup(mem_ctx, global_myname());
     2229        ctx->in.machine_name = talloc_strdup(mem_ctx, lp_netbios_name());
    18512230        W_ERROR_HAVE_NO_MEMORY(ctx->in.machine_name);
    18522231
     
    18722251        switch (r->out.domain_is_ad) {
    18732252                case false:
    1874                         valid_security = (lp_security() == SEC_DOMAIN);
     2253                        valid_security = (lp_security() == SEC_DOMAIN)
     2254                                || (lp_server_role() == ROLE_DOMAIN_PDC)
     2255                                || (lp_server_role() == ROLE_DOMAIN_BDC);
    18752256                        if (valid_workgroup && valid_security) {
    18762257                                /* nothing to be done */
     
    19162297                        const char *sec = NULL;
    19172298                        switch (lp_security()) {
    1918                         case SEC_SHARE: sec = "share"; break;
    19192299                        case SEC_USER:  sec = "user"; break;
    19202300                        case SEC_DOMAIN: sec = "domain"; break;
     
    19582338        ADS_STATUS ads_status;
    19592339#endif /* HAVE_ADS */
     2340        const char *pre_connect_realm = NULL;
     2341        const char *numeric_dcip = NULL;
     2342        const char *sitename = NULL;
     2343
     2344        /* Before contacting a DC, we can securely know
     2345         * the realm only if the user specifies it.
     2346         */
     2347        if (r->in.use_kerberos &&
     2348            r->in.domain_name_type == JoinDomNameTypeDNS) {
     2349                pre_connect_realm = r->in.domain_name;
     2350        }
    19602351
    19612352        if (!r->in.dc_name) {
    19622353                struct netr_DsRGetDCNameInfo *info;
    19632354                const char *dc;
     2355                uint32_t name_type_flags = 0;
     2356                if (r->in.domain_name_type == JoinDomNameTypeDNS) {
     2357                        name_type_flags = DS_IS_DNS_NAME;
     2358                } else if (r->in.domain_name_type == JoinDomNameTypeNBT) {
     2359                        name_type_flags = DS_IS_FLAT_NAME;
     2360                }
    19642361                status = dsgetdcname(mem_ctx,
    19652362                                     r->in.msg_ctx,
     
    19702367                                     DS_DIRECTORY_SERVICE_REQUIRED |
    19712368                                     DS_WRITABLE_REQUIRED |
    1972                                      DS_RETURN_DNS_NAME,
     2369                                     DS_RETURN_DNS_NAME |
     2370                                     name_type_flags,
    19732371                                     &info);
    19742372                if (!NT_STATUS_IS_OK(status)) {
     
    19832381                r->in.dc_name = talloc_strdup(mem_ctx, dc);
    19842382                W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
     2383
     2384                if (info->dc_address == NULL || info->dc_address[0] != '\\' ||
     2385                    info->dc_address[1] != '\\') {
     2386                        DBG_ERR("ill-formed DC address '%s'\n",
     2387                                info->dc_address);
     2388                        return WERR_DCNOTFOUND;
     2389                }
     2390
     2391                numeric_dcip = info->dc_address + 2;
     2392                sitename = info->dc_site_name;
     2393                /* info goes out of scope but the memory stays
     2394                   allocated on the talloc context */
     2395        }
     2396
     2397        if (pre_connect_realm != NULL) {
     2398                struct sockaddr_storage ss = {0};
     2399
     2400                if (numeric_dcip != NULL) {
     2401                        if (!interpret_string_addr(&ss, numeric_dcip,
     2402                                                   AI_NUMERICHOST)) {
     2403                                DBG_ERR(
     2404                                    "cannot parse IP address '%s' of DC '%s'\n",
     2405                                    numeric_dcip, r->in.dc_name);
     2406                                return WERR_DCNOTFOUND;
     2407                        }
     2408                } else {
     2409                        if (!interpret_string_addr(&ss, r->in.dc_name, 0)) {
     2410                                DBG_WARNING(
     2411                                    "cannot resolve IP address of DC '%s'\n",
     2412                                    r->in.dc_name);
     2413                                return WERR_DCNOTFOUND;
     2414                        }
     2415                }
     2416
     2417                /* The domain parameter is only used as modifier
     2418                 * to krb5.conf file name. .JOIN is is not a valid
     2419                 * NetBIOS name so it cannot clash with another domain
     2420                 * -- Uri.
     2421                 */
     2422                create_local_private_krb5_conf_for_domain(
     2423                    pre_connect_realm, ".JOIN", sitename, &ss);
    19852424        }
    19862425
     
    20022441        create_local_private_krb5_conf_for_domain(
    20032442                r->out.dns_domain_name, r->out.netbios_domain_name,
    2004                 NULL, &cli->dest_ss, cli->desthost);
    2005 
    2006         if (r->out.domain_is_ad && r->in.account_ou &&
     2443                NULL, smbXcli_conn_remote_sockaddr(cli->conn));
     2444
     2445        if (r->out.domain_is_ad &&
    20072446            !(r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE)) {
    20082447
    2009                 ads_status = libnet_join_connect_ads(mem_ctx, r);
     2448                const char *initial_account_ou = r->in.account_ou;
     2449
     2450                /*
     2451                 * we want to create the msDS-SupportedEncryptionTypes attribute
     2452                 * as early as possible so always try an LDAP create as the user
     2453                 * first. We copy r->in.account_ou because it may be changed
     2454                 * during the machine pre-creation.
     2455                 */
     2456
     2457                ads_status = libnet_join_connect_ads_user(mem_ctx, r);
    20102458                if (!ADS_ERR_OK(ads_status)) {
    20112459                        return WERR_DEFAULT_JOIN_REQUIRED;
     
    20132461
    20142462                ads_status = libnet_join_precreate_machine_acct(mem_ctx, r);
    2015                 if (!ADS_ERR_OK(ads_status)) {
     2463                if (ADS_ERR_OK(ads_status)) {
     2464
     2465                        /*
     2466                         * LDAP object create succeeded, now go to the rpc
     2467                         * password set routines
     2468                         */
     2469
     2470                        r->in.join_flags &= ~WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE;
     2471                        goto rpc_join;
     2472                }
     2473
     2474                if (initial_account_ou != NULL) {
    20162475                        libnet_join_set_error_string(mem_ctx, r,
    20172476                                "failed to precreate account in ou %s: %s",
     
    20212480                }
    20222481
    2023                 r->in.join_flags &= ~WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE;
     2482                DEBUG(5, ("failed to precreate account in ou %s: %s",
     2483                        r->in.account_ou, ads_errstr(ads_status)));
    20242484        }
    20252485#endif /* HAVE_ADS */
    20262486
     2487 rpc_join:
    20272488        if ((r->in.join_flags & WKSSVC_JOIN_FLAGS_JOIN_UNSECURE) &&
    20282489            (r->in.join_flags & WKSSVC_JOIN_FLAGS_MACHINE_PWD_PASSED)) {
     
    20772538        u->in.admin_password    = r->in.admin_password;
    20782539        u->in.modify_config     = r->in.modify_config;
     2540        u->in.use_kerberos      = r->in.use_kerberos;
    20792541        u->in.unjoin_flags      = WKSSVC_JOIN_FLAGS_JOIN_TYPE |
    20802542                                  WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE;
     
    22612723        }
    22622724
     2725        if (!r->in.admin_domain) {
     2726                char *admin_domain = NULL;
     2727                char *admin_account = NULL;
     2728                split_domain_user(mem_ctx,
     2729                                  r->in.admin_account,
     2730                                  &admin_domain,
     2731                                  &admin_account);
     2732                r->in.admin_domain = admin_domain;
     2733                r->in.admin_account = admin_account;
     2734        }
     2735
    22632736        if (!secrets_init()) {
    22642737                libnet_unjoin_set_error_string(mem_ctx, r,
  • vendor/current/source3/libnet/libnet_join.h

    r740 r988  
    2424/* The following definitions come from libnet/libnet_join.c  */
    2525
    26 NTSTATUS libnet_join_ok(const char *netbios_domain_name,
    27                         const char *machine_name,
    28                         const char *dc_name);
     26struct messaging_context;
     27NTSTATUS libnet_join_ok(struct messaging_context *msg_ctx,
     28                        const char *netbios_domain_name,
     29                        const char *dc_name,
     30                        const bool use_kerberos);
    2931WERROR libnet_init_JoinCtx(TALLOC_CTX *mem_ctx,
    3032                           struct libnet_JoinCtx **r);
  • vendor/current/source3/libnet/libnet_keytab.c

    r740 r988  
    6767        struct libnet_keytab_context *r;
    6868
    69         r = TALLOC_ZERO_P(mem_ctx, struct libnet_keytab_context);
     69        r = talloc_zero(mem_ctx, struct libnet_keytab_context);
    7070        if (!r) {
    7171                return ENOMEM;
  • vendor/current/source3/libnet/libnet_keytab.h

    r740 r988  
    2828};
    2929
     30struct ads_struct;
     31
    3032struct libnet_keytab_context {
    3133        krb5_context context;
    3234        krb5_keytab keytab;
    3335        const char *keytab_name;
    34         ADS_STRUCT *ads;
     36        struct ads_struct *ads;
    3537        const char *dns_domain_name;
    3638        uint8_t zero_buf[16];
  • vendor/current/source3/libnet/libnet_samsync.c

    r740 r988  
    3131#include "../libcli/security/security.h"
    3232#include "messages.h"
     33#include "../libcli/auth/netlogon_creds_cli.h"
    3334
    3435/**
     
    7172        *ctx_p = NULL;
    7273
    73         ctx = TALLOC_ZERO_P(mem_ctx, struct samsync_context);
     74        ctx = talloc_zero(mem_ctx, struct samsync_context);
    7475        NT_STATUS_HAVE_NO_MEMORY(ctx);
    7576
     
    8283        }
    8384
    84         ctx->msg_ctx = messaging_init(ctx, procid_self(),
    85                                       event_context_init(ctx));
     85        ctx->msg_ctx = messaging_init(ctx, samba_tevent_context_init(ctx));
    8686        NT_STATUS_HAVE_NO_MEMORY(ctx->msg_ctx);
    8787
     
    204204        NTSTATUS callback_status;
    205205        const char *logon_server = ctx->cli->desthost;
    206         const char *computername = global_myname();
     206        const char *computername = lp_netbios_name();
    207207        struct netr_Authenticator credential;
    208208        struct netr_Authenticator return_authenticator;
     
    215215        do {
    216216                struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL;
    217 
    218                 netlogon_creds_client_authenticator(ctx->cli->dc, &credential);
     217                struct netlogon_creds_CredentialState *creds = NULL;
     218
     219                status = netlogon_creds_cli_lock(ctx->netlogon_creds,
     220                                                 mem_ctx, &creds);
     221                if (!NT_STATUS_IS_OK(status)) {
     222                        return status;
     223                }
     224
     225                netlogon_creds_client_authenticator(creds, &credential);
    219226
    220227                if (ctx->single_object_replication &&
     
    256263
    257264                if (!NT_STATUS_IS_OK(status)) {
     265                        TALLOC_FREE(creds);
    258266                        return status;
    259267                }
    260268
    261269                /* Check returned credentials. */
    262                 if (!netlogon_creds_client_check(ctx->cli->dc,
     270                if (!netlogon_creds_client_check(creds,
    263271                                                 &return_authenticator.cred)) {
     272                        TALLOC_FREE(creds);
    264273                        DEBUG(0,("credentials chain check failed\n"));
    265274                        return NT_STATUS_ACCESS_DENIED;
     
    267276
    268277                if (NT_STATUS_EQUAL(result, NT_STATUS_NOT_SUPPORTED)) {
     278                        TALLOC_FREE(creds);
    269279                        return result;
    270280                }
    271281
    272282                if (NT_STATUS_IS_ERR(result)) {
     283                        TALLOC_FREE(creds);
    273284                        break;
    274285                }
    275286
    276287                samsync_fix_delta_array(mem_ctx,
    277                                         ctx->cli->dc,
     288                                        creds,
    278289                                        database_id,
    279290                                        delta_enum_array);
     291                TALLOC_FREE(creds);
    280292
    281293                /* Process results */
     
    405417        *str_p = NULL;
    406418
    407         str = TALLOC_ZERO_P(mem_ctx, struct netr_AcctLockStr);
     419        str = talloc_zero(mem_ctx, struct netr_AcctLockStr);
    408420        if (!str) {
    409421                return NT_STATUS_NO_MEMORY;
  • vendor/current/source3/libnet/libnet_samsync.h

    r740 r988  
    7676
    7777        struct rpc_pipe_client *cli;
     78        struct netlogon_creds_cli_context *netlogon_creds;
    7879        struct messaging_context *msg_ctx;
    7980
  • vendor/current/source3/libnet/libnet_samsync_display.c

    r740 r988  
    9999        }
    100100
    101         u_logout = uint64s_nt_time_to_unix_abs((const uint64 *)&r->force_logoff_time);
     101        u_logout = uint64s_nt_time_to_unix_abs((const uint64_t *)&r->force_logoff_time);
    102102
    103103        d_printf("Domain name: %s\n", r->domain_name.string);
  • vendor/current/source3/libnet/libnet_samsync_ldif.c

    r740 r988  
    2525
    2626#include "includes.h"
     27#include "system/filesys.h"
    2728#include "libnet/libnet_samsync.h"
    28 #include "smbldap.h"
    2929#include "transfer_file.h"
    3030#include "passdb.h"
     31#include "passdb/pdb_ldap_schema.h"
    3132
    3233#ifdef HAVE_LDAP
    3334
    3435/* uid's and gid's for writing deltas to ldif */
    35 static uint32 ldif_gid = 999;
    36 static uint32 ldif_uid = 999;
     36static uint32_t ldif_gid = 999;
     37static uint32_t ldif_uid = 999;
    3738
    3839/* global counters */
     
    6970};
    7071
     72/*
     73   Returns the substring from src between the first occurrence of
     74   the char "front" and the first occurence of the char "back".
     75   Mallocs the return string which must be freed.  Not for use
     76   with wide character strings.
     77*/
     78static char *sstring_sub(const char *src, char front, char back)
     79{
     80        char *temp1, *temp2, *temp3;
     81        ptrdiff_t len;
     82
     83        temp1 = strchr(src, front);
     84        if (temp1 == NULL) return NULL;
     85        temp2 = strchr(src, back);
     86        if (temp2 == NULL) return NULL;
     87        len = temp2 - temp1;
     88        if (len <= 0) return NULL;
     89        temp3 = (char*)SMB_MALLOC(len);
     90        if (temp3 == NULL) {
     91                DEBUG(1,("Malloc failure in sstring_sub\n"));
     92                return NULL;
     93        }
     94        memcpy(temp3, temp1+1, len-1);
     95        temp3[len-1] = '\0';
     96        return temp3;
     97}
     98
    7199/****************************************************************
    72100****************************************************************/
     
    104132        fflush(add_fd);
    105133
    106         user_suffix = lp_ldap_user_suffix();
     134        user_suffix = lp_ldap_user_suffix(talloc_tos());
    107135        if (user_suffix == NULL) {
    108136                SAFE_FREE(suffix_attr);
     
    112140           Write the Users entity */
    113141        if (*user_suffix && strcmp(user_suffix, suffix)) {
    114                 user_attr = sstring_sub(lp_ldap_user_suffix(), '=', ',');
     142                user_attr = sstring_sub(lp_ldap_user_suffix(talloc_tos()), '=', ',');
    115143                fprintf(add_fd, "# %s\n", user_suffix);
    116144                fprintf(add_fd, "dn: %s\n", user_suffix);
     
    122150
    123151
    124         group_suffix = lp_ldap_group_suffix();
     152        group_suffix = lp_ldap_group_suffix(talloc_tos());
    125153        if (group_suffix == NULL) {
    126154                SAFE_FREE(suffix_attr);
     
    131159           Write the Groups entity */
    132160        if (*group_suffix && strcmp(group_suffix, suffix)) {
    133                 group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ',');
     161                group_attr = sstring_sub(lp_ldap_group_suffix(talloc_tos()), '=', ',');
    134162                fprintf(add_fd, "# %s\n", group_suffix);
    135163                fprintf(add_fd, "dn: %s\n", group_suffix);
     
    142170        /* If it exists and is distinct from other containers,
    143171           Write the Computers entity */
    144         machine_suffix = lp_ldap_machine_suffix();
     172        machine_suffix = lp_ldap_machine_suffix(talloc_tos());
    145173        if (machine_suffix == NULL) {
    146174                SAFE_FREE(suffix_attr);
     
    157185                /* this isn't totally correct as it assumes that
    158186                   there _must_ be an ou. just fixing memleak now. jmcd */
    159                 machine_ou = sstring_sub(lp_ldap_machine_suffix(), '=', ',');
     187                machine_ou = sstring_sub(lp_ldap_machine_suffix(talloc_tos()), '=', ',');
    160188                fprintf(add_fd, "ou: %s\n", machine_ou);
    161189                SAFE_FREE(machine_ou);
     
    166194        /* If it exists and is distinct from other containers,
    167195           Write the IdMap entity */
    168         idmap_suffix = lp_ldap_idmap_suffix();
     196        idmap_suffix = lp_ldap_idmap_suffix(talloc_tos());
    169197        if (idmap_suffix == NULL) {
    170198                SAFE_FREE(suffix_attr);
     
    180208                fprintf(add_fd, "dn: %s\n", idmap_suffix);
    181209                fprintf(add_fd, "ObjectClass: organizationalUnit\n");
    182                 s = sstring_sub(lp_ldap_idmap_suffix(), '=', ',');
     210                s = sstring_sub(lp_ldap_idmap_suffix(talloc_tos()), '=', ',');
    183211                fprintf(add_fd, "ou: %s\n", s);
    184212                SAFE_FREE(s);
     
    344372                                    const char *builtin_sid)
    345373{
    346         char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ',');
     374        char *group_attr = sstring_sub(lp_ldap_group_suffix(talloc_tos()), '=', ',');
    347375
    348376        /* Map the groups created by populate_ldap_for_ldif */
     
    549577{
    550578        const char *groupname = r->group_name.string;
    551         uint32 grouptype = 0, g_rid = 0;
    552         char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ',');
     579        uint32_t grouptype = 0, g_rid = 0;
     580        char *group_attr = sstring_sub(lp_ldap_group_suffix(talloc_tos()), '=', ',');
    553581
    554582        /* Set up the group type (always 2 for group info) */
     
    622650        const char* nopasswd = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
    623651        uchar zero_buf[16];
    624         uint32 rid = 0, group_rid = 0, gidNumber = 0;
     652        uint32_t rid = 0, group_rid = 0, gidNumber = 0;
    625653        time_t unix_time;
    626654        int i, ret;
     
    647675                        snprintf(homedir, sizeof(homedir), "/nobodyshomedir");
    648676                }
    649                 ou = lp_ldap_user_suffix();
     677                ou = lp_ldap_user_suffix(talloc_tos());
    650678        } else {
    651                 ou = lp_ldap_machine_suffix();
     679                ou = lp_ldap_machine_suffix(talloc_tos());
    652680                snprintf(homedir, sizeof(homedir), "/machinehomedir");
    653681        }
     
    768796{
    769797        fstring aliasname, description;
    770         uint32 grouptype = 0, g_rid = 0;
    771         char *group_attr = sstring_sub(lp_ldap_group_suffix(), '=', ',');
     798        uint32_t grouptype = 0, g_rid = 0;
     799        char *group_attr = sstring_sub(lp_ldap_group_suffix(talloc_tos()), '=', ',');
    772800
    773801        /* Get the alias name */
     
    851879{
    852880        fstring group_dn;
    853         uint32 group_rid = 0, rid = 0;
     881        uint32_t group_rid = 0, rid = 0;
    854882        int i, j, k;
    855883
     
    903931        const char *mod_template = "/tmp/mod.ldif.XXXXXX";
    904932        const char *builtin_sid = "S-1-5-32";
     933        mode_t mask;
     934        int fd;
     935
     936        r = talloc_zero(mem_ctx, struct samsync_ldif_context);
     937        NT_STATUS_HAVE_NO_MEMORY(r);
     938
     939        /* Get the ldap suffix */
     940        r->suffix = lp_ldap_suffix(talloc_tos());
    905941
    906942        /* Get other smb.conf data */
     
    911947
    912948        /* Get the ldap suffix */
    913         if (!(lp_ldap_suffix()) || !*(lp_ldap_suffix())) {
     949        if (!r->suffix || !*r->suffix) {
    914950                DEBUG(0,("ldap suffix missing from smb.conf--exiting\n"));
    915951                exit(1);
     
    919955                return NT_STATUS_OK;
    920956        }
    921 
    922         r = TALLOC_ZERO_P(mem_ctx, struct samsync_ldif_context);
    923         NT_STATUS_HAVE_NO_MEMORY(r);
    924 
    925         /* Get the ldap suffix */
    926         r->suffix = lp_ldap_suffix();
    927957
    928958        /* Ensure we have an output file */
     
    954984        }
    955985
    956         /* Open the add and mod ldif files */
    957         if (!(r->add_file = fdopen(mkstemp(r->add_name),"w"))) {
    958                 DEBUG(1, ("Could not open %s\n", r->add_name));
     986        mask = umask(S_IRWXO | S_IRWXG);
     987        fd = mkstemp(r->add_name);
     988        umask(mask);
     989        if (fd < 0) {
     990                DEBUG(1, ("Could not create %s\n", r->add_name));
    959991                status = NT_STATUS_UNSUCCESSFUL;
    960992                goto done;
    961993        }
    962         if (!(r->mod_file = fdopen(mkstemp(r->module_name),"w"))) {
    963                 DEBUG(1, ("Could not open %s\n", r->module_name));
     994
     995        /* Open the add and mod ldif files */
     996        r->add_file = fdopen(fd, "w");
     997        if (r->add_file == NULL) {
     998                DEBUG(1, ("Could not open %s\n", r->add_name));
     999                close(fd);
    9641000                status = NT_STATUS_UNSUCCESSFUL;
    9651001                goto done;
    9661002        }
    9671003
     1004        mask = umask(S_IRWXO | S_IRWXG);
     1005        fd = mkstemp(r->module_name);
     1006        umask(mask);
     1007        if (fd < 0) {
     1008                DEBUG(1, ("Could not create %s\n", r->module_name));
     1009                status = NT_STATUS_UNSUCCESSFUL;
     1010                goto done;
     1011        }
     1012
     1013        r->mod_file = fdopen(fd, "w");
     1014        if (r->mod_file == NULL) {
     1015                DEBUG(1, ("Could not open %s\n", r->module_name));
     1016                close(fd);
     1017                status = NT_STATUS_UNSUCCESSFUL;
     1018                goto done;
     1019        }
     1020
    9681021        /* Allocate initial memory for groupmap and accountmap arrays */
    969         r->groupmap = TALLOC_ZERO_ARRAY(mem_ctx, GROUPMAP, 8);
    970         r->accountmap = TALLOC_ZERO_ARRAY(mem_ctx, ACCOUNTMAP, 8);
     1022        r->groupmap = talloc_zero_array(mem_ctx, GROUPMAP, 8);
     1023        r->accountmap = talloc_zero_array(mem_ctx, ACCOUNTMAP, 8);
    9711024        if (r->groupmap == NULL || r->accountmap == NULL) {
    9721025                DEBUG(1,("GROUPMAP talloc failed\n"));
     
    11741227{
    11751228        /* Re-allocate memory for groupmap and accountmap arrays */
    1176         l->groupmap = TALLOC_REALLOC_ARRAY(mem_ctx,
     1229        l->groupmap = talloc_realloc(mem_ctx,
    11771230                                           l->groupmap,
    11781231                                           GROUPMAP,
    11791232                                           num_entries + l->num_alloced);
    11801233
    1181         l->accountmap = TALLOC_REALLOC_ARRAY(mem_ctx,
     1234        l->accountmap = talloc_realloc(mem_ctx,
    11821235                                             l->accountmap,
    11831236                                             ACCOUNTMAP,
  • vendor/current/source3/libnet/libnet_samsync_passdb.c

    r740 r988  
    251251        /* Create appropriate user */
    252252        if (acct_flags & ACB_NORMAL) {
    253                 add_script = talloc_strdup(mem_ctx, lp_adduser_script());
     253                add_script = lp_add_user_script(mem_ctx);
    254254        } else if ( (acct_flags & ACB_WSTRUST) ||
    255255                    (acct_flags & ACB_SVRTRUST) ||
    256256                    (acct_flags & ACB_DOMTRUST) ) {
    257                 add_script = talloc_strdup(mem_ctx, lp_addmachine_script());
     257                add_script = lp_add_machine_script(mem_ctx);
    258258        } else {
    259259                DEBUG(1, ("Unknown user type: %s\n",
     
    302302        fstring account;
    303303        struct samu *sam_account=NULL;
    304         GROUP_MAP map;
     304        GROUP_MAP *map = NULL;
    305305        struct group *grp;
    306306        struct dom_sid user_sid;
     
    356356        group_sid = *pdb_get_group_sid(sam_account);
    357357
    358         if (!pdb_getgrsid(&map, group_sid)) {
     358        map = talloc_zero(mem_ctx, GROUP_MAP);
     359        if (!map) {
     360                return NT_STATUS_NO_MEMORY;
     361        }
     362
     363        if (!pdb_getgrsid(map, group_sid)) {
    359364                DEBUG(0, ("Primary group of %s has no mapping!\n",
    360365                          pdb_get_username(sam_account)));
    361366        } else {
    362                 if (map.gid != passwd->pw_gid) {
    363                         if (!(grp = getgrgid(map.gid))) {
     367                if (map->gid != passwd->pw_gid) {
     368                        if (!(grp = getgrgid(map->gid))) {
    364369                                DEBUG(0, ("Could not find unix group %lu for user %s (group SID=%s)\n",
    365                                           (unsigned long)map.gid, pdb_get_username(sam_account), sid_string_tos(&group_sid)));
     370                                          (unsigned long)map->gid, pdb_get_username(sam_account), sid_string_tos(&group_sid)));
    366371                        } else {
    367372                                smb_set_primary_group(grp->gr_name, pdb_get_username(sam_account));
     
    377382 done:
    378383        TALLOC_FREE(sam_account);
     384        TALLOC_FREE(map);
    379385        return nt_ret;
    380386}
     
    387393                                 struct netr_DELTA_GROUP *r)
    388394{
    389         fstring name;
    390         fstring comment;
    391395        struct group *grp = NULL;
    392396        struct dom_sid group_sid;
    393397        fstring sid_string;
    394         GROUP_MAP map;
     398        GROUP_MAP *map;
    395399        bool insert = true;
    396400
    397         fstrcpy(name, r->group_name.string);
    398         fstrcpy(comment, r->description.string);
    399 
     401        map = talloc_zero(mem_ctx, GROUP_MAP);
     402        if (!map) {
     403                return NT_STATUS_NO_MEMORY;
     404        }
    400405        /* add the group to the mapping table */
    401406        sid_compose(&group_sid, get_global_sam_sid(), rid);
    402407        sid_to_fstring(sid_string, &group_sid);
    403408
    404         if (pdb_getgrsid(&map, group_sid)) {
    405                 if ( map.gid != -1 )
    406                         grp = getgrgid(map.gid);
     409        if (pdb_getgrsid(map, group_sid)) {
     410                if (map->gid != -1) {
     411                        grp = getgrgid(map->gid);
     412                }
    407413                insert = false;
     414        }
     415
     416        map->nt_name = talloc_strdup(map, r->group_name.string);
     417        if (!map->nt_name) {
     418                return NT_STATUS_NO_MEMORY;
     419        }
     420        map->comment = talloc_strdup(map, r->description.string);
     421        if (!map->comment) {
     422                return NT_STATUS_NO_MEMORY;
    408423        }
    409424
     
    412427
    413428                /* No group found from mapping, find it from its name. */
    414                 if ((grp = getgrnam(name)) == NULL) {
     429                if ((grp = getgrnam(map->nt_name)) == NULL) {
    415430
    416431                        /* No appropriate group found, create one */
    417432
    418                         d_printf("Creating unix group: '%s'\n", name);
    419 
    420                         if (smb_create_group(name, &gid) != 0)
     433                        d_printf("Creating unix group: '%s'\n", map->nt_name);
     434
     435                        if (smb_create_group(map->nt_name, &gid) != 0)
    421436                                return NT_STATUS_ACCESS_DENIED;
    422437
    423                         if ((grp = getgrnam(name)) == NULL)
     438                        if ((grp = getgrnam(map->nt_name)) == NULL)
    424439                                return NT_STATUS_ACCESS_DENIED;
    425440                }
    426441        }
    427442
    428         map.gid = grp->gr_gid;
    429         map.sid = group_sid;
    430         map.sid_name_use = SID_NAME_DOM_GRP;
    431         fstrcpy(map.nt_name, name);
    432         if (r->description.string) {
    433                 fstrcpy(map.comment, comment);
     443        map->gid = grp->gr_gid;
     444        map->sid = group_sid;
     445        map->sid_name_use = SID_NAME_DOM_GRP;
     446
     447        if (insert) {
     448                pdb_add_group_mapping_entry(map);
    434449        } else {
    435                 fstrcpy(map.comment, "");
    436         }
    437 
    438         if (insert)
    439                 pdb_add_group_mapping_entry(&map);
    440         else
    441                 pdb_update_group_mapping_entry(&map);
    442 
     450                pdb_update_group_mapping_entry(map);
     451        }
     452
     453        TALLOC_FREE(map);
    443454        return NT_STATUS_OK;
    444455}
     
    455466        char **unix_members;
    456467        struct dom_sid group_sid;
    457         GROUP_MAP map;
     468        GROUP_MAP *map;
    458469        struct group *grp;
    459470
     
    464475        sid_compose(&group_sid, get_global_sam_sid(), rid);
    465476
    466         if (!get_domain_group_from_sid(group_sid, &map)) {
     477        map = talloc_zero(mem_ctx, GROUP_MAP);
     478        if (!map) {
     479                return NT_STATUS_NO_MEMORY;
     480        }
     481
     482        if (!get_domain_group_from_sid(group_sid, map)) {
    467483                DEBUG(0, ("Could not find global group %d\n", rid));
     484                TALLOC_FREE(map);
    468485                return NT_STATUS_NO_SUCH_GROUP;
    469486        }
    470487
    471         if (!(grp = getgrgid(map.gid))) {
    472                 DEBUG(0, ("Could not find unix group %lu\n", (unsigned long)map.gid));
     488        if (!(grp = getgrgid(map->gid))) {
     489                DEBUG(0, ("Could not find unix group %lu\n",
     490                                                (unsigned long)map->gid));
     491                TALLOC_FREE(map);
    473492                return NT_STATUS_NO_SUCH_GROUP;
    474493        }
    475494
     495        TALLOC_FREE(map);
     496
    476497        d_printf("Group members of %s: ", grp->gr_name);
    477498
    478499        if (r->num_rids) {
    479                 if ((nt_members = TALLOC_ZERO_ARRAY(mem_ctx, char *, r->num_rids)) == NULL) {
     500                if ((nt_members = talloc_zero_array(mem_ctx, char *, r->num_rids)) == NULL) {
    480501                        DEBUG(0, ("talloc failed\n"));
    481502                        return NT_STATUS_NO_MEMORY;
     
    576597                                 const struct dom_sid *dom_sid)
    577598{
    578         fstring name;
    579         fstring comment;
    580599        struct group *grp = NULL;
    581600        struct dom_sid alias_sid;
    582601        fstring sid_string;
    583         GROUP_MAP map;
     602        GROUP_MAP *map;
    584603        bool insert = true;
    585604
    586         fstrcpy(name, r->alias_name.string);
    587         fstrcpy(comment, r->description.string);
     605        map = talloc_zero(mem_ctx, GROUP_MAP);
     606        if (!map) {
     607                return NT_STATUS_NO_MEMORY;
     608        }
    588609
    589610        /* Find out whether the group is already mapped */
     
    591612        sid_to_fstring(sid_string, &alias_sid);
    592613
    593         if (pdb_getgrsid(&map, alias_sid)) {
    594                 grp = getgrgid(map.gid);
     614        if (pdb_getgrsid(map, alias_sid)) {
     615                grp = getgrgid(map->gid);
    595616                insert = false;
     617        }
     618
     619        map->nt_name = talloc_strdup(map, r->alias_name.string);
     620        if (!map->nt_name) {
     621                return NT_STATUS_NO_MEMORY;
     622        }
     623        map->comment = talloc_strdup(map, r->description.string);
     624        if (!map->comment) {
     625                return NT_STATUS_NO_MEMORY;
    596626        }
    597627
     
    600630
    601631                /* No group found from mapping, find it from its name. */
    602                 if ((grp = getgrnam(name)) == NULL) {
     632                if ((grp = getgrnam(map->nt_name)) == NULL) {
    603633                        /* No appropriate group found, create one */
    604                         d_printf("Creating unix group: '%s'\n", name);
    605                         if (smb_create_group(name, &gid) != 0)
     634                        d_printf("Creating unix group: '%s'\n", map->nt_name);
     635                        if (smb_create_group(map->nt_name, &gid) != 0)
    606636                                return NT_STATUS_ACCESS_DENIED;
    607637                        if ((grp = getgrgid(gid)) == NULL)
     
    610640        }
    611641
    612         map.gid = grp->gr_gid;
    613         map.sid = alias_sid;
    614 
    615         if (dom_sid_equal(dom_sid, &global_sid_Builtin))
    616                 map.sid_name_use = SID_NAME_WKN_GRP;
    617         else
    618                 map.sid_name_use = SID_NAME_ALIAS;
    619 
    620         fstrcpy(map.nt_name, name);
    621         fstrcpy(map.comment, comment);
    622 
    623         if (insert)
    624                 pdb_add_group_mapping_entry(&map);
    625         else
    626                 pdb_update_group_mapping_entry(&map);
    627 
     642        map->gid = grp->gr_gid;
     643        map->sid = alias_sid;
     644
     645        if (dom_sid_equal(dom_sid, &global_sid_Builtin)) {
     646                map->sid_name_use = SID_NAME_WKN_GRP;
     647        } else {
     648                map->sid_name_use = SID_NAME_ALIAS;
     649        }
     650
     651        if (insert) {
     652                pdb_add_group_mapping_entry(map);
     653        } else {
     654                pdb_update_group_mapping_entry(map);
     655        }
     656
     657        TALLOC_FREE(map);
    628658        return NT_STATUS_OK;
    629659}
     
    660690        }
    661691
    662         u_max_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->max_password_age);
    663         u_min_age = uint64s_nt_time_to_unix_abs((uint64 *)&r->min_password_age);
    664         u_logout = uint64s_nt_time_to_unix_abs((uint64 *)&r->force_logoff_time);
     692        u_max_age = uint64s_nt_time_to_unix_abs((uint64_t *)&r->max_password_age);
     693        u_min_age = uint64s_nt_time_to_unix_abs((uint64_t *)&r->min_password_age);
     694        u_logout = uint64s_nt_time_to_unix_abs((uint64_t *)&r->force_logoff_time);
    665695
    666696        domname = r->domain_name.string;
     
    685715
    686716        if (!pdb_set_account_policy(PDB_POLICY_MAX_PASSWORD_AGE,
    687                                     (uint32)u_max_age))
     717                                    (uint32_t)u_max_age))
    688718                return nt_status;
    689719
    690720        if (!pdb_set_account_policy(PDB_POLICY_MIN_PASSWORD_AGE,
    691                                     (uint32)u_min_age))
     721                                    (uint32_t)u_min_age))
    692722                return nt_status;
    693723
    694724        if (!pdb_set_account_policy(PDB_POLICY_TIME_TO_LOGOUT,
    695                                     (uint32)u_logout))
     725                                    (uint32_t)u_logout))
    696726                return nt_status;
    697727
Note: See TracChangeset for help on using the changeset viewer.