Changeset 596 for trunk/server/source3/utils/net_ads.c
- Timestamp:
- Jul 2, 2011, 3:35:33 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/server/source3/utils/net_ads.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/server/source3/utils/net_ads.c
r590 r596 1198 1198 } 1199 1199 1200 static NTSTATUS net_update_dns(TALLOC_CTX *mem_ctx, ADS_STRUCT *ads) 1201 { 1202 int num_addrs; 1203 struct sockaddr_storage *iplist = NULL; 1200 static 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; 1204 1206 fstring machine_name; 1205 1207 NTSTATUS status; 1206 1208 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 } 1208 1214 strlower_m( machine_name ); 1209 1215 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; 1218 1228 } 1219 1229 1220 1230 status = net_update_dns_internal(mem_ctx, ads, machine_name, 1221 1231 iplist, num_addrs); 1222 SAFE_FREE( iplist ); 1232 1233 SAFE_FREE(iplist_alloc); 1234 return status; 1235 } 1236 1237 static 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); 1223 1242 return status; 1224 1243 } … … 1377 1396 1378 1397 #if defined(WITH_DNS_UPDATES) 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1379 1415 if (r->out.domain_is_ad) { 1380 1416 /* We enter this block with user creds */ … … 1395 1431 } 1396 1432 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)) ) { 1398 1434 d_fprintf( stderr, _("DNS update failed!\n") ); 1399 1435 } … … 1403 1439 } 1404 1440 #endif 1441 1442 1405 1443 TALLOC_FREE(r); 1406 1444 TALLOC_FREE( ctx ); … … 1426 1464 ADS_STRUCT *ads; 1427 1465 ADS_STATUS status; 1466 1428 1467 TALLOC_CTX *ctx; 1468 1469 1470 1471 1472 1429 1473 1430 1474 #ifdef DEVELOPER … … 1432 1476 #endif 1433 1477 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) { 1435 1486 d_printf( "%s\n" 1436 "net ads dns register \n"1487 "net ads dns register\n" 1437 1488 " %s\n", 1438 1489 _("Usage:"), … … 1444 1495 d_fprintf(stderr, _("Could not initialise talloc context\n")); 1445 1496 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 1446 1528 } 1447 1529 … … 1453 1535 } 1454 1536 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)) { 1456 1539 d_fprintf( stderr, _("DNS update failed!\n") ); 1457 1540 ads_destroy( &ads );
Note:
See TracChangeset
for help on using the changeset viewer.
