Changeset 224 for branches/samba-3.3.x/source/utils
- Timestamp:
- May 24, 2009, 7:55:48 AM (16 years ago)
- Location:
- branches/samba-3.3.x/source/utils
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/utils/net.c
r206 r224 636 636 {"stdin", 'i', POPT_ARG_NONE, &c->opt_stdin}, 637 637 {"timeout", 't', POPT_ARG_INT, &c->opt_timeout}, 638 {"request-timeout",0,POPT_ARG_INT, &c->opt_request_timeout}, 638 639 {"machine-pass",'P', POPT_ARG_NONE, &c->opt_machine_pass}, 639 640 {"kerberos", 'k', POPT_ARG_NONE, &c->opt_kerberos}, -
branches/samba-3.3.x/source/utils/net.h
r206 r224 44 44 int opt_flags; 45 45 int opt_timeout; 46 int opt_request_timeout; 46 47 const char *opt_target_workgroup; 47 48 int opt_machine_pass; -
branches/samba-3.3.x/source/utils/net_conf.c
r223 r224 301 301 goto done; 302 302 case 2: 303 servicename = talloc_strdup _lower(mem_ctx, argv[1]);303 servicename = talloc_strdup(mem_ctx, argv[1]); 304 304 if (servicename == NULL) { 305 305 d_printf("error: out of memory!\n"); … … 341 341 goto cancel; 342 342 } 343 344 werr = smbconf_transaction_start(conf_ctx); 345 if (!W_ERROR_IS_OK(werr)) { 346 d_printf("error starting transaction: %s\n", 347 dos_errstr(werr)); 348 goto done; 349 } 350 343 351 werr = import_process_service(c, conf_ctx, service); 344 352 if (!W_ERROR_IS_OK(werr)) { … … 502 510 } 503 511 504 sharename = talloc_strdup _lower(mem_ctx, argv[0]);512 sharename = talloc_strdup(mem_ctx, argv[0]); 505 513 if (sharename == NULL) { 506 514 d_printf("error: out of memory!\n"); … … 515 523 } 516 524 517 d_printf("[%s]\n", s harename);525 d_printf("[%s]\n", service->name); 518 526 519 527 for (count = 0; count < service->num_params; count++) { … … 601 609 case 2: 602 610 path = argv[1]; 603 sharename = talloc_strdup _lower(mem_ctx, argv[0]);611 sharename = talloc_strdup(mem_ctx, argv[0]); 604 612 if (sharename == NULL) { 605 613 d_printf("error: out of memory!\n"); … … 729 737 goto done; 730 738 } 731 sharename = talloc_strdup _lower(mem_ctx, argv[0]);739 sharename = talloc_strdup(mem_ctx, argv[0]); 732 740 if (sharename == NULL) { 733 741 d_printf("error: out of memory!\n"); … … 762 770 goto done; 763 771 } 764 service = talloc_strdup _lower(mem_ctx, argv[0]);772 service = talloc_strdup(mem_ctx, argv[0]); 765 773 if (service == NULL) { 766 774 d_printf("error: out of memory!\n"); … … 814 822 goto done; 815 823 } 816 service = talloc_strdup _lower(mem_ctx, argv[0]);824 service = talloc_strdup(mem_ctx, argv[0]); 817 825 if (service == NULL) { 818 826 d_printf("error: out of memory!\n"); … … 864 872 goto done; 865 873 } 866 service = talloc_strdup _lower(mem_ctx, argv[0]);874 service = talloc_strdup(mem_ctx, argv[0]); 867 875 if (service == NULL) { 868 876 d_printf("error: out of memory!\n"); … … 917 925 } 918 926 919 service = talloc_strdup _lower(mem_ctx, argv[0]);927 service = talloc_strdup(mem_ctx, argv[0]); 920 928 if (service == NULL) { 921 929 d_printf("error: out of memory!\n"); … … 957 965 } 958 966 959 service = talloc_strdup _lower(mem_ctx, argv[0]);967 service = talloc_strdup(mem_ctx, argv[0]); 960 968 if (service == NULL) { 961 969 d_printf("error: out of memory!\n"); … … 997 1005 } 998 1006 999 service = talloc_strdup _lower(mem_ctx, argv[0]);1007 service = talloc_strdup(mem_ctx, argv[0]); 1000 1008 if (service == NULL) { 1001 1009 d_printf("error: out of memory!\n"); -
branches/samba-3.3.x/source/utils/net_rpc.c
r221 r224 121 121 DOM_SID *domain_sid; 122 122 const char *domain_name; 123 int ret = -1; 123 124 124 125 /* make use of cli_state handed over as an argument, if possible */ … … 142 143 if (!(mem_ctx = talloc_init("run_rpc_command"))) { 143 144 DEBUG(0, ("talloc_init() failed\n")); 144 cli_shutdown(cli); 145 return -1; 145 goto fail; 146 146 } 147 147 … … 149 149 &domain_name); 150 150 if (!NT_STATUS_IS_OK(nt_status)) { 151 cli_shutdown(cli); 152 return -1; 151 goto fail; 153 152 } 154 153 … … 165 164 DEBUG(0, ("Could not initialise schannel netlogon pipe. Error was %s\n", 166 165 nt_errstr(nt_status) )); 167 cli_shutdown(cli); 168 return -1; 166 goto fail; 169 167 } 170 168 } else { … … 185 183 debug_ctx(), cli, interface), 186 184 nt_errstr(nt_status) )); 187 cli_shutdown(cli); 188 return -1; 185 goto fail; 189 186 } 190 187 } … … 196 193 DEBUG(1, ("rpc command function failed! (%s)\n", nt_errstr(nt_status))); 197 194 } else { 195 ret = 0; 198 196 DEBUG(5, ("rpc command function succedded\n")); 199 197 } … … 205 203 } 206 204 205 fail: 207 206 /* close the connection only if it was opened here */ 208 207 if (!cli_arg) { … … 211 210 212 211 talloc_destroy(mem_ctx); 213 return (!NT_STATUS_IS_OK(nt_status));212 return ret; 214 213 } 215 214 … … 6128 6127 nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx, 6129 6128 pipe_hnd->desthost, 6130 SAMR_ACCESS_ OPEN_DOMAIN,6129 SAMR_ACCESS_LOOKUP_DOMAIN, 6131 6130 &connect_hnd); 6132 6131 if (!NT_STATUS_IS_OK(nt_status)) { -
branches/samba-3.3.x/source/utils/net_rpc_join.c
r221 r224 245 245 pipe_hnd->desthost, 246 246 SAMR_ACCESS_ENUM_DOMAINS 247 | SAMR_ACCESS_ OPEN_DOMAIN,247 | SAMR_ACCESS_LOOKUP_DOMAIN, 248 248 &sam_pol), 249 249 "could not connect to SAM database"); -
branches/samba-3.3.x/source/utils/net_rpc_service.c
r206 r224 583 583 ********************************************************************/ 584 584 585 static NTSTATUS rpc_service_delete_internal(struct net_context *c, 586 const DOM_SID *domain_sid, 587 const char *domain_name, 588 struct cli_state *cli, 589 struct rpc_pipe_client *pipe_hnd, 590 TALLOC_CTX *mem_ctx, 591 int argc, 592 const char **argv) 593 { 594 struct policy_handle hSCM, hService; 595 WERROR result = WERR_GENERAL_FAILURE; 596 NTSTATUS status; 597 598 if (argc != 1 ) { 599 d_printf("Usage: net rpc service delete <service>\n"); 600 return NT_STATUS_OK; 601 } 602 603 /* Open the Service Control Manager */ 604 status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, 605 pipe_hnd->srv_name_slash, 606 NULL, 607 SC_RIGHT_MGR_ENUMERATE_SERVICE, 608 &hSCM, 609 &result); 610 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 611 d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", 612 win_errstr(result)); 613 return werror_to_ntstatus(result); 614 } 615 616 /* Open the Service */ 617 618 status = rpccli_svcctl_OpenServiceW(pipe_hnd, mem_ctx, 619 &hSCM, 620 argv[0], 621 SERVICE_ALL_ACCESS, 622 &hService, 623 &result); 624 625 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { 626 d_fprintf(stderr, "Failed to open service. [%s]\n", 627 win_errstr(result)); 628 goto done; 629 } 630 631 /* Delete the Service */ 632 633 status = rpccli_svcctl_DeleteService(pipe_hnd, mem_ctx, 634 &hService, 635 &result); 636 637 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { 638 d_fprintf(stderr, "Delete service request failed. [%s]\n", 639 win_errstr(result)); 640 goto done; 641 } 642 643 d_printf("Successfully deleted Service: %s\n", argv[0]); 644 645 done: 646 if (is_valid_policy_hnd(&hService)) { 647 rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); 648 } 649 if (is_valid_policy_hnd(&hSCM)) { 650 rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); 651 } 652 653 return werror_to_ntstatus(result); 654 } 655 656 /******************************************************************** 657 ********************************************************************/ 658 659 static NTSTATUS rpc_service_create_internal(struct net_context *c, 660 const DOM_SID *domain_sid, 661 const char *domain_name, 662 struct cli_state *cli, 663 struct rpc_pipe_client *pipe_hnd, 664 TALLOC_CTX *mem_ctx, 665 int argc, 666 const char **argv) 667 { 668 struct policy_handle hSCM, hService; 669 WERROR result = WERR_GENERAL_FAILURE; 670 NTSTATUS status; 671 const char *ServiceName; 672 const char *DisplayName; 673 const char *binary_path; 674 675 if (argc != 3) { 676 d_printf("Usage: net rpc service create <service> <displayname> <binarypath>\n"); 677 return NT_STATUS_OK; 678 } 679 680 /* Open the Service Control Manager */ 681 status = rpccli_svcctl_OpenSCManagerW(pipe_hnd, mem_ctx, 682 pipe_hnd->srv_name_slash, 683 NULL, 684 SC_RIGHT_MGR_CREATE_SERVICE, 685 &hSCM, 686 &result); 687 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result)) { 688 d_fprintf(stderr, "Failed to open Service Control Manager. [%s]\n", 689 win_errstr(result)); 690 return werror_to_ntstatus(result); 691 } 692 693 /* Create the service */ 694 695 ServiceName = argv[0]; 696 DisplayName = argv[1]; 697 binary_path = argv[2]; 698 699 status = rpccli_svcctl_CreateServiceW(pipe_hnd, mem_ctx, 700 &hSCM, 701 ServiceName, 702 DisplayName, 703 SERVICE_ALL_ACCESS, 704 SERVICE_TYPE_WIN32_OWN_PROCESS, 705 SVCCTL_DEMAND_START, 706 SVCCTL_SVC_ERROR_NORMAL, 707 binary_path, 708 NULL, /* LoadOrderGroupKey */ 709 NULL, /* TagId */ 710 NULL, /* dependencies */ 711 0, /* dependencies_size */ 712 NULL, /* service_start_name */ 713 NULL, /* password */ 714 0, /* password_size */ 715 &hService, 716 &result); 717 718 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(result) ) { 719 d_fprintf(stderr, "Create service request failed. [%s]\n", 720 win_errstr(result)); 721 goto done; 722 } 723 724 d_printf("Successfully created Service: %s\n", argv[0]); 725 726 done: 727 if (is_valid_policy_hnd(&hService)) { 728 rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hService, NULL); 729 } 730 if (is_valid_policy_hnd(&hSCM)) { 731 rpccli_svcctl_CloseServiceHandle(pipe_hnd, mem_ctx, &hSCM, NULL); 732 } 733 734 return werror_to_ntstatus(result); 735 } 736 737 /******************************************************************** 738 ********************************************************************/ 739 585 740 static int rpc_service_list(struct net_context *c, int argc, const char **argv ) 586 741 { … … 674 829 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0, 675 830 rpc_service_status_internal, argc, argv ); 831 } 832 833 /******************************************************************** 834 ********************************************************************/ 835 836 static int rpc_service_delete(struct net_context *c, int argc, const char **argv) 837 { 838 if (c->display_usage) { 839 d_printf("Usage:\n" 840 "net rpc service delete <service>\n" 841 " Delete a Win32 service\n"); 842 return 0; 843 } 844 845 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0, 846 rpc_service_delete_internal, argc, argv); 847 } 848 849 /******************************************************************** 850 ********************************************************************/ 851 852 static int rpc_service_create(struct net_context *c, int argc, const char **argv) 853 { 854 if (c->display_usage) { 855 d_printf("Usage:\n" 856 "net rpc service create <service>\n" 857 " Create a Win32 service\n"); 858 return 0; 859 } 860 861 return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0, 862 rpc_service_create_internal, argc, argv); 676 863 } 677 864 … … 730 917 " View current status of a service" 731 918 }, 919 { 920 "delete", 921 rpc_service_delete, 922 NET_TRANSPORT_RPC, 923 "Delete a service", 924 "net rpc service delete\n" 925 " Deletes a service" 926 }, 927 { 928 "create", 929 rpc_service_create, 930 NET_TRANSPORT_RPC, 931 "Create a service", 932 "net rpc service create\n" 933 " Creates a service" 934 }, 935 732 936 {NULL, NULL, 0, NULL, NULL} 733 937 }; -
branches/samba-3.3.x/source/utils/net_util.c
r206 r224 522 522 nt_errstr(nt_status)); 523 523 cli = NULL; 524 } else if (c->opt_request_timeout) { 525 cli_set_timeout(cli, c->opt_request_timeout * 1000); 524 526 } 525 527 -
branches/samba-3.3.x/source/utils/smbpasswd.c
r206 r224 431 431 432 432 if((local_flags & LOCAL_SET_PASSWORD) && (new_passwd == NULL)) { 433 struct passwd *passwd = getpwnam_alloc(NULL, user_name); 434 435 if (!passwd) { 436 fprintf(stderr, "Cannot locate Unix account for " 437 "'%s'!\n", user_name); 438 exit(1); 433 struct passwd *passwd; 434 435 if (remote_machine == NULL) { 436 passwd = getpwnam_alloc(NULL, user_name); 437 438 if (!passwd) { 439 fprintf(stderr, "Cannot locate Unix account for " 440 "'%s'!\n", user_name); 441 exit(1); 442 } 443 TALLOC_FREE(passwd); 439 444 } 440 TALLOC_FREE(passwd);441 445 442 446 new_passwd = prompt_for_new_password(stdin_passwd_get);
Note:
See TracChangeset
for help on using the changeset viewer.