Changeset 929


Ignore:
Timestamp:
Jul 25, 2016, 11:19:09 AM (9 years ago)
Author:
Paul Smedley
Message:

make it build using Samba 4.4.x

Location:
branches/client-3.0/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/client-3.0/src/Config.km_

    r884 r929  
    1111# adjust also the date please
    1212#
    13 VERSION = 2.3.x
     13VERSION = 3.0.x
    1414BUILD   = beta-date
    1515VENDOR  = netlabs
    16 SAMBA   = ../../samba-36
     16SAMBA   = ../../samba-44
    1717TOOLKIT = u:/os2tk45
    1818
     
    2323GCC_LIB=e:/usr/lib
    2424
    25 # libsmb 3.3 is threadunsafe, change =0 to =1 if it works again
     25# libsmb is threadunsafe, change =0 to =1 if it works again
    2626LIBSMB_THREAD_UNSAFE = LIBSMB_THREAD_SAFE=0
  • branches/client-3.0/src/Makefile.kmk

    r883 r929  
    4444ndpsmb_INCS = ./h ./rc \
    4545                $(SAMBA)        \
     46                $(SAMBA)/bin/default/include/public     \
     47                $(SAMBA)/bin/default/include    \
     48                $(SAMBA)/bin/default    \
    4649                $(SAMBA)/source3 \
    4750                $(SAMBA)/source3/include \
     
    4952                $(SAMBA)/popt \
    5053                $(SAMBA)/lib/talloc \
     54                $(SAMBA)/libcli \
    5155                $(SAMBA)/librpc \
    5256                $(SAMBA)/lib/tdb/include \
    5357                $(SAMBA)/lib/tevent
    5458
    55 ndpsmb_LIBS = libsmbclient libtalloc libtdb libwbclient libtevent z mmap
    56 ndpsmb_LIBS += $(GCC_LIB)/binmode.obj
     59ndpsmb_LIBS = $(SAMBA)/smbcln44.lib
    5760ndpsmb_LIBPATH = $(SAMBA)/source3/bin $(Z_LIBDIR)
    5861
  • branches/client-3.0/src/smbwrp.c

    r887 r929  
    2424#include "libsmb/libsmb.h"
    2525#include "libsmb/clirap.h"
     26#include "param.h"
     27#include "smb/smbXcli_base.h"
    2628#include "trans2.h"
    2729#include "smbwrp.h"
     30#include "util.h"
    2831
    2932/*
     
    3336int os2cli_errno(cli_state * cli)
    3437{
     38#if 0 // cli->fd not available in Samba 4.x
    3539        if (cli->fd == -1)
    3640        {
    3741                return maperror( ENOTCONN);
    3842        }
     43#endif
    3944        return maperror(cli_errno(cli));
    4045}
     
    5762
    5863        // init samba for debug messages
    59         setup_logging(slogfile, false);
     64        setup_logging(slogfile, DEBUG_FILE);
    6065        lp_set_logfile(slogfile);
    61         debug_parse_levels("10");
    62 
    63 }
     66        reopen_logs();
     67}
     68
    6469const char * smbwrp_getVersion()
    6570{
     
    8085        char *p;
    8186
     87        struct loadparm_context *lp_ctx;
     88        TALLOC_CTX *frame = talloc_stackframe();
     89
    8290        if (initialised)
    8391        {
     
    8694        initialised = 1;
    8795
    88         lp_set_in_client(true); /* Make sure that we tell lp_load we are client */
    89 
    90         load_case_tables();
    91 
    92         if (!lp_load(get_dyn_CONFIGFILE(),true,false,false,true)) {
    93                 debuglocal(0,("The initial smb.conf is missing, defaults are used!\n"));
    94         }
    95 
     96        smb_init_locale();
     97
     98        if (!lp_load_client(get_dyn_CONFIGFILE())) {
     99                debuglocal(0,("Can't load %s, defaults are used!\n",get_dyn_CONFIGFILE()));
     100        }
    96101        load_interfaces();
    97102
     
    219224/*****************************************************
    220225return a connection to a server
     226loosely based on do_connect() from libsmb/clidfs.c
    221227*******************************************************/
    222228int _System smbwrp_connect( Resource* pRes, cli_state ** cli)
     
    228234        struct nmb_name called, calling;
    229235        char *p, *server_n = server;
    230         fstring group;
    231         struct sockaddr_storage ss;
    232236        struct cli_state * c;
    233237        char* dev_type;
    234238        int loginerror = 0;
    235239        NTSTATUS status;
    236 
    237         zero_sockaddr(&ss);
     240        int max_protocol = lp__client_max_protocol();
     241        int port = 0; //NBT_SMB_PORT;
     242        int name_type= 0x20;
     243        int flags = 0;
     244        enum protocol_types protocol;
     245        const char *name = NULL;
    238246
    239247        debuglocal(1,"Connecting to \\\\%s:*********@%s:%s\\%s. Master %s:%d\n", srv->username,  workgroup, server, share, srv->master, srv->ifmastergroup);
    240 
    241         if (!*server) {
    242                 struct sockaddr_storage sip;
    243 
    244                 if (*workgroup)
    245                 {
    246                         if (!find_master_ip(workgroup, &sip)) {
    247                                 return 1;
    248                         }
    249                         fstrcpy(group, inet_ntoa(sip.sin_addr));
    250                         server_n = group;
    251                 } else
    252                 if (*srv->master)
    253                 {
    254                         if (srv->ifmastergroup)
    255                         {
    256                                 if (!find_master_ip(srv->master, &sip)) {
    257                                         return 11;
    258                                 }
    259                                 strncpy(srv->master, inet_ntoa(sip.sin_addr), sizeof(srv->master) - 1);
    260                                 srv->ifmastergroup = 0;
    261                         }
    262                         server_n = srv->master;
    263                 } else
    264                 {
    265                         return 10;
    266                 }               
    267         }
    268 
    269         make_nmb_name(&calling, global_myname(), 0x0);
    270 //      make_nmb_name(&calling, "WORK", 0x0); // this machine name
    271         make_nmb_name(&called , server_n, 0x20);
    272 
    273  again:
    274         zero_sockaddr(&ss);
    275 
    276         /* have to open a new connection */
    277         if (!(c=cli_initialise()))
    278         {
    279                 return 2;
    280         }
    281248
    282249        cli_set_timeout(c, 10000); /* 10 seconds. */
     
    288255        }
    289256
    290         if (!NT_STATUS_IS_OK(cli_connect(c, server_n, &ss)))
    291         {
     257        status = cli_connect_nb(
     258                server, NULL, port, name_type, NULL,
     259                SMB_SIGNING_DEFAULT, flags, &c);
     260
     261        if (!NT_STATUS_IS_OK(status)) {
     262                debuglocal(4,"Connection to %s failed (Error %s)\n",
     263                                server,
     264                                nt_errstr(status));
    292265                return 3;
    293266        }
    294267
    295         if (!cli_session_request(c, &calling, &called)) {
     268        if (max_protocol == PROTOCOL_DEFAULT) {
     269                max_protocol = PROTOCOL_LATEST;
     270        }
     271        DEBUG(4,(" session request ok, c->timeout = %d\n",c->timeout));
     272
     273        status = smbXcli_negprot(c->conn, c->timeout,
     274                                 lp_client_min_protocol(),
     275                                 max_protocol);
     276
     277        if (!NT_STATUS_IS_OK(status)) {
     278                debuglocal(4,"protocol negotiation failed: %s\n",
     279                         nt_errstr(status));
    296280                cli_shutdown(c);
    297                 if (strcmp(called.name, "*SMBSERVER")) {
    298                         make_nmb_name(&called , "*SMBSERVER", 0x20);
    299                         goto again;
    300                 }
    301                 return 4;
    302         }
    303 
    304         debuglocal(4," session request ok\n");
    305 
    306         if (!NT_STATUS_IS_OK(cli_negprot(c))) {
    307                 cli_shutdown(c);
    308                 return 5;
    309         }
    310 
    311         debuglocal(4," session setuping for <%s>/<********> in <%s> %08x %08x %08x\n", srv->username,  workgroup, c->protocol, c->sec_mode, c->capabilities);
     281                return status;
     282        }
    312283
    313284        if (!NT_STATUS_IS_OK(cli_session_setup(c, srv->username,
     
    325296                }
    326297                debuglocal(4,"Anonymous login successful\n");
    327                 status = cli_init_creds(c, "", lp_workgroup(), "");
    328         } else {
    329                 status = cli_init_creds(c, srv->username, workgroup, srv->password);
    330298        }
    331299
     
    359327        }
    360328
    361         debuglocal(4," tconx ok. cli caps %08x\n", c->capabilities);
     329        debuglocal(4," tconx ok.\n");
    362330       
    363331        // save cli_state pointer
     
    419387                return maperror(EINVAL);
    420388        }
    421        
     389        size_t nread;
    422390        *result = 0;
    423         ret = cli_read(cli, file->fd, buf, file->offset, count);
     391        ret = cli_read(cli, file->fd, buf, file->offset, count, &nread);
    424392        if (ret == -1)
    425393        {
     394                debuglocal(4," smbwrp_read - cli_read ret = %d\n",ret);
    426395                return os2cli_errno(cli);
    427396        }
    428397
    429         file->offset += ret;
    430         *result = ret;
     398        file->offset += nread;
     399        *result = nread;
     400        debuglocal(4," smbwrp_read successful, nread = %d, ret = %d\n",nread,ret);
    431401        return 0;       
    432402}
     
    669639                return maperror(EINVAL);
    670640        }
    671         debuglocal(4,"getattr %d %d <%s>\n", cli->capabilities & CAP_NOPATHINFO2, cli->capabilities & CAP_NT_SMBS, finfo->fname);
    672         if (!(cli->capabilities & CAP_NOPATHINFO2) &&
    673                 NT_STATUS_IS_OK(cli_qpathinfo2(cli, finfo->fname, &ctime, &atime, &mtime, NULL,
     641        debuglocal(4,"getattr %d %d <%s>\n", smb1cli_conn_capabilities(cli->conn) & CAP_NOPATHINFO2, smb1cli_conn_capabilities(cli->conn) & CAP_NT_SMBS, finfo->fname);
     642
     643        if (NT_STATUS_IS_OK(cli_qpathinfo2(cli, finfo->fname, &ctime, &atime, &mtime, NULL,
    674644                           (off_t *)&finfo->size, (unsigned short *)&finfo->attr, &ino)))
    675645        {
     
    681651        }
    682652
     653#if 0 // cli->fd not available in Samba 4.x
    683654        if (cli->fd == -1)
    684655        {
    685656           /* fd == -1 means the connection is broken */
    686657           return maperror(ENOTCONN);
     658        }
     659#endif
     660
     661        debuglocal(4, "smbwrp_getattr, calling cli_qpathinfo3\n");
     662        if (NT_STATUS_IS_OK(cli_qpathinfo3(cli, finfo->fname, &ctime, &atime, &mtime, NULL,
     663                           (off_t *)&finfo->size, (unsigned short *)&finfo->attr, &ino)))
     664        {
     665                finfo->attr &= 0x7F;
     666                finfo->ctime = convert_timespec_to_time_t(ctime);
     667                finfo->atime = convert_timespec_to_time_t(atime);
     668                finfo->mtime = convert_timespec_to_time_t(mtime);
     669                return 0;
    687670        }
    688671
     
    709692       
    710693        /* if this is NT then don't bother with the getatr */
    711         if (cli->capabilities & CAP_NT_SMBS && !(cli->capabilities & CAP_NOPATHINFO2))
     694        if (smb1cli_conn_capabilities(cli->conn) & CAP_NT_SMBS/* && !(smb1cli_conn_capabilities(cli->conn) & CAP_NOPATHINFO2)*/)
    712695        {
    713696                int ret = cli_errno(cli);
     
    728711                finfo->atime = finfo->atime;  //was mtime
    729712                finfo->ctime = finfo->ctime;  //was mtime
    730                 cli->capabilities &= CAP_NOPATHINFO2;
    731713                return 0;
    732714        }
     
    782764add a entry to a directory listing
    783765*******************************************************/
    784 static void smbwrp_dir_add(const char* mnt, smbwrp_fileinfo *finfo, const char *mask, void *state)
     766static NTSTATUS smbwrp_dir_add(const char* mnt, smbwrp_fileinfo *finfo, const char *mask, void *state)
    785767{
    786768        if (state && finfo)
     
    814796}
    815797
    816 static void smbwrp_printjob_add(struct print_job_info *job, void * state)
     798static NTSTATUS smbwrp_printjob_add(struct print_job_info *job, void * state)
    817799{
    818800        smbwrp_fileinfo finfo = {0};
     
    832814}
    833815
    834 static void smbwrp_share_add(const char *share, uint32 type,
     816static void smbwrp_share_add(const char *share, uint32_t type,
    835817                           const char *comment, void *state)
    836818{
     
    852834 Modified from cli_list
    853835****************************************************************************/
    854 static int list_files(struct cli_state *cli, const char *mask, uint16 attribute,
     836static int list_files(struct cli_state *cli, const char *mask, uint16_t attribute,
    855837                  void (*fn)(const char *, smbwrp_fileinfo *, const char *,
    856838                             void *), void *state)
     
    873855        }
    874856
    875         if (cli_has_async_calls(cli)) {
     857        if (smbXcli_conn_has_async_calls(cli->conn)) {
    876858                /*
    877859                 * Can't use sync call while an async call is in flight
     
    880862                goto fail;
    881863        }
    882         ev = event_context_init(frame);
     864        ev = samba_tevent_context_init(frame);
    883865        if (ev == NULL) {
    884866                goto fail;
    885867        }
    886868
    887         info_level = (cli->capabilities & CAP_NT_SMBS)
     869        info_level = (smb1cli_conn_capabilities(cli->conn) & CAP_NT_SMBS)
    888870                ? SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_EA_SIZE;
    889871
Note: See TracChangeset for help on using the changeset viewer.