Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/utils/net_status.c

    r414 r745  
    1919#include "includes.h"
    2020#include "utils/net.h"
     21#include "session.h"
     22#include "messages.h"
    2123
    2224int net_status_usage(struct net_context *c, int argc, const char **argv)
     
    2931}
    3032
    31 static int show_session(struct db_record *rec, void *private_data)
     33static int show_session(const char *key, struct sessionid *session,
     34                        void *private_data)
    3235{
    3336        bool *parseable = (bool *)private_data;
    34         struct sessionid sessionid;
    35 
    36         if (rec->value.dsize != sizeof(sessionid))
    37                 return 0;
    38 
    39         memcpy(&sessionid, rec->value.dptr, sizeof(sessionid));
    40 
    41         if (!process_exists(sessionid.pid)) {
     37
     38        if (!process_exists(session->pid)) {
    4239                return 0;
    4340        }
     
    4542        if (*parseable) {
    4643                d_printf("%s\\%s\\%s\\%s\\%s\n",
    47                          procid_str_static(&sessionid.pid), uidtoname(sessionid.uid),
    48                          gidtoname(sessionid.gid),
    49                          sessionid.remote_machine, sessionid.hostname);
     44                         procid_str_static(&session->pid),
     45                         uidtoname(session->uid),
     46                         gidtoname(session->gid),
     47                         session->remote_machine, session->hostname);
    5048        } else {
    5149                d_printf("%7s   %-12s  %-12s  %-12s (%s)\n",
    52                          procid_str_static(&sessionid.pid), uidtoname(sessionid.uid),
    53                          gidtoname(sessionid.gid),
    54                          sessionid.remote_machine, sessionid.hostname);
     50                         procid_str_static(&session->pid),
     51                         uidtoname(session->uid),
     52                         gidtoname(session->gid),
     53                         session->remote_machine, session->hostname);
    5554        }
    5655
     
    6059static int net_status_sessions(struct net_context *c, int argc, const char **argv)
    6160{
    62         struct db_context *db;
    6361        bool parseable;
    6462
     
    8987        }
    9088
    91         db = db_open(NULL, lock_path("sessionid.tdb"), 0,
    92                      TDB_CLEAR_IF_FIRST, O_RDONLY, 0644);
    93         if (db == NULL) {
    94                 d_fprintf(stderr, _("%s not initialised\n"),
    95                           lock_path("sessionid.tdb"));
    96                 return -1;
    97         }
    98 
    99         db->traverse_read(db, show_session, &parseable);
    100         TALLOC_FREE(db);
    101 
     89        sessionid_traverse_read(show_session, &parseable);
    10290        return 0;
    10391}
     
    128116};
    129117
    130 static int collect_pid(struct db_record *rec, void *private_data)
     118static int collect_pids(const char *key, struct sessionid *session,
     119                        void *private_data)
    131120{
    132121        struct sessionids *ids = (struct sessionids *)private_data;
    133         struct sessionid sessionid;
    134 
    135         if (rec->value.dsize != sizeof(sessionid))
    136                 return 0;
    137 
    138         memcpy(&sessionid, rec->value.dptr, sizeof(sessionid));
    139 
    140         if (!process_exists(sessionid.pid))
     122
     123        if (!process_exists(session->pid))
    141124                return 0;
    142125
     
    147130                return 0;
    148131        }
    149         ids->entries[ids->num_entries-1] = sessionid;
    150 
    151         return 0;
    152 }
    153 
    154 static int show_share_parseable(struct db_record *rec,
    155                                 const struct connections_key *key,
     132        ids->entries[ids->num_entries-1] = *session;
     133
     134        return 0;
     135}
     136
     137static int show_share_parseable(const struct connections_key *key,
    156138                                const struct connections_data *crec,
    157139                                void *state)
     
    190172{
    191173        struct sessionids ids;
    192         struct db_context *db;
    193174
    194175        ids.num_entries = 0;
    195176        ids.entries = NULL;
    196177
    197         db = db_open(NULL, lock_path("sessionid.tdb"), 0,
    198                      TDB_CLEAR_IF_FIRST, O_RDONLY, 0644);
    199         if (db == NULL) {
    200                 d_fprintf(stderr, _("%s not initialised\n"),
    201                           lock_path("sessionid.tdb"));
    202                 return -1;
    203         }
    204 
    205         db->traverse_read(db, collect_pid, &ids);
    206         TALLOC_FREE(db);
    207 
    208         connections_forall(show_share_parseable, &ids);
     178        sessionid_traverse_read(collect_pids, &ids);
     179
     180        connections_forall_read(show_share_parseable, &ids);
    209181
    210182        SAFE_FREE(ids.entries);
Note: See TracChangeset for help on using the changeset viewer.