Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/rpcclient/rpcclient.c

    r587 r740  
    1010   the Free Software Foundation; either version 3 of the License, or
    1111   (at your option) any later version.
    12    
     12
    1313   This program is distributed in the hope that it will be useful,
    1414   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1515   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1616   GNU General Public License for more details.
    17    
     17
    1818   You should have received a copy of the GNU General Public License
    1919   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2121
    2222#include "includes.h"
     23#include "popt_common.h"
    2324#include "rpcclient.h"
    2425#include "../libcli/auth/libcli_auth.h"
    25 #include "../librpc/gen_ndr/cli_lsa.h"
    26 
    27 DOM_SID domain_sid;
    28 
    29 static enum pipe_auth_type pipe_default_auth_type = PIPE_AUTH_TYPE_NONE;
     26#include "../librpc/gen_ndr/ndr_lsa_c.h"
     27#include "rpc_client/cli_lsarpc.h"
     28#include "../librpc/gen_ndr/ndr_netlogon.h"
     29#include "rpc_client/cli_netlogon.h"
     30#include "../libcli/smbreadline/smbreadline.h"
     31#include "../libcli/security/security.h"
     32#include "passdb.h"
     33#include "libsmb/libsmb.h"
     34
     35enum pipe_auth_type_spnego {
     36        PIPE_AUTH_TYPE_SPNEGO_NONE = 0,
     37        PIPE_AUTH_TYPE_SPNEGO_NTLMSSP,
     38        PIPE_AUTH_TYPE_SPNEGO_KRB5
     39};
     40
     41struct dom_sid domain_sid;
     42
     43static enum dcerpc_AuthType pipe_default_auth_type = DCERPC_AUTH_TYPE_NONE;
     44static enum pipe_auth_type_spnego pipe_default_auth_spnego_type = 0;
    3045static enum dcerpc_AuthLevel pipe_default_auth_level = DCERPC_AUTH_LEVEL_NONE;
    3146static unsigned int timeout = 0;
     
    8398                        break;
    8499                }
    85                
     100
    86101                for (i=0; commands->cmd_set[i].name; i++) {
    87102                        if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
     
    102117                }
    103118                commands = commands->next;
    104                
    105119        }
    106120
     
    117131        char *command;
    118132        char                    *p;
    119        
     133
    120134        if (!cmdstr || !(*cmdstr))
    121135                return NULL;
    122        
     136
    123137        p = strchr_m(*cmdstr, ';');
    124138        if (p)
     
    129143        else
    130144                *cmdstr = NULL;
    131        
     145
    132146        return command;
    133147}
     
    138152{
    139153        struct policy_handle pol;
    140         NTSTATUS result = NT_STATUS_OK;
     154        NTSTATUS result = NT_STATUS_OK, status;
    141155        static bool got_domain_sid;
    142156        TALLOC_CTX *mem_ctx;
    143157        struct rpc_pipe_client *lsapipe = NULL;
    144158        union lsa_PolicyInformation *info = NULL;
     159        struct dcerpc_binding_handle *b;
    145160
    146161        if (got_domain_sid) return;
     
    157172                goto error;
    158173        }
    159        
     174
     175        b = lsapipe->binding_handle;
     176
    160177        result = rpccli_lsa_open_policy(lsapipe, mem_ctx, True,
    161178                                     SEC_FLAG_MAXIMUM_ALLOWED,
     
    165182        }
    166183
    167         result = rpccli_lsa_QueryInfoPolicy(lsapipe, mem_ctx,
     184        status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
    168185                                            &pol,
    169186                                            LSA_POLICY_INFO_ACCOUNT_DOMAIN,
    170                                             &info);
     187                                            &info,
     188                                            &result);
     189        if (!NT_STATUS_IS_OK(status)) {
     190                result = status;
     191                goto error;
     192        }
    171193        if (!NT_STATUS_IS_OK(result)) {
    172194                goto error;
     
    176198        sid_copy(&domain_sid, info->account_domain.sid);
    177199
    178         rpccli_lsa_Close(lsapipe, mem_ctx, &pol);
     200        dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
    179201        TALLOC_FREE(lsapipe);
    180202        talloc_destroy(mem_ctx);
     
    218240        {
    219241                tmp_set = tmp->cmd_set;
    220                
     242
    221243                if (!StrCaseCmp(argv[1], tmp_set->name))
    222244                {
     
    232254                                        printf("\n");
    233255                        }
    234                        
     256
    235257                        /* drop out of the loop */
    236258                        break;
     
    261283        if (argc == 2) {
    262284                for (tmp = cmd_list; tmp; tmp = tmp->next) {
    263                        
     285
    264286                        tmp_set = tmp->cmd_set;
    265287
     
    313335
    314336        if (argc == 2) {
    315                 DEBUGLEVEL = atoi(argv[1]);
     337                lp_set_cmdline("log level", argv[1]);
    316338        }
    317339
     
    380402                         int argc, const char **argv)
    381403{
     404        const char *p = "[KRB5|KRB5_SPNEGO|NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]";
    382405        const char *type = "NTLMSSP";
    383406
    384407        pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
    385         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     408        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    386409
    387410        if (argc > 2) {
    388                 printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]);
     411                printf("Usage: %s %s\n", argv[0], p);
    389412                return NT_STATUS_OK;
    390413        }
     
    392415        if (argc == 2) {
    393416                type = argv[1];
    394                 if (strequal(type, "NTLMSSP")) {
    395                         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     417                if (strequal(type, "KRB5")) {
     418                        pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5;
     419                } else if (strequal(type, "KRB5_SPNEGO")) {
     420                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     421                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     422                } else if (strequal(type, "NTLMSSP")) {
     423                        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    396424                } else if (strequal(type, "NTLMSSP_SPNEGO")) {
    397                         pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     425                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     426                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
    398427                } else if (strequal(type, "SCHANNEL")) {
    399                         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     428                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    400429                } else {
    401430                        printf("unknown type %s\n", type);
     431                        printf("Usage: %s %s\n", argv[0], p);
    402432                        return NT_STATUS_INVALID_LEVEL;
    403433                }
     
    412442                         int argc, const char **argv)
    413443{
     444        const char *p = "[KRB5|KRB5_SPNEGO|NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]";
    414445        const char *type = "NTLMSSP";
    415446
    416447        pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY;
    417         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     448        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    418449
    419450        if (argc > 2) {
    420                 printf("Usage: %s [NTLMSSP|NTLMSSP_SPNEGO|SCHANNEL]\n", argv[0]);
     451                printf("Usage: %s %s\n", argv[0], p);
    421452                return NT_STATUS_OK;
    422453        }
     
    424455        if (argc == 2) {
    425456                type = argv[1];
    426                 if (strequal(type, "NTLMSSP")) {
    427                         pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     457                if (strequal(type, "KRB5")) {
     458                        pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5;
     459                } else if (strequal(type, "KRB5_SPNEGO")) {
     460                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     461                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     462                } else if (strequal(type, "NTLMSSP")) {
     463                        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    428464                } else if (strequal(type, "NTLMSSP_SPNEGO")) {
    429                         pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     465                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     466                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
    430467                } else if (strequal(type, "SCHANNEL")) {
    431                         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     468                        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    432469                } else {
    433470                        printf("unknown type %s\n", type);
     471                        printf("Usage: %s %s\n", argv[0], p);
    434472                        return NT_STATUS_INVALID_LEVEL;
    435473                }
     
    455493
    456494                for (tmp = cmd_list; tmp; tmp = tmp->next) {
    457                        
     495
    458496                        struct cmd_set *tmp_set;
    459497
     
    478516{
    479517        pipe_default_auth_level = DCERPC_AUTH_LEVEL_NONE;
    480         pipe_default_auth_type = PIPE_AUTH_TYPE_NONE;
     518        pipe_default_auth_type = DCERPC_AUTH_TYPE_NONE;
     519        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NONE;
    481520
    482521        return cmd_set_ss_level();
     
    488527        d_printf("Setting schannel - sign and seal\n");
    489528        pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY;
    490         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     529        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    491530
    492531        return cmd_set_ss_level();
     
    498537        d_printf("Setting schannel - sign only\n");
    499538        pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
    500         pipe_default_auth_type = PIPE_AUTH_TYPE_SCHANNEL;
     539        pipe_default_auth_type = DCERPC_AUTH_TYPE_SCHANNEL;
    501540
    502541        return cmd_set_ss_level();
     
    549588        { "schannel", RPC_RTYPE_NTSTATUS, cmd_schannel, NULL,     NULL, NULL,   "Force RPC pipe connections to be sealed with 'schannel'.  Assumes valid machine account to this domain controller.", "" },
    550589        { "schannelsign", RPC_RTYPE_NTSTATUS, cmd_schannel_sign, NULL,    NULL, NULL, "Force RPC pipe connections to be signed (not sealed) with 'schannel'.  Assumes valid machine account to this domain controller.", "" },
    551         { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL,       NULL, NULL, "Set timeout (in milliseonds) for RPC operations", "" },
     590        { "timeout", RPC_RTYPE_NTSTATUS, cmd_timeout, NULL,       NULL, NULL, "Set timeout (in milliseconds) for RPC operations", "" },
    552591        { "transport", RPC_RTYPE_NTSTATUS, cmd_choose_transport, NULL,    NULL, NULL, "Choose ncacn transport for RPC operations", "" },
    553592        { "none", RPC_RTYPE_NTSTATUS, cmd_none, NULL,     NULL, NULL, "Force RPC pipe connections to have no special properties", "" },
     
    579618extern struct cmd_set drsuapi_commands[];
    580619extern struct cmd_set eventlog_commands[];
     620extern struct cmd_set winreg_commands[];
    581621
    582622static struct cmd_set *rpcclient_command_list[] = {
     
    597637        drsuapi_commands,
    598638        eventlog_commands,
     639        winreg_commands,
    599640        NULL
    600641};
     
    629670        NTSTATUS ntresult;
    630671        WERROR wresult;
    631        
     672
    632673        TALLOC_CTX *mem_ctx;
    633674
     
    643684        if ((cmd_entry->interface != NULL) && (cmd_entry->rpc_pipe == NULL)) {
    644685                switch (pipe_default_auth_type) {
    645                         case PIPE_AUTH_TYPE_NONE:
    646                                 ntresult = cli_rpc_pipe_open_noauth_transport(
    647                                         cli, default_transport,
    648                                         cmd_entry->interface,
    649                                         &cmd_entry->rpc_pipe);
    650                                 break;
     686                case DCERPC_AUTH_TYPE_NONE:
     687                        ntresult = cli_rpc_pipe_open_noauth_transport(
     688                                cli, default_transport,
     689                                cmd_entry->interface,
     690                                &cmd_entry->rpc_pipe);
     691                        break;
     692                case DCERPC_AUTH_TYPE_SPNEGO:
     693                        switch (pipe_default_auth_spnego_type) {
    651694                        case PIPE_AUTH_TYPE_SPNEGO_NTLMSSP:
    652695                                ntresult = cli_rpc_pipe_open_spnego_ntlmssp(
    653                                         cli, cmd_entry->interface,
    654                                         default_transport,
    655                                         pipe_default_auth_level,
    656                                         get_cmdline_auth_info_domain(auth_info),
    657                                         get_cmdline_auth_info_username(auth_info),
    658                                         get_cmdline_auth_info_password(auth_info),
    659                                         &cmd_entry->rpc_pipe);
     696                                                cli, cmd_entry->interface,
     697                                                default_transport,
     698                                                pipe_default_auth_level,
     699                                                get_cmdline_auth_info_domain(auth_info),
     700                                                get_cmdline_auth_info_username(auth_info),
     701                                                get_cmdline_auth_info_password(auth_info),
     702                                                &cmd_entry->rpc_pipe);
    660703                                break;
    661                         case PIPE_AUTH_TYPE_NTLMSSP:
    662                                 ntresult = cli_rpc_pipe_open_ntlmssp(
    663                                         cli, cmd_entry->interface,
    664                                         default_transport,
    665                                         pipe_default_auth_level,
    666                                         get_cmdline_auth_info_domain(auth_info),
    667                                         get_cmdline_auth_info_username(auth_info),
    668                                         get_cmdline_auth_info_password(auth_info),
    669                                         &cmd_entry->rpc_pipe);
    670                                 break;
    671                         case PIPE_AUTH_TYPE_SCHANNEL:
    672                                 ntresult = cli_rpc_pipe_open_schannel(
    673                                         cli, cmd_entry->interface,
    674                                         default_transport,
    675                                         pipe_default_auth_level,
    676                                         get_cmdline_auth_info_domain(auth_info),
    677                                         &cmd_entry->rpc_pipe);
     704                        case PIPE_AUTH_TYPE_SPNEGO_KRB5:
     705                                ntresult = cli_rpc_pipe_open_spnego_krb5(
     706                                                cli, cmd_entry->interface,
     707                                                default_transport,
     708                                                pipe_default_auth_level,
     709                                                cli->desthost,
     710                                                NULL, NULL,
     711                                                &cmd_entry->rpc_pipe);
    678712                                break;
    679713                        default:
    680                                 DEBUG(0, ("Could not initialise %s. Invalid "
    681                                           "auth type %u\n",
    682                                           get_pipe_name_from_syntax(
    683                                                   talloc_tos(),
    684                                                   cmd_entry->interface),
    685                                           pipe_default_auth_type ));
    686                                 return NT_STATUS_UNSUCCESSFUL;
     714                                ntresult = NT_STATUS_INTERNAL_ERROR;
     715                        }
     716                        break;
     717                case DCERPC_AUTH_TYPE_NTLMSSP:
     718                        ntresult = cli_rpc_pipe_open_ntlmssp(
     719                                cli, cmd_entry->interface,
     720                                default_transport,
     721                                pipe_default_auth_level,
     722                                get_cmdline_auth_info_domain(auth_info),
     723                                get_cmdline_auth_info_username(auth_info),
     724                                get_cmdline_auth_info_password(auth_info),
     725                                &cmd_entry->rpc_pipe);
     726                        break;
     727                case DCERPC_AUTH_TYPE_SCHANNEL:
     728                        ntresult = cli_rpc_pipe_open_schannel(
     729                                cli, cmd_entry->interface,
     730                                default_transport,
     731                                pipe_default_auth_level,
     732                                get_cmdline_auth_info_domain(auth_info),
     733                                &cmd_entry->rpc_pipe);
     734                        break;
     735                case DCERPC_AUTH_TYPE_KRB5:
     736                        ntresult = cli_rpc_pipe_open_krb5(
     737                                cli, cmd_entry->interface,
     738                                default_transport,
     739                                pipe_default_auth_level,
     740                                cli->desthost,
     741                                NULL, NULL,
     742                                &cmd_entry->rpc_pipe);
     743                        break;
     744                default:
     745                        DEBUG(0, ("Could not initialise %s. Invalid "
     746                                  "auth type %u\n",
     747                                  get_pipe_name_from_syntax(
     748                                          talloc_tos(),
     749                                          cmd_entry->interface),
     750                                  pipe_default_auth_type ));
     751                        return NT_STATUS_UNSUCCESSFUL;
    687752                }
    688753                if (!NT_STATUS_IS_OK(ntresult)) {
     
    858923        /* the following functions are part of the Samba debugging
    859924           facilities.  See lib/debug.c */
    860         setup_logging("rpcclient", True);
     925        setup_logging("rpcclient", DEBUG_STDOUT);
    861926
    862927        rpcclient_auth_info = user_auth_info_init(frame);
     
    9691034        if (binding->flags & DCERPC_SIGN) {
    9701035                pipe_default_auth_level = DCERPC_AUTH_LEVEL_INTEGRITY;
    971                 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     1036                pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    9721037        }
    9731038        if (binding->flags & DCERPC_SEAL) {
    9741039                pipe_default_auth_level = DCERPC_AUTH_LEVEL_PRIVACY;
    975                 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     1040                pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
    9761041        }
    9771042        if (binding->flags & DCERPC_AUTH_SPNEGO) {
    978                 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     1043                pipe_default_auth_type = DCERPC_AUTH_TYPE_SPNEGO;
     1044                pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
    9791045        }
    9801046        if (binding->flags & DCERPC_AUTH_NTLM) {
    981                 pipe_default_auth_type = PIPE_AUTH_TYPE_NTLMSSP;
     1047                /* If neither Integrity or Privacy are requested then
     1048                 * Use just Connect level */
     1049                if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) {
     1050                        pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT;
     1051                }
     1052
     1053                if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) {
     1054                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_NTLMSSP;
     1055                } else {
     1056                        pipe_default_auth_type = DCERPC_AUTH_TYPE_NTLMSSP;
     1057                }
    9821058        }
    9831059        if (binding->flags & DCERPC_AUTH_KRB5) {
    984                 pipe_default_auth_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     1060                /* If neither Integrity or Privacy are requested then
     1061                 * Use just Connect level */
     1062                if (pipe_default_auth_level == DCERPC_AUTH_LEVEL_NONE) {
     1063                        pipe_default_auth_level = DCERPC_AUTH_LEVEL_CONNECT;
     1064                }
     1065
     1066                if (pipe_default_auth_type == DCERPC_AUTH_TYPE_SPNEGO) {
     1067                        pipe_default_auth_spnego_type = PIPE_AUTH_TYPE_SPNEGO_KRB5;
     1068                } else {
     1069                        pipe_default_auth_type = DCERPC_AUTH_TYPE_KRB5;
     1070                }
    9851071        }
    9861072
     
    10131099                                        get_cmdline_auth_info_password(rpcclient_auth_info),
    10141100                                        flags,
    1015                                         get_cmdline_auth_info_signing_state(rpcclient_auth_info),
    1016                                         NULL);
     1101                                        get_cmdline_auth_info_signing_state(rpcclient_auth_info));
    10171102
    10181103        if (!NT_STATUS_IS_OK(nt_status)) {
Note: See TracChangeset for help on using the changeset viewer.