Ignore:
Timestamp:
Jul 2, 2011, 3:35:33 PM (14 years ago)
Author:
Herwig Bauernfeind
Message:

Samba 3.5: Update trunk to 3.5.8

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/utils/net_ads.c

    r590 r596  
    11981198}
    11991199
    1200 static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads)
    1201 {
    1202         int num_addrs;
    1203         struct sockaddr_storage *iplist = NULL;
     1200static NTSTATUS net_update_dns_ext(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads,
     1201                                   const char *hostname,
     1202                                   struct sockaddr_storage *iplist,
     1203                                   int num_addrs)
     1204{
     1205        struct sockaddr_storage *iplist_alloc = NULL;
    12041206        fstring machine_name;
    12051207        NTSTATUS status;
    12061208
    1207         name_to_fqdn( machine_name, global_myname() );
     1209        if (hostname) {
     1210                fstrcpy(machine_name, hostname);
     1211        } else {
     1212                name_to_fqdn( machine_name, global_myname() );
     1213        }
    12081214        strlower_m( machine_name );
    12091215
    1210         /* Get our ip address (not the 127.0.0.x address but a real ip
    1211          * address) */
    1212 
    1213         num_addrs = get_my_ip_address( &iplist );
    1214         if ( num_addrs <= 0 ) {
    1215                 DEBUG(4,("net_update_dns: Failed to find my non-loopback IP "
    1216                          "addresses!\n"));
    1217                 return NT_STATUS_INVALID_PARAMETER;
     1216        if (num_addrs == 0 || iplist == NULL) {
     1217                /*
     1218                 * Get our ip address
     1219                 * (not the 127.0.0.x address but a real ip address)
     1220                 */
     1221                num_addrs = get_my_ip_address(&iplist_alloc);
     1222                if ( num_addrs <= 0 ) {
     1223                        DEBUG(4, ("net_update_dns_ext: Failed to find my "
     1224                                  "non-loopback IP addresses!\n"));
     1225                        return NT_STATUS_INVALID_PARAMETER;
     1226                }
     1227                iplist = iplist_alloc;
    12181228        }
    12191229
    12201230        status = net_update_dns_internal(mem_ctx, ads, machine_name,
    12211231                                         iplist, num_addrs);
    1222         SAFE_FREE( iplist );
     1232
     1233        SAFE_FREE(iplist_alloc);
     1234        return status;
     1235}
     1236
     1237static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads, const char *hostname)
     1238{
     1239        NTSTATUS status;
     1240
     1241        status = net_update_dns_ext(mem_ctx, ads, hostname, NULL, 0);
    12231242        return status;
    12241243}
     
    13771396
    13781397#if defined(WITH_DNS_UPDATES)
     1398
     1399
     1400
     1401
     1402
     1403
     1404
     1405
     1406
     1407
     1408
     1409
     1410
     1411
     1412
     1413
     1414
    13791415        if (r->out.domain_is_ad) {
    13801416                /* We enter this block with user creds */
     
    13951431                }
    13961432
    1397                 if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns )) ) {
     1433                if ( !ads_dns || !NT_STATUS_IS_OK(net_update_dns( ctx, ads_dns)) ) {
    13981434                        d_fprintf( stderr, _("DNS update failed!\n") );
    13991435                }
     
    14031439        }
    14041440#endif
     1441
     1442
    14051443        TALLOC_FREE(r);
    14061444        TALLOC_FREE( ctx );
     
    14261464        ADS_STRUCT *ads;
    14271465        ADS_STATUS status;
     1466
    14281467        TALLOC_CTX *ctx;
     1468
     1469
     1470
     1471
     1472
    14291473
    14301474#ifdef DEVELOPER
     
    14321476#endif
    14331477
    1434         if (argc > 0 || c->display_usage) {
     1478        if (argc <= 1 && lp_clustering() && lp_cluster_addresses() == NULL) {
     1479                d_fprintf(stderr, _("Refusing DNS updates with automatic "
     1480                                    "detection of addresses in a clustered "
     1481                                    "setup.\n"));
     1482                c->display_usage = true;
     1483        }
     1484
     1485        if (c->display_usage) {
    14351486                d_printf(  "%s\n"
    1436                            "net ads dns register\n"
     1487                           "net ads dns register\n"
    14371488                           "    %s\n",
    14381489                         _("Usage:"),
     
    14441495                d_fprintf(stderr, _("Could not initialise talloc context\n"));
    14451496                return -1;
     1497
     1498
     1499
     1500
     1501
     1502
     1503
     1504
     1505
     1506
     1507
     1508
     1509
     1510
     1511
     1512
     1513
     1514
     1515
     1516
     1517
     1518
     1519
     1520
     1521
     1522
     1523
     1524
     1525
     1526
     1527
    14461528        }
    14471529
     
    14531535        }
    14541536
    1455         if ( !NT_STATUS_IS_OK(net_update_dns(ctx, ads)) ) {
     1537        ntstatus = net_update_dns_ext(ctx, ads, hostname, addrs, num_addrs);
     1538        if (!NT_STATUS_IS_OK(ntstatus)) {
    14561539                d_fprintf( stderr, _("DNS update failed!\n") );
    14571540                ads_destroy( &ads );
Note: See TracChangeset for help on using the changeset viewer.