Changeset 817


Ignore:
Timestamp:
Sep 27, 2013, 1:55:10 PM (12 years ago)
Author:
Silvan Scherrer
Message:

Samba Client 2.1: timestamp work and some backport from 2.2 client

Location:
branches/client-2.1/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/client-2.1/src/BuildAll.cmd

    r401 r817  
    55kmk BUILD_TYPE=release
    66
     7kmk BUILD_TYPE=debug install
     8kmk BUILD_TYPE=release install
     9
    710kmk BUILD_TYPE=debug packing
    811kmk BUILD_TYPE=release packing
  • branches/client-2.1/src/Makefile.kmk

    r799 r817  
    9292                | $(SED) "s;_WPIVERSION_;$(subst .,\\\,$(VERSION));g" \
    9393                | $(SED) "s;_BUILD_;$(BUILD);g" \
     94                | $(SED) "s;_VENDOR_;$(VENDOR);g" \
    9495                > rc/rc.rc
    9596
     
    132133                | $(SED) "s;_WPIVERSION_;$(subst .,\\\,$(VERSION));g" \
    133134                | $(SED) "s;_BUILD_;$(BUILD);g" \
     135                | $(SED) "s;_VENDOR_;$(VENDOR);g" \
    134136                > nversion.h
    135137
  • branches/client-2.1/src/debug.c

    r533 r817  
    138138                {
    139139                   fprintf(f, "Samba client %s build %s based on %s\n", VERSION, BUILD, smbwrp_getVersion());
     140                   fprintf(f, "This build is maintained by %s\n", VENDOR);
    140141                   firstLogLine = FALSE;
    141142                }
  • branches/client-2.1/src/ndpsmb.c

    r816 r817  
    104104        {ND_PROP_STRING, 0, "USER", "guest"},
    105105        {ND_PROP_STRING, 0, "PASSWORD", ""},
    106                 {ND_PROP_STRING, 0, "SPASSWORD",  ""},
     106        {ND_PROP_STRING, 0, "SPASSWORD",  ""},
    107107        {ND_PROP_STRING, 0, "MASTER", "WORKGROUP"},
    108108        {ND_PROP_ULONG, 0, "MASTERTYPE", "1"},
    109                 {ND_PROP_ULONG, 0, "CTO", "10"},
    110                 {ND_PROP_ULONG, 0, "CLD", "32"},
     109        {ND_PROP_ULONG, 0, "CTO", "10"},
     110        {ND_PROP_ULONG, 0, "CLD", "32"},
    111111        {ND_PROP_ULONG, 0, "EASUPPORT", "1"},
    112112        {ND_PROP_STRING, 0, NULL, NULL}
     
    126126/* A mutex to serialize plugin calls because libsmb may not be thread safe. */
    127127static NDMUTEX mutex;
    128                
     128
    129129static int lockInit (void)
    130130{
    131131        return ph->fsphCreateMutex (&mutex);
    132132}
    133                
     133
    134134static void lockClose (void)
    135135{
    136136        ph->fsphCloseMutex (mutex);
    137137}
    138                
     138
    139139static int lockRequest (void)
    140140{
     
    150150
    151151#define ENTER() do {                    \
    152         int rcLock = lockRequest(); \
    153         if (rcLock != NO_ERROR)  \
    154                 return rcLock;            \
     152        int rcLock = lockRequest();     \
     153        if (rcLock != NO_ERROR)         \
     154                return rcLock;          \
    155155} while (0)
    156156
    157 #define LEAVE() do { \
     157#define LEAVE() do {    \
    158158        lockRelease();  \
    159159} while (0)
     
    181181                ifL = 1;
    182182        }
    183                 lockInit();
    184                 debugInit();
     183        lockInit();
     184        debugInit();
    185185        debuglocal(9,"Working with %s bit fileio NDFS\n", ifL ? "64" : "32");
    186186        return NO_ERROR;
     
    190190int APIENTRY NdpPluginFree (void)
    191191{
    192                 debugDelete();
    193                 lockClose();
     192        debugDelete();
     193        lockClose();
    194194        return NO_ERROR;
    195195}
     
    218218        stat->attrFile = (finfo->attr & 0x37);
    219219
    220                 fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
    221                 fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
    222                 fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
     220        fsphUnixTimeToDosDate(finfo->mtime, &stat->fdateLastWrite, &stat->ftimeLastWrite);
     221        fsphUnixTimeToDosDate(finfo->ctime, &stat->fdateCreation, &stat->ftimeCreation);
     222        fsphUnixTimeToDosDate(finfo->atime, &stat->fdateLastAccess, &stat->ftimeLastAccess);
    223223}
    224224
     
    248248        stat.attrFile = (finfo->attr & 0x37);
    249249
    250                 fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
    251                 fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
    252                 fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
     250        fsphUnixTimeToDosDate(finfo->mtime, &stat.fdateLastWrite, &stat.ftimeLastWrite);
     251        fsphUnixTimeToDosDate(finfo->ctime, &stat.fdateCreation, &stat.ftimeCreation);
     252        fsphUnixTimeToDosDate(finfo->atime, &stat.fdateLastAccess, &stat.ftimeLastAccess);
    253253        debug_printf( "fname %s\n", finfo->fname);
    254254        debug_printf( "mtime %d %s", finfo->mtime, ctime( (time_t*)&finfo->mtime));
     
    263263        if ('0' <= c && c <= '9')
    264264        {
    265                  return c - '0';
    266         }
    267        
     265                return c - '0';
     266        }
     267
    268268        if ('A' <= c && c <= 'F')
    269269        {
    270                  return c - 'A' + 0xA;
    271         }
    272        
     270                return c - 'A' + 0xA;
     271        }
     272
    273273        if ('a' <= c && c <= 'f')
    274274        {
    275                  return c - 'a' + 0xA;
    276         }
    277        
     275                return c - 'a' + 0xA;
     276        }
     277
    278278        return 0;
    279279}
     
    282282{
    283283        b &= 0xF;
    284        
     284
    285285        if (b <= 9)
    286286        {
    287287                return b + '0';
    288288        }
    289        
     289
    290290        return 'A' + (b - 0xA);
    291291}
     
    296296        const char *s = pszCrypt;
    297297        char *d = pszPlain;
    298        
     298
    299299        while (*s)
    300300        {
    301301                *d++ = (char)((fromhex (*s++) << 4) + fromhex (*s++));
    302302        }
    303        
     303
    304304        *d++ = 0;
    305305}
     
    310310        const char *s = pszPlain;
    311311        char *d = pszCrypt;
    312        
     312
    313313        while (*s)
    314314        {
     
    317317                s++;
    318318        }
    319        
     319
    320320        *d++ = 0;
    321321}
     
    338338        pRes->krb5support = 0;
    339339#endif
    340                 pRes->pdc = NULL;
     340        pRes->pdc = NULL;
    341341
    342342        t = 0, q = NULL;
     
    380380
    381381        t = 0, q = NULL;
    382                 rc = ph->fsphQueryStringProperty (properties, "SPASSWORD", &q, &t);
    383                 if (   rc == NO_ERROR
    384                         && *q != '\0'
    385                         && defaultPassword)
    386                 {
    387                         char p[1024];
    388                         p[0] = 0;
    389                
    390                         decryptPassword (q, p);
    391                
    392                         if (*p)
    393                         {
    394                 strncpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1);
    395                
    396                                 /* clear the plain password */
    397                                 ph->fsphSetProperty (properties, "PASSWORD", "");
    398                         }
    399                 }
    400                 else
    401                 {
    402                         char c[1024];
    403                         encryptPassword (pRes->srv.password, c);
    404                
    405                         ph->fsphSetProperty (properties, "SPASSWORD", c);
    406                
    407                         // clear the plain password
     382        rc = ph->fsphQueryStringProperty (properties, "SPASSWORD", &q, &t);
     383        if (   rc == NO_ERROR && *q != '\0' && defaultPassword)
     384        {
     385                char p[1024];
     386                p[0] = 0;
     387
     388                decryptPassword (q, p);
     389
     390                if (*p)
     391                {
     392                        strncpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1);
     393
     394                        /* clear the plain password */
    408395                        ph->fsphSetProperty (properties, "PASSWORD", "");
    409396                }
     397        }
     398        else
     399        {
     400                char c[1024];
     401                encryptPassword (pRes->srv.password, c);
     402
     403                ph->fsphSetProperty (properties, "SPASSWORD", c);
     404
     405                // clear the plain password
     406                ph->fsphSetProperty (properties, "PASSWORD", "");
     407        }
    410408
    411409        t = 0, q = NULL;
     
    473471
    474472        /*
    475                 * Create a directory cache with expiration time and cache listings
    476                 * the above values come from the gui. default: timeout 10; listings: 32
    477                 */
     473        * Create a directory cache with expiration time and cache listings
     474        * the above values come from the gui. default: timeout 10; listings: 32
     475        */
    478476        dircache_create(&pRes->pdc, pRes->cachetimeout, pRes->cachedepth);
    479477
     
    580578                if (newlevel)
    581579                {
    582                                 // reconnect to server here, first test new connection
     580                        // reconnect to server here, first test new connection
    583581                        cli_state* tmp_cli = NULL;
    584582                        rc = smbwrp_connect( &tmpRes, &tmp_cli);
     
    918916/*
    919917 * NdpQueryPathInfo is the most important  function :) netdrive always calls
    920  * the function before every operation to find out the path status: does it exist, is it a file, does a
    921  * parent directory exist, etc.
     918 * the function before every operation to find out the path status:
     919 * does it exist, is it a file, does a parent directory exist, etc.
    922920 * Plugin must return one of the following error codes:
    923  * NO_ERROR - path exists and the path information have been successfully retrieved.
     921 * NO_ERROR - path exists and the path information have been successfully
     922 *      retrieved.
    924923 * ERROR_FILE_NOT_FOUND - all but the last component of the path exist and the
    925  *      path without the last component is a directory. dir1_ok\dir2_ok\does_not_exist.
    926  *      the wildcard can not exist, so the plugin returns FILE_NOT_FOUND, if the parent
    927  *      directory exist.
     924 *      path without the last component is a directory. dir1_ok\dir2_ok\does_not_exist.
     925 *      the wildcard can not exist, so the plugin returns FILE_NOT_FOUND, if the parent
     926 *      directory exist.
    928927 * ERROR_PATH_NOT_FOUND - any of not last path components does not exist, or all
    929  *      but the last component exist and is a file: \dir_ok\dir2_ok\file_ok\non_existing.
     928 *      but the last component exist and is a file: \dir_ok\dir2_ok\file_ok\non_existing.
    930929 * ERROR_REM_NOT_LIST - resource is temporarily unavailable for some reasons.
    931930 * Any other error codes means an internal plugin error, not related to the status
     
    10021001                                        rcCon = smbwrp_connect( pRes, &pConn->cli);
    10031002                                        if (rcCon != NO_ERROR)
    1004                                         debuglocal(9,"NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
     1003                                                debuglocal(9,"NdpQueryPathInfo smbwrp_connect rc = %d\n", rcCon);
    10051004
    10061005                                        // try file list again if reconnecting worked
    10071006                                        if (rcCon == NO_ERROR)
    1008                                         rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
     1007                                                rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
    10091008                                }
    10101009                                debuglocal(9,"NdpQueryPathInfo smbwrp_getattr, rc = %d\n", rc);
     
    10371036                                        *p = 0;
    10381037                                        rc = smbwrp_getattr( &pRes->srv, pConn->cli, &finfo);
    1039                                                                                 debuglocal(9,"NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
     1038                                        debuglocal(9,"NdpQueryPathInfo upper path in <%s>, rc = %d\n",  finfo.fname, rc);
    10401039                                        if (rc == NO_ERROR)
    10411040                                        {       
    10421041                                                rc = (finfo.attr & FILE_DIRECTORY) !=0 ?
    1043                                                                                                 ERROR_FILE_NOT_FOUND:
    1044                                                                                                 ERROR_PATH_NOT_FOUND;
     1042                                                ERROR_FILE_NOT_FOUND:ERROR_PATH_NOT_FOUND;
    10451043                                        }
    1046                                                                                 else if (rc != ERROR_REM_NOT_LIST)
    1047                                                                                 {
    1048                                                                                           rc = ERROR_PATH_NOT_FOUND;
     1044                                        else if (rc != ERROR_REM_NOT_LIST)
     1045                                        {
     1046                                                rc = ERROR_PATH_NOT_FOUND;
    10491047                                        }
    10501048                                }
     
    11331131                }
    11341132                debuglocal(9,"NdpFindStart: dir [%s], dir_mask [%s], mask [%s], szPath [%s]\n",
    1135                                                    state.dir, state.dir_mask, state.mask, state.fullpath);
     1133                        state.dir, state.dir_mask, state.mask, state.fullpath);
    11361134                rc = smbwrp_filelist( &pRes->srv, pConn->cli, &state);
    11371135                // we need to handle reconnection also here, because NdpQueryPathInfo
     
    11901188        debug_printf("NdpSetPathInfo in [%p]\n", pConn);
    11911189
    1192                 // delete the dir cache
     1190        // delete the dir cache
    11931191        dircache_invalidate(szPathName, pRes->pdc, 1);
    11941192
     
    13061304        debuglocal(9,"NdpEAQuery in [%p] <%s> %08x %d\n", pConn, path, pGEAList, pGEAList ? pGEAList->cbList : 0);
    13071305
    1308                 char *pchBuffer = (char *)malloc(cbBuffer);
    1309                 if (!pchBuffer)
    1310                 {
    1311                                 LEAVE();
    1312                                 return ERROR_NOT_ENOUGH_MEMORY;
    1313                 }
     1306        char *pchBuffer = (char *)malloc(cbBuffer);
     1307        if (!pchBuffer)
     1308        {
     1309                LEAVE();
     1310                return ERROR_NOT_ENOUGH_MEMORY;
     1311        }
    13141312
    13151313        do {
     
    13421340                }
    13431341        } while (0);
    1344                 free(pchBuffer);
     1342        free(pchBuffer);
    13451343        debuglocal(9,"NdpEAQuery <%s> %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList);
    13461344        LEAVE();
     
    14231421                return ERROR_EAS_NOT_SUPPORTED;
    14241422        }
    1425                
    1426                 debuglocal(9, "remove me NdpEASize before fsphGetFileInfoData\n");
     1423
    14271424        rc = ph->fsphGetFileInfoData(pfi, &fdata, 0);
    14281425        if (rc || !fdata.ulSize || !fdata.pData)
     
    14341431        ENTER();
    14351432
    1436                 debuglocal(9, "remove me NdpEASize before finfo =\n");
    14371433        finfo = (smbwrp_fileinfo *)fdata.pData;
    1438                 debuglocal(9, "remove me NdpEASize after finfo=\n");
    14391434        easize = finfo->easize;
    14401435        finfo->easize = -1;
     
    14501445        debuglocal(9,"NdpEASize in [%p] <%s> \n", pConn, path);
    14511446
    1452                 char *pchBuffer = (char *)malloc(cbBuffer);
    1453                 if (!pchBuffer)
    1454                 {
    1455                                 LEAVE();
    1456                                 return ERROR_NOT_ENOUGH_MEMORY;
    1457                 }
     1447        char *pchBuffer = (char *)malloc(cbBuffer);
     1448        if (!pchBuffer)
     1449        {
     1450                LEAVE();
     1451                return ERROR_NOT_ENOUGH_MEMORY;
     1452        }
    14581453
    14591454        do {
     
    14821477                *pulEASize = pfealist->cbList;
    14831478        } while (0);
    1484                 free(pchBuffer);
     1479        free(pchBuffer);
    14851480        debuglocal(9,"NdpEASize <%s> %d %d\n", pfi->pszName, *pulEASize, rc);
    14861481        LEAVE();
     
    17931788{
    17941789        if (function == ND_PL_INIT_THREAD)
    1795            {
    1796                   smbwrp_initthread();
    1797                   debuglocal(9, "NdpIOCTL init thread\n");
    1798                   return NO_ERROR;
    1799            }
     1790        {
     1791                smbwrp_initthread();
     1792                debuglocal(9, "NdpIOCTL init thread\n");
     1793                return NO_ERROR;
     1794        }
    18001795
    18011796        debuglocal(9,"NdpIOCTL <%s> %d\n", path, function);
     
    18031798        if (in && insize > 4096)
    18041799        {
    1805         char out[4096];
    1806         sprintf (out, "SAMBA IOCTL function = %d, parms [%s] insize = %d, *poutlen = %d", function, in, insize, *poutlen);
    1807         *poutlen = strlen(out);
    1808         strcpy (in, out);
    1809         return NO_ERROR;
     1800                char out[4096];
     1801                sprintf (out, "SAMBA IOCTL function = %d, parms [%s] insize = %d, *poutlen = %d", function, in, insize, *poutlen);
     1802                *poutlen = strlen(out);
     1803                strcpy (in, out);
     1804                return NO_ERROR;
    18101805        }
    18111806
     
    18631858        debuglocal(9,"NdpFileEAQuery in [%p] <%s>/%d pGEAList=%08x\n", pConn, pConn->file.fname, pConn->file.fd, pGEAList);
    18641859
    1865                 char *pchBuffer = (char *)malloc(cbBuffer);
    1866                 if (!pchBuffer)
    1867                                 return ERROR_NOT_ENOUGH_MEMORY;
     1860        char *pchBuffer = (char *)malloc(cbBuffer);
     1861        if (!pchBuffer)
     1862                return ERROR_NOT_ENOUGH_MEMORY;
    18681863
    18691864        ENTER();
     
    19031898                }
    19041899        } while (0);
    1905                 free(pchBuffer);
     1900        free(pchBuffer);
    19061901        debuglocal(9,"NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc);
    19071902        LEAVE();
     
    19781973        debuglocal(9,"NdpFileEASize in [%p] <%s>/%d \n", pConn, pConn->file.fname, pConn->file.fd);
    19791974
    1980                 char *pchBuffer = (char *)malloc(cbBuffer);
    1981                 if (!pchBuffer)
    1982                                 return ERROR_NOT_ENOUGH_MEMORY;
     1975        char *pchBuffer = (char *)malloc(cbBuffer);
     1976        if (!pchBuffer)
     1977                return ERROR_NOT_ENOUGH_MEMORY;
    19831978
    19841979        ENTER();
     
    20142009                *pulEASize = pFEAList->cbList;
    20152010        } while (0);
    2016                 free(pchBuffer);
     2011        free(pchBuffer);
    20172012        debuglocal(9,"NdpFileEASize %d %d\n", *pulEASize, rc);
    20182013        LEAVE();
     
    20312026        debug_printf("NdpFileSetInfo in [%p]\n", pConn);
    20322027
    2033                 // delete the dir cache
     2028        // delete the dir cache
    20342029        dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
    20352030
     
    21822177                while (ulReadCompleted < ulRead)
    21832178                {
    2184                                 ULONG ulActual;
     2179                        ULONG ulActual;
    21852180                        ULONG ulToRead = ulRead - ulReadCompleted;
    21862181                        debuglocal(9,"NdpFileRead completed %d, to read %d\n", ulReadCompleted, ulToRead);
     
    22292224        debuglocal(9,"NdpFileWrite in [%p]\n", pConn);
    22302225
    2231                 /* delete the dir cache
    2232                 this was moved from NdpFileClose() becasue if there are a lot files in the tree all are reread
    2233                 the problem when moved to here is, that last accessed time is not refreshed
    2234                 if this is needed, a new function needs to be done to update only one file in the cache */
     2226        /* delete the dir cache
     2227        this was moved from NdpFileClose() becasue if there are a lot files in the tree all are reread
     2228        the problem when moved to here is, that last accessed time is not refreshed
     2229        if this is needed, a new function needs to be done to update only one file in the cache */
    22352230        dircache_invalidate(pConn->file.fullname, pRes->pdc, 1);
    22362231
  • branches/client-2.1/src/nversion.tpl

    r679 r817  
    33#define __nversion__H
    44
    5 #define NDPSMB_VERSION  _VERSION_
    6 #define NDPSMB_BUILD    _BUILD_
    7 #define NDPSMB_INSTALL  _WPIVERSION_
    8 #define VERSION        "_VERSION_"
    9 #define BUILD          "_BUILD_"
    10 #define OS              eCS (OS/2)
    11 #define ND              NetDrive
     5#define NDPSMB_VERSION  _VERSION_
     6#define NDPSMB_BUILD    _BUILD_
     7#define NDPSMB_INSTALL  _WPIVERSION_
     8#define VERSION         "_VERSION_"
     9#define BUILD           "_BUILD_"
     10#define OS              eCS (OS/2)
     11#define ND              NetDrive
     12#define VENDOR          "_VENDOR_"
    1213
    1314#endif // __nversion__H
  • branches/client-2.1/src/resources/ndpsmb.tpl

    r801 r817  
    113113    =("chkndenv")
    114114    =("ChkREQ LIBC065.DLL Package:netlabs.org\kLIBC\LIBC 0.6 Runtime\0\6\5")
    115     =("ChkREQ GCC442.DLL Package:netlabs.org\GCC4\Core\1\2\0")
     115    =("ChkREQ GCC446.DLL Package:netlabs.org\GCC4\Core\1\2\0")
    116116    =("ChkREQ STDCPP.DLL Package:netlabs.org\GCC4\Core\1\2\1")
    117117    TITLE="Samba Client Plugin for Netdrive and EVFS"
  • branches/client-2.1/src/smbwrp.c

    r816 r817  
    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        }
     
    503503
    504504 again:
    505         zero_sockaddr(&ss);
     505        zero_sockaddr(&ss);
    506506
    507507        /* have to open a new connection */
     
    695695                debuglocal(4,"cli_close new mtime %lu\n", file->mtime);
    696696        }
    697 
    698         if (file->updatetime == 2 && !cli_setattrE(cli, file->fd, file->ctime, 0, file->mtime))
    699         {
    700                 debuglocal(4,"Set attrE on close failed %d\n", os2cli_errno(cli));
    701         }
    702697       
    703698        if (!cli_close(cli, file->fd))
     
    706701        }
    707702
    708         if (!rc && (file->openattr || file->mtime))
    709         {
    710                 debuglocal(4,"Set attr on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->mtime);
    711                 if (!cli_setatr(cli, file->fname, file->openattr, file->mtime))
    712                 {
    713                         debuglocal(4,"Set attr on close failed %d\n", os2cli_errno(cli));
     703        if (!rc && (file->openattr || file->mtime || file->ctime))
     704        {
     705                debuglocal(4,"Set pathinfo on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->ctime);
     706                if (!cli_setpathinfo(cli, file->fname, file->ctime, 0, file->mtime, 0, file->openattr))
     707                {
     708                        debuglocal(4,"Set pathinfo on close failed %d\n", os2cli_errno(cli));
    714709                        //rc = os2cli_errno(cli);
    715710                }
    716                
    717711        }
    718712
    719713        file->openattr = 0;
    720714        file->mtime = 0;
    721         file->updatetime = 0;           
     715        file->ctime = 0;
     716        file->updatetime = 0;
    722717        file->fd = -1;
    723718        file->offset = 0;
Note: See TracChangeset for help on using the changeset viewer.