Changeset 117

Show
Ignore:
Timestamp:
02/02/08 07:32:39 (10 months ago)
Author:
psmedley
Message:

Update trunk with all ndpsmb changes in 3.0.28 branch

Location:
trunk/samba/source/ndpsmb
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • trunk/samba/source/ndpsmb/ndpsmb.c

    r70 r117  
    150150        {ND_PROP_STRING, 0, "USER", "guest"}, 
    151151        {ND_PROP_STRING, 0, "PASSWORD", ""}, 
     152        {ND_PROP_STRING, 0, "SPASSWORD",  ""}, 
    152153        {ND_PROP_STRING, 0, "MASTER", "WORKGROUP"}, 
    153154        { ND_PROP_ULONG, 0, "MASTERTYPE", "1"}, 
     
    376377} 
    377378 
     379static unsigned char fromhex (char c) 
     380{ 
     381    if ('0' <= c && c <= '9') 
     382    { 
     383         return c - '0'; 
     384    } 
     385     
     386    if ('A' <= c && c <= 'F') 
     387    { 
     388         return c - 'A'; 
     389    } 
     390     
     391    if ('a' <= c && c <= 'f') 
     392    { 
     393         return c - 'a'; 
     394    } 
     395     
     396    return 0; 
     397} 
     398 
     399static char tohex (unsigned char b) 
     400{ 
     401    b &= 0xF; 
     402     
     403    if (b <= 9) 
     404    { 
     405        return b + '0'; 
     406    } 
     407     
     408    return 'A' + (b - 0xA); 
     409} 
     410 
     411static void decryptPassword (const char *pszCrypt, char *pszPlain) 
     412{ 
     413    /* A simple "decryption", character from the hex value. */ 
     414    const char *s = pszCrypt; 
     415    char *d = pszPlain; 
     416     
     417    while (*s) 
     418    { 
     419        *d++ = (char)((fromhex (*s++) << 4) + fromhex (*s++)); 
     420    } 
     421     
     422    *d++ = 0; 
     423} 
     424 
     425static void encryptPassword (const char *pszPlain, char *pszCrypt) 
     426{ 
     427    /* A simple "encryption" encode each character as hex value. */ 
     428    const char *s = pszPlain; 
     429    char *d = pszCrypt; 
     430     
     431    while (*s) 
     432    { 
     433        *d++ = tohex ((*s) >> 4); 
     434        *d++ = tohex (*s); 
     435        s++; 
     436    } 
     437     
     438    *d++ = 0; 
     439} 
    378440 
    379441/* accept parameters in form 
     
    386448        const unsigned char * q = NULL; 
    387449        HPIPE pipe; 
     450        int defaultPassword = 1; 
    388451 
    389452        pRes->memlen = 1 << 18; 
     
    429492        { 
    430493                StrNCpy(pRes->srv.password, q, sizeof(pRes->srv.password) - 1); 
    431         } 
     494                defaultPassword = 0; 
     495        } 
     496 
     497        t = 0, q = NULL; 
     498        rc = ph->fsphQueryStringProperty (pRes->properties, "SPASSWORD", &q, &t); 
     499        if (   rc == NO_ERROR 
     500            && *q != '\0' 
     501            && defaultPassword) 
     502        { 
     503            char p[1024]; 
     504            p[0] = 0; 
     505         
     506            decryptPassword (q, p); 
     507         
     508            if (*p) 
     509            { 
     510                StrNCpy(pRes->srv.password, p, sizeof(pRes->srv.password) - 1); 
     511         
     512                /* clear the plain password */ 
     513                ph->fsphSetProperty (pRes->properties, "PASSWORD", ""); 
     514            } 
     515        } 
     516        else 
     517        { 
     518            char c[1024]; 
     519            encryptPassword (pRes->srv.password, c); 
     520         
     521            ph->fsphSetProperty (pRes->properties, "SPASSWORD", c); 
     522         
     523            // clear the plain password 
     524            ph->fsphSetProperty (pRes->properties, "PASSWORD", ""); 
     525        } 
    432526 
    433527        t = 0, q = NULL; 
     
    20172111int APIENTRY NdpIOCTL (int type, HRESOURCE resource, char *path, int function, void *in, ULONG insize, PULONG poutlen) 
    20182112{ 
    2019         log("NdpIOCTL <%s> %d %d\n", path, function, ERROR_NOT_SUPPORTED); 
    2020         return ERROR_NOT_SUPPORTED; 
     2113    log("NdpIOCTL <%s> %d\n", path, function); 
     2114 
     2115    if (in && insize > 4096) 
     2116    { 
     2117        sprintf (in, "SAMBA IOCTL function = %d, parms [%s] insize = %d, *poutlen = %d", function, in, insize, *poutlen); 
     2118        *poutlen = insize; 
     2119        return NO_ERROR; 
     2120    } 
     2121 
     2122    return ERROR_NOT_SUPPORTED; 
    20212123} 
    20222124 
  • trunk/samba/source/ndpsmb/rc/rc.dlg

    r66 r117  
    3131                        DT_BOTTOM  
    3232        ENTRYFIELD      "", ENT_PASS, 67, 70, 100, 8, ES_MARGIN | ES_UNREADABLE 
     33        ENTRYFIELD      "", ENT_SPASS, 0, 0, 0, 0, ES_MARGIN |  
     34                        ES_UNREADABLE | NOT WS_TABSTOP | NOT WS_VISIBLE 
    3335 
    3436        RTEXT           "Master", LBL_MASTER, 5, 57, 30, 10,  
  • trunk/samba/source/ndpsmb/rc/rc.h

    r5 r117  
    2424#define LBL_EASUPPORT               1021 
    2525#define CHK_EASUPPORT               1022 
     26#define ENT_SPASS                   1023 
  • trunk/samba/source/ndpsmb/rc/rc.rc

    r9 r117  
    145145RCDATA (DLG_ID + 11) 
    146146{ 
     147    ENT_SPASS, PARMTYPE_STRING, 1L, 255L, "spassword", "%s", "" 
     148} 
     149 
     150RCDATA (DLG_ID + 12) 
     151{ 
    147152    0 
    148153} 
  • trunk/samba/source/ndpsmb/smbcd.c

    r75 r117  
    1111#include "smbwrp.h" 
    1212#include "smbcd.h" 
     13#include "config.h" 
    1314 
    1415#define SMBCD_MAX_THREADS 250 
    1516 
    1617int debuglevel = 0; 
     18int krb5support = 0; 
    1719HMTX logmutex = 0; 
    1820char *logfile = NULL; 
     
    306308        data = req->param + req->paramlen; 
    307309//      memset(res, 0, sizeof(*res)); 
     310 
    308311        debuglocal(1,"Client request %d paramlen %d len %d, reconnect %d. State %08x\n",  req->request, req->paramlen, req->length, *reconnect, cli); 
    309312        if (*reconnect == 2) 
    310313        { 
    311314                debuglocal(1,"Reconnecting to last server requested\n"); 
    312                 res->rc = smbwrp_connect(srv, _cli); 
     315                res->rc = smbwrp_connect(srv, _cli, krb5support); 
    313316                if (res->rc) 
    314317                { 
     
    343346                                break; 
    344347                        } 
    345                         res->rc = smbwrp_connect((smbwrp_server *)req->param, _cli); 
     348                        res->rc = smbwrp_connect((smbwrp_server *)req->param, _cli, krb5support); 
    346349                        if (!res->rc) 
    347350                        { 
     
    756759        printf( "Daemon priority set to PRTYC_FOREGROUNDSERVER\n"); 
    757760#endif 
    758  
     761        debuglocal(0,"Entering main()\n"); 
    759762        for (argc--, argv++; argc > 0; argc--, argv++) 
    760763        { 
     
    813816                } 
    814817        } 
     818#ifdef HAVE_KRB5_H 
     819        krb5support = 1; 
     820#else 
     821        krb5support = 0; 
     822#endif 
    815823        if (rc) 
    816824        { 
  • trunk/samba/source/ndpsmb/smbwrp.c

    r75 r117  
    373373return a connection to a server 
    374374*******************************************************/ 
    375 int _System smbwrp_connect(smbwrp_server * srv, struct cli_state ** cli) 
     375int _System smbwrp_connect(smbwrp_server * srv, struct cli_state ** cli, int krb5support) 
    376376{ 
    377377        char * server = srv->server_name; 
     
    387387        zero_ip(&ip); 
    388388 
    389         debuglocal(1,"Connecting to \\\\%s:%s@%s:%s\\%s. Master %s:%d\n", srv->username, srv->password, workgroup, server, share, srv->master, srv->ifmastergroup); 
     389        debuglocal(1,"Connecting to \\\\%s:*********@%s:%s\\%s. Master %s:%d\n", srv->username, workgroup, server, share, srv->master, srv->ifmastergroup); 
    390390 
    391391        if (!*server) { 
     
    434434                return 3; 
    435435        } 
     436 
     437        if (krb5support == 1){ 
     438        debuglocal(1,"Kerberos support enabled\n"); 
     439                c->use_kerberos = True;} 
     440 
    436441        if (!cli_session_request(c, &calling, &called)) { 
    437442                cli_shutdown(c); 
     
    450455        } 
    451456 
    452         debuglocal(4," session setuping for <%s>/<%s> %d in <%s> %08x %08x %08x\n", srv->username, srv->password, strlen(srv->password), workgroup, c->protocol, c->sec_mode, c->capabilities); 
     457        debuglocal(4," session setuping for <%s>/<********> in <%s> %08x %08x %08x\n", srv->username, workgroup, c->protocol, c->sec_mode, c->capabilities); 
    453458 
    454459        if (!NT_STATUS_IS_OK(cli_session_setup(c, srv->username,  
     
    456461                               srv->password, strlen(srv->password), 
    457462                               workgroup))) { 
    458                 debuglocal(4,"%s/%s login failed\n", srv->username, srv->password); 
     463                debuglocal(4,"%s/******** login failed\n", srv->username); 
    459464                /* try an anonymous login if it failed */ 
    460465                if (!NT_STATUS_IS_OK(cli_session_setup(c, "", "", 1,"", 0, workgroup))) { 
     
    465470        } 
    466471 
    467         debuglocal(4," session setup ok. Sending tconx <%s> <%s> %d\n", share, srv->password, strlen(srv->password)); 
     472        debuglocal(4," session setup ok. Sending tconx <%s> <********>\n", share); 
    468473 
    469474        if (!cli_send_tconX(c, share, "?????", 
     
    10221027        if (!finfo) finfo = &finfo1; 
    10231028 
    1024 //      memcpy(finfo,&def_finfo,sizeof(*finfo)); 
     1029        if (p_resume_key) { 
     1030                *p_resume_key = 0; 
     1031        } 
     1032 
    10251033        finfo->attr = def_finfo.mode; 
    10261034        finfo->mtime = def_finfo.mtime_ts.tv_sec; 
     
    10471055                        p += clistr_pull(cli, finfo->fname, p, 
    10481056                                         sizeof(finfo->fname), 
    1049                                          len+2,  
     1057                                         len+2, 
    10501058                                         STR_TERMINATE); 
    10511059                        finfo->easize = -1; 
     
    10741082                        size_t namelen, slen; 
    10751083                        p += 4; /* next entry offset */ 
    1076 #if 0 
    10771084                        if (p_resume_key) { 
    10781085                                *p_resume_key = IVAL(p,0); 
    10791086                        } 
    1080 #endif 
     1087 
    10811088                        p += 4; /* fileindex */ 
    10821089                                 
     
    11571164        smbwrp_fileinfo finfo; 
    11581165        int i; 
    1159         char *tdl, *dirlist = NULL; 
     1166        char *dirlist = NULL; 
    11601167        int dirlist_len = 0; 
    11611168        int total_received = -1; 
     
    11631170        int ff_searchcount=0; 
    11641171        int ff_eos=0; 
    1165         //int ff_lastname=0; 
    11661172        int ff_dir_handle=0; 
    11671173        int loop_count = 0; 
     
    11761182 
    11771183        /* NT uses 260, OS/2 uses 2. Both accept 1. */ 
    1178         info_level = (cli->capabilities&CAP_NT_SMBS)?260:2; 
     1184        info_level = (cli->capabilities&CAP_NT_SMBS)?260:2;  
    11791185 
    11801186        debuglocal(4,"list_files level %d. mask <%s>\n", info_level, mask); 
     
    11991205                        SSVAL(param,0,attribute); /* attribute */ 
    12001206                        SSVAL(param,2,max_matches); /* max count */ 
    1201                         //SSVAL(param,4,4+2);   /* resume required + close on end */ 
    12021207                        SSVAL(param,4,(FLAG_TRANS2_FIND_REQUIRE_RESUME|FLAG_TRANS2_FIND_CLOSE_IF_END)); /* resume required + close on end */ 
    12031208                        SSVAL(param,6,info_level);  
     
    12101215                        SSVAL(param,0,ff_dir_handle); 
    12111216                        SSVAL(param,2,max_matches); /* max count */ 
    1212                         //SIVAL(param,6,0); /* ff_resume_key */ 
    12131217                        SSVAL(param,4,info_level);  
    12141218                        /* For W2K servers serving out FAT filesystems we *must* set the 
     
    12181222                           can miss filenames. Use last filename continue instead. JRA */ 
    12191223                        SSVAL(param,10,(FLAG_TRANS2_FIND_REQUIRE_RESUME|FLAG_TRANS2_FIND_CLOSE_IF_END));        /* resume required + close on end */ 
    1220                         //SSVAL(param,10,8+4+2);        /* continue + resume required + close on end */ 
    12211224                        p = param+12; 
    1222                         //p += clistr_push(cli, param+12, mask, sizeof(param)-12,  
    1223                         //               STR_TERMINATE); 
    12241225                        if (last_name_raw_len && (last_name_raw_len < (sizeof(param)-12))) { 
    12251226                                memcpy(p, last_name_raw.data, last_name_raw_len); 
     
    12311232 
    12321233                param_len = PTR_DIFF(p, param); 
     1234 
    12331235                if (!cli_send_trans(cli, SMBtrans2,  
    12341236                                    NULL,                   /* Name */ 
     
    12661268                } 
    12671269 
    1268  
    12691270                if (cli_is_error(cli) || !rdata || !rparam)  
    12701271                { 
     
    12901291                        ff_searchcount = SVAL(p,2); 
    12911292                        ff_eos = SVAL(p,4); 
    1292                         //ff_lastname = SVAL(p,8); 
    12931293                } else { 
    12941294                        ff_searchcount = SVAL(p,0); 
    12951295                        ff_eos = SVAL(p,2); 
    1296                         //ff_lastname = SVAL(p,6); 
    12971296                } 
    12981297                debuglocal(4,"list_files %d %d %d %d\n", ff_searchcount, ff_eos, "(ff_lastname)", First); 
  • trunk/samba/source/ndpsmb/smbwrp.h

    r75 r117  
    121121int _System smbwrp_getclisize(void); 
    122122int _System smbwrp_init(void); 
    123 int _System smbwrp_connect(smbwrp_server * srv, cli_state ** c); 
     123int _System smbwrp_connect(smbwrp_server * srv, cli_state ** c, int krb5support); 
    124124void _System smbwrp_disconnect(cli_state ** cli); 
    125125int _System smbwrp_open(cli_state * cli, smbwrp_file * file);