Changeset 808


Ignore:
Timestamp:
Sep 16, 2013, 7:03:21 PM (12 years ago)
Author:
Herwig Bauernfeind
Message:

Samba Client 2.2: Fix Ticket #227 (wrongly updated time stamps) by _diver

Location:
trunk/client/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/client/src/smbwrp.c

    r645 r808  
    3939static int
    4040net_share_enum_rpc(struct cli_state *cli,
    41                    void (*fn)(const char *name,
    42                               uint32 type,
    43                               const char *comment,
    44                               void *state),
    45                    void *state)
    46 {
    47         int i;
     41                   void (*fn)(const char *name,
     42                              uint32 type,
     43                              const char *comment,
     44                              void *state),
     45                   void *state)
     46{
     47        int i;
    4848        NTSTATUS status;
    49         WERROR werr;
     49        WERROR werr;
    5050        uint32_t resume_handle = 0;
    51         uint32_t total_entries = 0;
    52         struct srvsvc_NetShareInfoCtr info_ctr;
    53         struct srvsvc_NetShareCtr1 ctr1;
     51        uint32_t total_entries = 0;
     52        struct srvsvc_NetShareInfoCtr info_ctr;
     53        struct srvsvc_NetShareCtr1 ctr1;
    5454        fstring name = "";
    55         fstring comment = "";
    56         void *mem_ctx;
     55        fstring comment = "";
     56        void *mem_ctx;
    5757        struct rpc_pipe_client *pipe_hnd;
    5858
    59         /* Open the server service pipe */
    60         status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id, &pipe_hnd);
    61         if (!NT_STATUS_IS_OK(status)) {
    62                 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n"));
    63                 return -1;
    64         }
    65 
    66         /* Allocate a context for parsing and for the entries in "ctr" */
    67         mem_ctx = talloc_init("libsmbclient: net_share_enum_rpc");
    68         if (mem_ctx == NULL) {
    69                 DEBUG(0, ("out of memory for net_share_enum_rpc!\n"));
    70                 TALLOC_FREE(pipe_hnd);
    71                 return -1;
    72         }
    73 
    74         /* Issue the NetShareEnum RPC call and retrieve the response */
     59        /* Open the server service pipe */
     60        status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id, &pipe_hnd);
     61        if (!NT_STATUS_IS_OK(status)) {
     62                DEBUG(1, ("net_share_enum_rpc pipe open fail!\n"));
     63                return -1;
     64        }
     65
     66        /* Allocate a context for parsing and for the entries in "ctr" */
     67        mem_ctx = talloc_init("libsmbclient: net_share_enum_rpc");
     68        if (mem_ctx == NULL) {
     69                DEBUG(0, ("out of memory for net_share_enum_rpc!\n"));
     70                TALLOC_FREE(pipe_hnd);
     71                return -1;
     72        }
     73
     74        /* Issue the NetShareEnum RPC call and retrieve the response */
    7575        ZERO_STRUCT(info_ctr);
    76         ZERO_STRUCT(ctr1);
    77         info_ctr.level = 1;
    78         info_ctr.ctr.ctr1 = &ctr1;
     76        ZERO_STRUCT(ctr1);
     77        info_ctr.level = 1;
     78        info_ctr.ctr.ctr1 = &ctr1;
    7979        status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx,
    80                                               pipe_hnd->desthost,
    81                                               &info_ctr,
    82                                               0xffffffff,
    83                                               &total_entries,
    84                                               &resume_handle,
    85                                               &werr);
    86 
    87         /* Was it successful? */
     80                                              pipe_hnd->desthost,
     81                                              &info_ctr,
     82                                              0xffffffff,
     83                                              &total_entries,
     84                                              &resume_handle,
     85                                              &werr);
     86
     87        /* Was it successful? */
    8888        if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr) || info_ctr.ctr.ctr1->count == 0) {
    89                 /*  Nope.  Go clean up. */
     89                /*  Nope.  Go clean up. */
    9090                goto done;
    91         }
    92 
    93         /* For each returned entry... */
    94         for (i = 0; i < info_ctr.ctr.ctr1->count; i++) {
    95                 struct srvsvc_NetShareInfo1 info = info_ctr.ctr.ctr1->array[i];
    96 
    97                 /* Add this share to the list */
    98                 (*fn)(info.name, info.type, info.comment, state);
    99         }
     91        }
     92
     93        /* For each returned entry... */
     94        for (i = 0; i < info_ctr.ctr.ctr1->count; i++) {
     95                struct srvsvc_NetShareInfo1 info = info_ctr.ctr.ctr1->array[i];
     96
     97                /* Add this share to the list */
     98                (*fn)(info.name, info.type, info.comment, state);
     99        }
    100100
    101101done:
    102         /* Close the server service pipe */
    103         TALLOC_FREE(pipe_hnd);
    104 
    105         /* Free all memory which was allocated for this request */
    106         TALLOC_FREE(mem_ctx);
    107 
    108         /* Tell 'em if it worked */
    109         return W_ERROR_IS_OK(status) ? 0 : -1;
     102        /* Close the server service pipe */
     103        TALLOC_FREE(pipe_hnd);
     104
     105        /* Free all memory which was allocated for this request */
     106        TALLOC_FREE(mem_ctx);
     107
     108        /* Tell 'em if it worked */
     109        return W_ERROR_IS_OK(status) ? 0 : -1;
    110110}
    111111
     
    125125void smbwrp_Logging()
    126126{
    127         char slogfile[_MAX_PATH +1] = {0};
    128         char slogfilename[] = "log.smbc";
    129         char *env = getenv("LOGFILES");
    130                 if (env != NULL)
    131                 {
    132                    strncpy(slogfile, env, sizeof(slogfile) -1);
    133                    strncat(slogfile, "\\", sizeof(slogfile) - strlen(slogfile) -1);
    134                    strncat(slogfile, slogfilename, sizeof(slogfile) - strlen(slogfile) -1);
    135                 }
    136                 else
    137                 {
    138                    strncpy(slogfile, slogfilename, sizeof(slogfile) -1);
    139                 }
    140 
    141                 // init samba for debug messages
    142                 setup_logging(slogfile, false);
    143                 lp_set_logfile(slogfile);
    144                 debug_parse_levels("10");
     127        char slogfile[_MAX_PATH +1] = {0};
     128        char slogfilename[] = "log.smbc";
     129        char *env = getenv("LOGFILES");
     130                if (env != NULL)
     131                {
     132                   strncpy(slogfile, env, sizeof(slogfile) -1);
     133                   strncat(slogfile, "\\", sizeof(slogfile) - strlen(slogfile) -1);
     134                   strncat(slogfile, slogfilename, sizeof(slogfile) - strlen(slogfile) -1);
     135                }
     136                else
     137                {
     138                   strncpy(slogfile, slogfilename, sizeof(slogfile) -1);
     139                }
     140
     141                // init samba for debug messages
     142                setup_logging(slogfile, false);
     143                lp_set_logfile(slogfile);
     144                debug_parse_levels("10");
    145145
    146146}
    147147const char * smbwrp_getVersion()
    148148{
    149         return samba_version_string();
     149        return samba_version_string();
    150150}
    151151
     
    169169        initialised = 1;
    170170
    171         lp_set_in_client(true); /* Make sure that we tell lp_load we are client */
     171        lp_set_in_client(true); /* Make sure that we tell lp_load we are client */
    172172
    173173        load_case_tables();
     
    184184        }
    185185
    186         if (writeLog())
    187         {
    188                 smbwrp_Logging();
    189         }
     186        if (writeLog())
     187        {
     188                smbwrp_Logging();
     189        }
    190190
    191191/*
     
    200200void smbwrp_initthread(void)
    201201{
    202         /*
    203         * Block SIGPIPE (from lib/util_sock.c: write())
    204         * It is not needed and should not stop execution
    205         */
    206         BlockSignals(True, SIGPIPE);
     202        /*
     203        * Block SIGPIPE (from lib/util_sock.c: write())
     204        * It is not needed and should not stop execution
     205        */
     206        BlockSignals(True, SIGPIPE);
    207207}
    208208
     
    313313        uint16 setup = TRANSACT2_QPATHINFO;
    314314        char *param;
    315         size_t nlen = 2*(strlen(fname)+1);
     315        size_t nlen = 2*(strlen(fname)+1);
    316316        char *rparam=NULL, *rdata=NULL;
    317317        char *p;
    318        
    319         param = SMB_MALLOC_ARRAY(char, 6+nlen+2);
    320         if (!param) {
     318       
     319        param = SMB_MALLOC_ARRAY(char, 6+nlen+2);
     320        if (!param) {
    321321                return false;
    322322        }
     
    331331
    332332        if (!cli_send_trans(cli, SMBtrans2,
    333                             NULL,                        /* name */
    334                             -1, 0,                        /* fid, flags */
    335                             &setup, 1, 0,                /* setup, length, max */
    336                             param, param_len, 10,        /* param, length, max */
    337                             NULL, data_len, cli->max_xmit /* data, length, max */
    338                            )) {
     333                            NULL,                        /* name */
     334                            -1, 0,                      /* fid, flags */
     335                            &setup, 1, 0,                /* setup, length, max */
     336                            param, param_len, 10,        /* param, length, max */
     337                            NULL, data_len, cli->max_xmit /* data, length, max */
     338                           )) {
    339339                return False;
    340340        }
    341341
    342         SAFE_FREE(param);
     342        SAFE_FREE(param);
    343343        if (!cli_receive_trans(cli, SMBtrans2,
    344                                &rparam, &param_len,
    345                                &rdata, &data_len)) {
     344                               &rparam, &param_len,
     345                               &rdata, &data_len)) {
    346346                return False;
    347347        }
     
    402402
    403403        if (!cli_send_trans(cli, SMBtrans2,
    404                             NULL,                           /* name */
    405                             -1, 0,                          /* fid, flags */
    406                             &setup, 1, 0,                   /* setup, length, max */
    407                             param, param_len, 2,            /* param, length, max */
    408                             NULL, data_len, cli->max_xmit   /* data, length, max */
    409                            )) {
     404                            NULL,                          /* name */
     405                            -1, 0,                        /* fid, flags */
     406                            &setup, 1, 0,                  /* setup, length, max */
     407                            param, param_len, 2,            /* param, length, max */
     408                            NULL, data_len, cli->max_xmit   /* data, length, max */
     409                           )) {
    410410                return False;
    411411        }
    412412
    413413        if (!cli_receive_trans(cli, SMBtrans2,
    414                                &rparam, &param_len,
    415                                &rdata, &data_len)) {
     414                               &rparam, &param_len,
     415                               &rdata, &data_len)) {
    416416                return False;
    417417        }
     
    465465        char* dev_type;
    466466        int loginerror = 0;
    467         NTSTATUS status;
     467        NTSTATUS status;
    468468
    469469        zero_sockaddr(&ss);
     
    504504
    505505 again:
    506         zero_sockaddr(&ss);
     506        zero_sockaddr(&ss);
    507507
    508508        /* have to open a new connection */
     
    556556                        return 6;
    557557                }
    558                 debuglocal(4,"Anonymous login successful\n");
     558                debuglocal(4,"Anonymous login successful\n");
    559559                status = cli_init_creds(c, "", lp_workgroup(), "");
    560560        } else {
     
    634634                return os2cli_errno(cli);
    635635        }
    636         file->fd = fd;
    637         if (file->openmode & (O_WRONLY | O_RDWR | O_TRUNC | O_CREAT))
    638         {
    639                 time_t t;
    640                 file->mtime = time(NULL);
    641 #if 0 // as time() delivers elapsed time in epoch we already have UTC
    642                 t = get_time_zone(file->mtime);
    643                 debuglocal(4,"cli_open mtime %lu %lu\n", file->mtime, t);
    644                 file->mtime -= t;
    645 #endif
    646                 debuglocal(4,"cli_open new mtime %lu\n", file->mtime);
    647         }
     636        file->fd = fd;
     637        file->newmtime = 0;
    648638        file->offset = 0;
    649639        return 0;
     
    696686        }
    697687
     688        file->newmtime = 1;
    698689        file->offset += ret;
    699690        *result = ret;
     
    717708                return os2cli_errno(cli);
    718709        }
     710        if (file->newmtime)
     711        {
     712                file->newmtime = 0;
     713                file->mtime = time(NULL);
     714                debuglocal(4,"cli_close new mtime %lu\n", file->mtime);
     715        }
    719716        file->fd = -1;
    720717        file->offset = 0;
     
    726723                        debuglocal(4,"Set attr on close failed %d\n", os2cli_errno(cli));
    727724                        //rc = os2cli_errno(cli);
    728                 }       
     725                }
     726               
    729727                file->openattr = 0;
    730728                file->mtime = 0;
     
    743741        uint16 setup = TRANSACT2_SETFILEINFO;
    744742        char param[6];
    745         unsigned char data[8];
     743        unsigned char data[8];
    746744        char *rparam=NULL, *rdata=NULL;
    747745
    748746        SSVAL(param,0,fnum);
    749747        SSVAL(param,2,SMB_SET_FILE_END_OF_FILE_INFO);
    750         SSVAL(param,4,0);
    751 
    752         SBVAL(data, 0, newsize);
     748        SSVAL(param,4,0);
     749
     750        SBVAL(data, 0, newsize);
    753751
    754752        if (!cli_send_trans(cli, SMBtrans2,
    755                                                 NULL,                        /* name */
    756                                                 -1, 0,                          /* fid, flags */
    757                                                 &setup, 1, 0,                   /* setup, length, max */
    758                                                 param, param_len, 2,            /* param, length, max */
    759                                                 (char *)&data,  data_len,        /* data, length */
    760                                                 cli->max_xmit /* max */
     753                                                NULL,                   /* name */
     754                                                -1, 0,                    /* fid, flags */
     755                                                &setup, 1, 0,              /* setup, length, max */
     756                                                param, param_len, 2,        /* param, length, max */
     757                                                (char *)&data,  data_len,       /* data, length */
     758                                                cli->max_xmit /* max */
    761759                                                )) {
    762760                return False;
     
    795793                        return os2cli_errno(cli);
    796794                }
    797                 uint16_t fd = 0;
     795                uint16_t fd = 0;
    798796                file->fd = -1;
    799797                file->offset = 0;                       
     
    805803                        return os2cli_errno(cli);
    806804                }
    807                 file->fd = fd;
     805                file->fd = fd;
    808806        }       
    809807        return 0;
     
    842840
    843841debuglocal(4,"Setting on <%s> attr %04x, time %lu (timezone /%lu\n", finfo->fname, finfo->attr, finfo->mtime, finfo->mtime + get_time_zone(finfo->mtime));
    844         // we already have gmt time, so no need to add timezone
     842        // we already have gmt time, so no need to add timezone
    845843        // if (!cli_setatr(cli, finfo->fname, finfo->attr, finfo->mtime + (finfo->mtime == 0 ? 0 : get_time_zone(finfo->mtime)))
    846844        if (!NT_STATUS_IS_OK(cli_setatr(cli, finfo->fname, finfo->attr, finfo->mtime))
     
    952950//debuglocal(2,("getattr rc1 %d\n", os2cli_errno(cli)));
    953951
    954         if (cli->fd == -1)
    955         {
    956            /* fd == -1 means the connection is broken */
    957            return maperror(ENOTCONN);
    958         }
    959 
    960         /* If the path is not on a share (it is a workgroup or a server),
    961         * then cli_qpathinfo3 obviously fails. Return some fake information
    962         * about the directory.
    963         */
    964         if (   *srv->server_name == 0
    965             || (strcmp(cli->dev,"IPC") == 0)
    966             || *srv->share_name == 0
    967             || (stricmp(srv->share_name,"IPC$") == 0)
    968             || (strncmp(cli->dev,"LPT",3) == 0)
     952        if (cli->fd == -1)
     953        {
     954           /* fd == -1 means the connection is broken */
     955           return maperror(ENOTCONN);
     956        }
     957
     958        /* If the path is not on a share (it is a workgroup or a server),
     959        * then cli_qpathinfo3 obviously fails. Return some fake information
     960        * about the directory.
     961        */
     962        if (   *srv->server_name == 0
     963            || (strcmp(cli->dev,"IPC") == 0)
     964            || *srv->share_name == 0
     965            || (stricmp(srv->share_name,"IPC$") == 0)
     966            || (strncmp(cli->dev,"LPT",3) == 0)
    969967           )
    970968        {
    971             debuglocal(4,"getattr not a share.\n");
    972             *(time_t *)&finfo->ctime = time (NULL);
    973             *(time_t *)&finfo->atime = time (NULL);
    974             *(time_t *)&finfo->mtime = time (NULL);
    975             finfo->size = 0;
    976             finfo->easize = 0;
    977             finfo->attr = aDIR;
    978             return 0;
    979         }
     969            debuglocal(4,"getattr not a share.\n");
     970            *(time_t *)&finfo->ctime = time (NULL);
     971            *(time_t *)&finfo->atime = time (NULL);
     972            *(time_t *)&finfo->mtime = time (NULL);
     973            finfo->size = 0;
     974            finfo->easize = 0;
     975            finfo->attr = aDIR;
     976            return 0;
     977        }
    980978       
    981979        /* if this is NT then don't bother with the getatr */
     
    10451043
    10461044// =============================DIRECTORY ROUTINES============================
    1047                                                                                                                
     1045                                                                                                               
    10481046/*****************************************************
    10491047add a entry to a directory listing
     
    11291127        const char *base = p;
    11301128        size_t ret;
    1131         char *fname;
     1129        char *fname;
    11321130       
    11331131        data_blob_free(p_last_name_raw);
     
    11381136
    11391137/*      ZERO_STRUCTP(finfo); */
    1140         finfo->atime = 0;
    1141         finfo->ctime = 0;
    1142         finfo->mtime = 0;
    1143         *finfo->fname = '\0';
     1138        finfo->atime = 0;
     1139        finfo->ctime = 0;
     1140        finfo->mtime = 0;
     1141        *finfo->fname = '\0';
    11441142       
    11451143        switch (level) {
    11461144                case SMB_FIND_INFO_STANDARD: /* OS/2 understands this */
    11471145                        /* these dates are converted to GMT by
    1148                            make_unix_date */
     1146                           make_unix_date */
    11491147                        if (pdata_end - base < 27) {
    11501148                                return pdata_end - base;
     
    11851183                        p += ret;
    11861184                        finfo->easize = -1;
    1187                         strncat(finfo->fname, fname, sizeof(finfo->fname) -1);
     1185                        strncat(finfo->fname, fname, sizeof(finfo->fname) -1);
    11881186                        return PTR_DIFF(p, base);
    11891187
    11901188                case SMB_FIND_EA_SIZE: /* this is what OS/2 uses mostly */
    11911189                        /* these dates are converted to GMT by
    1192                            make_unix_date */
     1190                           make_unix_date */
    11931191                        if (pdata_end - base < 31) {
    11941192                                return pdata_end - base;
     
    12131211                        }
    12141212                        p += ret;
    1215                         strncat(finfo->fname, fname, sizeof(finfo->fname) -1);
     1213                        strncat(finfo->fname, fname, sizeof(finfo->fname) -1);
    12161214                        return PTR_DIFF(p, base) + 1;
    12171215                       
     
    12741272                                return pdata_end - base;
    12751273                        }
    1276                         strncat(finfo->fname, fname, sizeof(finfo->fname) -1);
     1274                        strncat(finfo->fname, fname, sizeof(finfo->fname) -1);
    12771275
    12781276                        /* To be robust in the face of unicode conversion failures
     
    13301328
    13311329        /* NT uses SMB_FIND_FILE_BOTH_DIRECTORY_INFO,
    1332         OS/2 uses SMB_FIND_EA_SIZE. Both accept SMB_FIND_INFO_STANDARD. */
     1330        OS/2 uses SMB_FIND_EA_SIZE. Both accept SMB_FIND_INFO_STANDARD. */
    13331331        info_level = (cli->capabilities&CAP_NT_SMBS)?
    1334            SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_EA_SIZE;
     1332           SMB_FIND_FILE_BOTH_DIRECTORY_INFO : SMB_FIND_EA_SIZE;
    13351333       
    13361334        debuglocal(4,"list_files level %d. mask <%s>\n", info_level, Mask);
    13371335   
    13381336        mask = SMB_STRDUP(Mask);
    1339         if (!mask) {
    1340                 TALLOC_FREE(frame);
    1341                 return -1;
    1342         }
     1337        if (!mask) {
     1338                TALLOC_FREE(frame);
     1339                return -1;
     1340        }
    13431341
    13441342        /* Try to get the listing from cache. */
     
    13501348
    13511349        while (ff_eos == 0) {
    1352                 size_t nlen = 2*(strlen(mask)+1);
     1350                size_t nlen = 2*(strlen(mask)+1);
    13531351
    13541352                loop_count++;
     
    13581356                }
    13591357
    1360                 param = SMB_MALLOC_ARRAY(char, 12+nlen+last_name_raw.length+2);
     1358                param = SMB_MALLOC_ARRAY(char, 12+nlen+last_name_raw.length+2);
    13611359                if (!param) {
    13621360                        break;
     
    13901388                        } else {
    13911389                                p += clistr_push(cli, param+12, mask,
    1392                                               nlen, STR_TERMINATE);
     1390                                              nlen, STR_TERMINATE);
    13931391                        }
    13941392                }
     
    13971395
    13981396                if (!cli_send_trans(cli, SMBtrans2,
    1399                                     NULL,                   /* Name */
    1400                                     -1, 0,                  /* fid, flags */
    1401                                     &setup, 1, 0,           /* setup, length, max */
     1397                                    NULL,                  /* Name */
     1398                                    -1, 0,                /* fid, flags */
     1399                                    &setup, 1, 0,          /* setup, length, max */
    14021400                                    param, param_len, 10,   /* param, length, max */
    14031401                                    NULL, 0,
     
    14091407#endif
    14101408                                    )) {
    1411                         SAFE_FREE(param);
    1412                         TALLOC_FREE(frame);
     1409                        SAFE_FREE(param);
     1410                        TALLOC_FREE(frame);
    14131411                        break;
    14141412                }
    14151413
    1416                 SAFE_FREE(param);
     1414                SAFE_FREE(param);
    14171415
    14181416                if (!cli_receive_trans(cli, SMBtrans2,
    14191417                                       &rparam, &param_len,
    14201418                                       &rdata, &data_len) &&
    1421                     cli_is_dos_error(cli)) {
     1419                    cli_is_dos_error(cli)) {
    14221420                        /* we need to work around a Win95 bug - sometimes
    14231421                           it gives ERRSRV/ERRerror temprarily */
     
    14491447                }
    14501448
    1451                 if (cli_is_error(cli) || !rdata || !rparam)
     1449                if (cli_is_error(cli) || !rdata || !rparam)
    14521450                {
    14531451                        if (First && info_level == SMB_FIND_EA_SIZE)
     
    14861484                /* point to the data bytes */
    14871485                p = rdata;
    1488                 rdata_end = rdata + data_len;
     1486                rdata_end = rdata + data_len;
    14891487
    14901488                memset(&finfo, 0, sizeof(finfo));
     
    14931491                for (p2=p,i=0;i<ff_searchcount  && p2 < rdata_end;i++) {
    14941492                        if ((info_level == SMB_FIND_FILE_BOTH_DIRECTORY_INFO) &&
    1495                                         (i == ff_searchcount-1)) {
     1493                                        (i == ff_searchcount-1)) {
    14961494                                /* Last entry - fixup the last offset length. */
    14971495                                SIVAL(p2,0,PTR_DIFF((rdata + data_len),p2));
     
    15001498                                                        &resume_key, &last_name_raw);
    15011499
    1502                         if (!finfo.fname) {
     1500                        if (!finfo.fname) {
    15031501                                debuglocal(0,"Error: unable to parse name from info level %d\n",
    15041502                                        info_level);
    15051503                                ff_eos = 1;
    15061504                                break;
    1507                         }
     1505                        }
    15081506
    15091507                        if (!First && *mask && strcsequal(finfo.fname, mask)) {
     
    15151513                }
    15161514
    1517                 SAFE_FREE(mask);
     1515                SAFE_FREE(mask);
    15181516                if (ff_searchcount > 0 && ff_eos == 0 && finfo.fname) {
    15191517                        mask = SMB_STRDUP(finfo.fname);
     
    15211519                        mask = SMB_STRDUP("");
    15221520                }
    1523                 if (!mask) {
     1521                if (!mask) {
    15241522                        SAFE_FREE(rdata);
    15251523                        SAFE_FREE(rparam);
     
    15551553        }
    15561554
    1557         /* see if the server disconnected or the connection otherwise failed */
    1558         if (cli_is_error(cli)) {
    1559                 total_received = -1;
    1560         } else {
    1561                 void *dircachectx = dircache_write_begin(state, total_received);
    1562 
    1563                 /* no connection problem.  let user function add each entry */
    1564                 rdata_end = dirlist + dirlist_len;
    1565                 for (p=dirlist,i=0;i<total_received;i++) {
    1566                         p += _os2_interpret_long_filename(frame, cli, info_level, p, rdata_end,
    1567                                                      &finfo,NULL,NULL);
     1555        /* see if the server disconnected or the connection otherwise failed */
     1556        if (cli_is_error(cli)) {
     1557                total_received = -1;
     1558        } else {
     1559                void *dircachectx = dircache_write_begin(state, total_received);
     1560
     1561                /* no connection problem.  let user function add each entry */
     1562                rdata_end = dirlist + dirlist_len;
     1563                for (p=dirlist,i=0;i<total_received;i++) {
     1564                        p += _os2_interpret_long_filename(frame, cli, info_level, p, rdata_end,
     1565                                                     &finfo,NULL,NULL);
    15681566
    15691567                        if (!finfo.fname) {
     
    15711569                                        info_level);
    15721570                                break;
    1573                         }
    1574                         fn(cli->dfs_mountpoint,&finfo, Mask, state );
    1575 
    1576                         /* Also add the entry to the cache. */
    1577                         dircache_write_entry(dircachectx, &finfo);
    1578                 }
     1571                        }
     1572                        fn(cli->dfs_mountpoint,&finfo, Mask, state );
     1573
     1574                        /* Also add the entry to the cache. */
     1575                        dircache_write_entry(dircachectx, &finfo);
     1576                }
    15791577
    15801578                dircache_write_end(dircachectx);
    15811579
    1582         }
     1580        }
    15831581
    15841582        /* free up the dirlist buffer and last name raw blob */
    15851583        SAFE_FREE(dirlist);
    1586         data_blob_free(&last_name_raw);
    1587         SAFE_FREE(mask);
    1588         TALLOC_FREE(frame);
     1584        data_blob_free(&last_name_raw);
     1585        SAFE_FREE(mask);
     1586        TALLOC_FREE(frame);
    15891587        return(total_received);
    15901588}
     
    16211619                smbwrp_special_add("..", state);
    16221620
    1623                 if (net_share_enum_rpc(cli, smbwrp_share_add, state) < 0 &&
    1624                             cli_RNetShareEnum(cli,smbwrp_share_add, state) < 0)
     1621                if (net_share_enum_rpc(cli, smbwrp_share_add, state) < 0 &&
     1622                            cli_RNetShareEnum(cli,smbwrp_share_add, state) < 0)
    16251623                {
    16261624                        return os2cli_errno(cli);
     
    16511649                             smbwrp_dir_add, state) < 0)
    16521650#endif
    1653                 {                                                                             
     1651                {                                                                            
    16541652                        return os2cli_errno(cli);
    16551653                }
    1656         }                                                                                                                                               
     1654        }                                                                                                                                               
    16571655
    16581656        return 0;
     
    17531751
    17541752#pragma pack(1)
    1755 typedef struct _FEA        /* fea */
    1756 {
    1757          unsigned char fEA;           /* flags                              */
    1758          unsigned char cbName;        /* name length not including NULL */
    1759         unsigned short cbValue;     /* value length */
     1753typedef struct _FEA      /* fea */
     1754{
     1755         unsigned char fEA;        /* flags                           */
     1756         unsigned char cbName;  /* name length not including NULL */
     1757        unsigned short cbValue;     /* value length */
    17601758} FEA;
    17611759
     
    17631761{
    17641762        unsigned long cbList;       /* total bytes of structure including full list */
    1765         FEA list[1];        /* variable length FEA structures */
     1763        FEA list[1];    /* variable length FEA structures */
    17661764} FEALIST;
    17671765#pragma pack()
  • TabularUnified trunk/client/src/smbwrp.h

    r521 r808  
    9191        int denymode;
    9292        unsigned long mtime;
     93        int newmtime;
    9394        char fullname[261];
    9495        char fname[261];
Note: See TracChangeset for help on using the changeset viewer.