Ignore:
Timestamp:
May 24, 2009, 7:55:48 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 branch to 3.3.4

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  
    636636                {"stdin",       'i', POPT_ARG_NONE,   &c->opt_stdin},
    637637                {"timeout",     't', POPT_ARG_INT,    &c->opt_timeout},
     638                {"request-timeout",0,POPT_ARG_INT,    &c->opt_request_timeout},
    638639                {"machine-pass",'P', POPT_ARG_NONE,   &c->opt_machine_pass},
    639640                {"kerberos",    'k', POPT_ARG_NONE,   &c->opt_kerberos},
  • branches/samba-3.3.x/source/utils/net.h

    r206 r224  
    4444        int opt_flags;
    4545        int opt_timeout;
     46        int opt_request_timeout;
    4647        const char *opt_target_workgroup;
    4748        int opt_machine_pass;
  • branches/samba-3.3.x/source/utils/net_conf.c

    r223 r224  
    301301                        goto done;
    302302                case 2:
    303                         servicename = talloc_strdup_lower(mem_ctx, argv[1]);
     303                        servicename = talloc_strdup(mem_ctx, argv[1]);
    304304                        if (servicename == NULL) {
    305305                                d_printf("error: out of memory!\n");
     
    341341                        goto cancel;
    342342                }
     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
    343351                werr = import_process_service(c, conf_ctx, service);
    344352                if (!W_ERROR_IS_OK(werr)) {
     
    502510        }
    503511
    504         sharename = talloc_strdup_lower(mem_ctx, argv[0]);
     512        sharename = talloc_strdup(mem_ctx, argv[0]);
    505513        if (sharename == NULL) {
    506514                d_printf("error: out of memory!\n");
     
    515523        }
    516524
    517         d_printf("[%s]\n", sharename);
     525        d_printf("[%s]\n", service->name);
    518526
    519527        for (count = 0; count < service->num_params; count++) {
     
    601609                case 2:
    602610                        path = argv[1];
    603                         sharename = talloc_strdup_lower(mem_ctx, argv[0]);
     611                        sharename = talloc_strdup(mem_ctx, argv[0]);
    604612                        if (sharename == NULL) {
    605613                                d_printf("error: out of memory!\n");
     
    729737                goto done;
    730738        }
    731         sharename = talloc_strdup_lower(mem_ctx, argv[0]);
     739        sharename = talloc_strdup(mem_ctx, argv[0]);
    732740        if (sharename == NULL) {
    733741                d_printf("error: out of memory!\n");
     
    762770                goto done;
    763771        }
    764         service = talloc_strdup_lower(mem_ctx, argv[0]);
     772        service = talloc_strdup(mem_ctx, argv[0]);
    765773        if (service == NULL) {
    766774                d_printf("error: out of memory!\n");
     
    814822                goto done;
    815823        }
    816         service = talloc_strdup_lower(mem_ctx, argv[0]);
     824        service = talloc_strdup(mem_ctx, argv[0]);
    817825        if (service == NULL) {
    818826                d_printf("error: out of memory!\n");
     
    864872                goto done;
    865873        }
    866         service = talloc_strdup_lower(mem_ctx, argv[0]);
     874        service = talloc_strdup(mem_ctx, argv[0]);
    867875        if (service == NULL) {
    868876                d_printf("error: out of memory!\n");
     
    917925        }
    918926
    919         service = talloc_strdup_lower(mem_ctx, argv[0]);
     927        service = talloc_strdup(mem_ctx, argv[0]);
    920928        if (service == NULL) {
    921929                d_printf("error: out of memory!\n");
     
    957965        }
    958966
    959         service = talloc_strdup_lower(mem_ctx, argv[0]);
     967        service = talloc_strdup(mem_ctx, argv[0]);
    960968        if (service == NULL) {
    961969                d_printf("error: out of memory!\n");
     
    9971005        }
    9981006
    999         service = talloc_strdup_lower(mem_ctx, argv[0]);
     1007        service = talloc_strdup(mem_ctx, argv[0]);
    10001008        if (service == NULL) {
    10011009                d_printf("error: out of memory!\n");
  • branches/samba-3.3.x/source/utils/net_rpc.c

    r221 r224  
    121121        DOM_SID *domain_sid;
    122122        const char *domain_name;
     123        int ret = -1;
    123124
    124125        /* make use of cli_state handed over as an argument, if possible */
     
    142143        if (!(mem_ctx = talloc_init("run_rpc_command"))) {
    143144                DEBUG(0, ("talloc_init() failed\n"));
    144                 cli_shutdown(cli);
    145                 return -1;
     145                goto fail;
    146146        }
    147147
     
    149149                                              &domain_name);
    150150        if (!NT_STATUS_IS_OK(nt_status)) {
    151                 cli_shutdown(cli);
    152                 return -1;
     151                goto fail;
    153152        }
    154153
     
    165164                                DEBUG(0, ("Could not initialise schannel netlogon pipe. Error was %s\n",
    166165                                        nt_errstr(nt_status) ));
    167                                 cli_shutdown(cli);
    168                                 return -1;
     166                                goto fail;
    169167                        }
    170168                } else {
     
    185183                                                debug_ctx(), cli, interface),
    186184                                        nt_errstr(nt_status) ));
    187                                 cli_shutdown(cli);
    188                                 return -1;
     185                                goto fail;
    189186                        }
    190187                }
     
    196193                DEBUG(1, ("rpc command function failed! (%s)\n", nt_errstr(nt_status)));
    197194        } else {
     195                ret = 0;
    198196                DEBUG(5, ("rpc command function succedded\n"));
    199197        }
     
    205203        }
    206204
     205fail:
    207206        /* close the connection only if it was opened here */
    208207        if (!cli_arg) {
     
    211210
    212211        talloc_destroy(mem_ctx);
    213         return (!NT_STATUS_IS_OK(nt_status));
     212        return ret;
    214213}
    215214
     
    61286127        nt_status = rpccli_samr_Connect2(pipe_hnd, mem_ctx,
    61296128                                         pipe_hnd->desthost,
    6130                                          SAMR_ACCESS_OPEN_DOMAIN,
     6129                                         SAMR_ACCESS_LOOKUP_DOMAIN,
    61316130                                         &connect_hnd);
    61326131        if (!NT_STATUS_IS_OK(nt_status)) {
  • branches/samba-3.3.x/source/utils/net_rpc_join.c

    r221 r224  
    245245                                           pipe_hnd->desthost,
    246246                                           SAMR_ACCESS_ENUM_DOMAINS
    247                                            | SAMR_ACCESS_OPEN_DOMAIN,
     247                                           | SAMR_ACCESS_LOOKUP_DOMAIN,
    248248                                           &sam_pol),
    249249                      "could not connect to SAM database");
  • branches/samba-3.3.x/source/utils/net_rpc_service.c

    r206 r224  
    583583********************************************************************/
    584584
     585static 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
     659static 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
    585740static int rpc_service_list(struct net_context *c, int argc, const char **argv )
    586741{
     
    674829        return run_rpc_command(c, NULL, &ndr_table_svcctl.syntax_id, 0,
    675830                rpc_service_status_internal, argc, argv );
     831}
     832
     833/********************************************************************
     834********************************************************************/
     835
     836static 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
     852static 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);
    676863}
    677864
     
    730917                        "    View current status of a service"
    731918                },
     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
    732936                {NULL, NULL, 0, NULL, NULL}
    733937        };
  • branches/samba-3.3.x/source/utils/net_util.c

    r206 r224  
    522522                          nt_errstr(nt_status));
    523523                cli = NULL;
     524        } else if (c->opt_request_timeout) {
     525                cli_set_timeout(cli, c->opt_request_timeout * 1000);
    524526        }
    525527
  • branches/samba-3.3.x/source/utils/smbpasswd.c

    r206 r224  
    431431               
    432432                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);
    439444                        }
    440                         TALLOC_FREE(passwd);
    441445
    442446                        new_passwd = prompt_for_new_password(stdin_passwd_get);
Note: See TracChangeset for help on using the changeset viewer.