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

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/smbd/session.c

    r414 r740  
    2828
    2929#include "includes.h"
     30#include "smbd/smbd.h"
    3031#include "smbd/globals.h"
    31 
    32 /********************************************************************
    33 ********************************************************************/
    34 
    35 static struct db_context *session_db_ctx(void)
    36 {
    37         if (session_db_ctx_ptr)
    38                 return session_db_ctx_ptr;
    39 
    40         session_db_ctx_ptr = db_open(NULL, lock_path("sessionid.tdb"), 0,
    41                                      TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
    42                                      O_RDWR | O_CREAT, 0644);
    43         return session_db_ctx_ptr;
    44 }
    45 
    46 bool session_init(void)
    47 {
    48         if (session_db_ctx() == NULL) {
    49                 DEBUG(1,("session_init: failed to open sessionid tdb\n"));
    50                 return False;
    51         }
    52 
    53         return True;
    54 }
     32#include "dbwrap.h"
     33#include "session.h"
     34#include "auth.h"
    5535
    5636/********************************************************************
     
    5838********************************************************************/
    5939
    60 bool session_claim(user_struct *vuser)
    61 {
    62         TDB_DATA key, data;
     40bool session_claim(struct smbd_server_connection *sconn, user_struct *vuser)
     41{
     42        struct server_id pid = sconn_server_id(sconn);
     43        TDB_DATA data;
    6344        int i = 0;
    6445        struct sessionid sessionid;
    65         struct server_id pid = procid_self();
    6646        fstring keystr;
    67         const char * hostname;
    68         struct db_context *ctx;
    6947        struct db_record *rec;
    7048        NTSTATUS status;
    71         char addr[INET6_ADDRSTRLEN];
    7249
    7350        vuser->session_keystr = NULL;
     
    7552        /* don't register sessions for the guest user - its just too
    7653           expensive to go through pam session code for browsing etc */
    77         if (vuser->server_info->guest) {
     54        if (vuser->session_info->guest) {
    7855                return True;
    7956        }
    8057
    81         if (!(ctx = session_db_ctx())) {
     58        if (!sessionid_init()) {
    8259                return False;
    8360        }
     
    9976
    10077                        snprintf(keystr, sizeof(keystr), "ID/%d", i);
    101                         key = string_term_tdb_data(keystr);
    102 
    103                         rec = ctx->fetch_locked(ctx, NULL, key);
    104 
     78
     79                        rec = sessionid_fetch_record(NULL, keystr);
    10580                        if (rec == NULL) {
    10681                                DEBUG(1, ("Could not lock \"%s\"\n", keystr));
     
    140115                snprintf(keystr, sizeof(keystr), "ID/%s/%u",
    141116                         procid_str_static(&pid), vuser->vuid);
    142                 key = string_term_tdb_data(keystr);
    143 
    144                 rec = ctx->fetch_locked(ctx, NULL, key);
    145 
     117
     118                rec = sessionid_fetch_record(NULL, keystr);
    146119                if (rec == NULL) {
    147120                        DEBUG(1, ("Could not lock \"%s\"\n", keystr));
     
    162135        */
    163136
    164         hostname = client_name(get_client_fd());
    165         if (strcmp(hostname, "UNKNOWN") == 0) {
    166                 hostname = client_addr(get_client_fd(),addr,sizeof(addr));
    167         }
    168 
    169         fstrcpy(sessionid.username, vuser->server_info->unix_name);
    170         fstrcpy(sessionid.hostname, hostname);
     137        fstrcpy(sessionid.username, vuser->session_info->unix_name);
     138        fstrcpy(sessionid.hostname, sconn->client_id.name);
    171139        sessionid.id_num = i;  /* Only valid for utmp sessions */
    172140        sessionid.pid = pid;
    173         sessionid.uid = vuser->server_info->utok.uid;
    174         sessionid.gid = vuser->server_info->utok.gid;
     141        sessionid.uid = vuser->session_info->utok.uid;
     142        sessionid.gid = vuser->session_info->utok.gid;
    175143        fstrcpy(sessionid.remote_machine, get_remote_machine_name());
    176         fstrcpy(sessionid.ip_addr_str,
    177                 client_addr(get_client_fd(),addr,sizeof(addr)));
     144        fstrcpy(sessionid.ip_addr_str, sconn->client_id.addr);
    178145        sessionid.connect_start = time(NULL);
    179146
     
    220187void session_yield(user_struct *vuser)
    221188{
    222         TDB_DATA key;
    223189        struct sessionid sessionid;
    224         struct db_context *ctx;
    225190        struct db_record *rec;
    226 
    227         if (!(ctx = session_db_ctx())) return;
    228191
    229192        if (!vuser->session_keystr) {
     
    231194        }
    232195
    233         key = string_term_tdb_data(vuser->session_keystr);
    234 
    235         if (!(rec = ctx->fetch_locked(ctx, NULL, key))) {
     196        rec = sessionid_fetch_record(NULL, vuser->session_keystr);
     197        if (rec == NULL) {
    236198                return;
    237199        }
     
    254216
    255217        TALLOC_FREE(rec);
    256 }
    257 
    258 /********************************************************************
    259 ********************************************************************/
    260 
    261 static bool session_traverse(int (*fn)(struct db_record *db,
    262                                        void *private_data),
    263                              void *private_data)
    264 {
    265         struct db_context *ctx;
    266 
    267         if (!(ctx = session_db_ctx())) {
    268                 DEBUG(3, ("No tdb opened\n"));
    269                 return False;
    270         }
    271 
    272         ctx->traverse_read(ctx, fn, private_data);
    273         return True;
    274218}
    275219
     
    283227};
    284228
    285 static int gather_sessioninfo(struct db_record *rec, void *state)
    286 {
    287         struct session_list *sesslist = (struct session_list *) state;
    288         const struct sessionid *current =
    289                 (const struct sessionid *) rec->value.dptr;
     229static int gather_sessioninfo(const char *key, struct sessionid *session,
     230                              void *private_data)
     231{
     232        struct session_list *sesslist = (struct session_list *)private_data;
    290233
    291234        sesslist->sessions = TALLOC_REALLOC_ARRAY(
     
    298241        }
    299242
    300         memcpy(&sesslist->sessions[sesslist->count], current,
     243        memcpy(&sesslist->sessions[sesslist->count], session,
    301244               sizeof(struct sessionid));
    302245
    303246        sesslist->count++;
    304247
    305         DEBUG(7,("gather_sessioninfo session from %s@%s\n",
    306                  current->username, current->remote_machine));
     248        DEBUG(7, ("gather_sessioninfo session from %s@%s\n",
     249                  session->username, session->remote_machine));
    307250
    308251        return 0;
     
    315258{
    316259        struct session_list sesslist;
     260        int ret;
    317261
    318262        sesslist.mem_ctx = mem_ctx;
    319263        sesslist.count = 0;
    320264        sesslist.sessions = NULL;
    321        
    322         if (!session_traverse(gather_sessioninfo, (void *) &sesslist)) {
     265
     266        ret = sessionid_traverse_read(gather_sessioninfo, (void *) &sesslist);
     267        if (ret == -1) {
    323268                DEBUG(3, ("Session traverse failed\n"));
    324269                SAFE_FREE(sesslist.sessions);
Note: See TracChangeset for help on using the changeset viewer.