rpc_server/srv_netlog.c

説明を見る。
00001 /* 
00002  *  Unix SMB/CIFS implementation.
00003  *  RPC Pipe client / server routines
00004  *  Copyright (C) Andrew Tridgell              1992-1997,
00005  *  Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
00006  *  Copyright (C) Paul Ashton                       1997,
00007  *  Copyright (C) Jeremy Allison               1998-2001,
00008  *  Copyright (C) Jim McDonough <jmcd@us.ibm.com>   2003.
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *  
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *  
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00023  */
00024 
00025 /* This is the interface to the netlogon pipe. */
00026 
00027 #include "includes.h"
00028 
00029 #undef DBGC_CLASS
00030 #define DBGC_CLASS DBGC_RPC_SRV
00031 
00032 /*************************************************************************
00033  api_net_req_chal:
00034  *************************************************************************/
00035 
00036 static BOOL api_net_req_chal(pipes_struct *p)
00037 {
00038         NET_Q_REQ_CHAL q_u;
00039         NET_R_REQ_CHAL r_u;
00040         prs_struct *data = &p->in_data.data;
00041         prs_struct *rdata = &p->out_data.rdata;
00042 
00043         ZERO_STRUCT(q_u);
00044         ZERO_STRUCT(r_u);
00045 
00046         /* grab the challenge... */
00047         if(!net_io_q_req_chal("", &q_u, data, 0)) {
00048                 DEBUG(0,("api_net_req_chal: Failed to unmarshall NET_Q_REQ_CHAL.\n"));
00049                 return False;
00050         }
00051 
00052         r_u.status = _net_req_chal(p, &q_u, &r_u);
00053 
00054         /* store the response in the SMB stream */
00055         if(!net_io_r_req_chal("", &r_u, rdata, 0)) {
00056                 DEBUG(0,("api_net_req_chal: Failed to marshall NET_R_REQ_CHAL.\n"));
00057                 return False;
00058         }
00059 
00060         return True;
00061 }
00062 
00063 /*************************************************************************
00064  api_net_auth:
00065  *************************************************************************/
00066 
00067 static BOOL api_net_auth(pipes_struct *p)
00068 {
00069         NET_Q_AUTH q_u;
00070         NET_R_AUTH r_u;
00071         prs_struct *data = &p->in_data.data;
00072         prs_struct *rdata = &p->out_data.rdata;
00073 
00074         ZERO_STRUCT(q_u);
00075         ZERO_STRUCT(r_u);
00076 
00077         /* grab the challenge... */
00078         if(!net_io_q_auth("", &q_u, data, 0)) {
00079                 DEBUG(0,("api_net_auth: Failed to unmarshall NET_Q_AUTH.\n"));
00080                 return False;
00081         }
00082 
00083         r_u.status = _net_auth(p, &q_u, &r_u);
00084 
00085         /* store the response in the SMB stream */
00086         if(!net_io_r_auth("", &r_u, rdata, 0)) {
00087                 DEBUG(0,("api_net_auth: Failed to marshall NET_R_AUTH.\n"));
00088                 return False;
00089         }
00090 
00091         return True;
00092 }
00093 
00094 /*************************************************************************
00095  api_net_auth_2:
00096  *************************************************************************/
00097 
00098 static BOOL api_net_auth_2(pipes_struct *p)
00099 {
00100         NET_Q_AUTH_2 q_u;
00101         NET_R_AUTH_2 r_u;
00102         prs_struct *data = &p->in_data.data;
00103         prs_struct *rdata = &p->out_data.rdata;
00104 
00105         ZERO_STRUCT(q_u);
00106         ZERO_STRUCT(r_u);
00107 
00108         /* grab the challenge... */
00109         if(!net_io_q_auth_2("", &q_u, data, 0)) {
00110                 DEBUG(0,("api_net_auth_2: Failed to unmarshall NET_Q_AUTH_2.\n"));
00111                 return False;
00112         }
00113 
00114         r_u.status = _net_auth_2(p, &q_u, &r_u);
00115 
00116         /* store the response in the SMB stream */
00117         if(!net_io_r_auth_2("", &r_u, rdata, 0)) {
00118                 DEBUG(0,("api_net_auth_2: Failed to marshall NET_R_AUTH_2.\n"));
00119                 return False;
00120         }
00121 
00122         return True;
00123 }
00124 
00125 /*************************************************************************
00126  api_net_srv_pwset:
00127  *************************************************************************/
00128 
00129 static BOOL api_net_srv_pwset(pipes_struct *p)
00130 {
00131         NET_Q_SRV_PWSET q_u;
00132         NET_R_SRV_PWSET r_u;
00133         prs_struct *data = &p->in_data.data;
00134         prs_struct *rdata = &p->out_data.rdata;
00135 
00136         ZERO_STRUCT(q_u);
00137         ZERO_STRUCT(r_u);
00138 
00139         /* grab the challenge and encrypted password ... */
00140         if(!net_io_q_srv_pwset("", &q_u, data, 0)) {
00141                 DEBUG(0,("api_net_srv_pwset: Failed to unmarshall NET_Q_SRV_PWSET.\n"));
00142                 return False;
00143         }
00144 
00145         r_u.status = _net_srv_pwset(p, &q_u, &r_u);
00146 
00147         /* store the response in the SMB stream */
00148         if(!net_io_r_srv_pwset("", &r_u, rdata, 0)) {
00149                 DEBUG(0,("api_net_srv_pwset: Failed to marshall NET_R_SRV_PWSET.\n"));
00150                 return False;
00151         }
00152 
00153         return True;
00154 }
00155 
00156 /*************************************************************************
00157  api_net_sam_logoff:
00158  *************************************************************************/
00159 
00160 static BOOL api_net_sam_logoff(pipes_struct *p)
00161 {
00162         NET_Q_SAM_LOGOFF q_u;
00163         NET_R_SAM_LOGOFF r_u;
00164         prs_struct *data = &p->in_data.data;
00165         prs_struct *rdata = &p->out_data.rdata;
00166 
00167         ZERO_STRUCT(q_u);
00168         ZERO_STRUCT(r_u);
00169 
00170         if(!net_io_q_sam_logoff("", &q_u, data, 0)) {
00171                 DEBUG(0,("api_net_sam_logoff: Failed to unmarshall NET_Q_SAM_LOGOFF.\n"));
00172                 return False;
00173         }
00174 
00175         r_u.status = _net_sam_logoff(p, &q_u, &r_u);
00176 
00177         /* store the response in the SMB stream */
00178         if(!net_io_r_sam_logoff("", &r_u, rdata, 0)) {
00179                 DEBUG(0,("api_net_sam_logoff: Failed to marshall NET_R_SAM_LOGOFF.\n"));
00180                 return False;
00181         }
00182 
00183         return True;
00184 }
00185 
00186 /*************************************************************************
00187  api_net_sam_logon:
00188  *************************************************************************/
00189 
00190 static BOOL api_net_sam_logon(pipes_struct *p)
00191 {
00192         NET_Q_SAM_LOGON q_u;
00193         NET_R_SAM_LOGON r_u;
00194         prs_struct *data = &p->in_data.data;
00195         prs_struct *rdata = &p->out_data.rdata;
00196     
00197         ZERO_STRUCT(q_u);
00198         ZERO_STRUCT(r_u);
00199 
00200         if(!net_io_q_sam_logon("", &q_u, data, 0)) {
00201                 DEBUG(0, ("api_net_sam_logon: Failed to unmarshall NET_Q_SAM_LOGON.\n"));
00202                 return False;
00203         }
00204    
00205         r_u.status = _net_sam_logon(p, &q_u, &r_u);
00206 
00207         /* store the response in the SMB stream */
00208         if(!net_io_r_sam_logon("", &r_u, rdata, 0)) {
00209                 DEBUG(0,("api_net_sam_logon: Failed to marshall NET_R_SAM_LOGON.\n"));
00210                 return False;
00211         }
00212 
00213         return True;
00214 }
00215 
00216 /*************************************************************************
00217  api_net_trust_dom_list:
00218  *************************************************************************/
00219 
00220 static BOOL api_net_trust_dom_list(pipes_struct *p)
00221 {
00222         NET_Q_TRUST_DOM_LIST q_u;
00223         NET_R_TRUST_DOM_LIST r_u;
00224         prs_struct *data = &p->in_data.data;
00225         prs_struct *rdata = &p->out_data.rdata;
00226 
00227         ZERO_STRUCT(q_u);
00228         ZERO_STRUCT(r_u);
00229 
00230         /* grab the lsa trusted domain list query... */
00231         if(!net_io_q_trust_dom("", &q_u, data, 0)) {
00232                 DEBUG(0,("api_net_trust_dom_list: Failed to unmarshall NET_Q_TRUST_DOM_LIST.\n"));
00233                 return False;
00234         }
00235 
00236         /* construct reply. */
00237         r_u.status = _net_trust_dom_list(p, &q_u, &r_u);
00238 
00239         /* store the response in the SMB stream */
00240         if(!net_io_r_trust_dom("", &r_u, rdata, 0)) {
00241                 DEBUG(0,("net_reply_trust_dom_list: Failed to marshall NET_R_TRUST_DOM_LIST.\n"));
00242                 return False;
00243         }
00244 
00245         return True;
00246 }
00247 
00248 /*************************************************************************
00249  api_net_logon_ctrl2:
00250  *************************************************************************/
00251 
00252 static BOOL api_net_logon_ctrl2(pipes_struct *p)
00253 {
00254         NET_Q_LOGON_CTRL2 q_u;
00255         NET_R_LOGON_CTRL2 r_u;
00256         prs_struct *data = &p->in_data.data;
00257         prs_struct *rdata = &p->out_data.rdata;
00258 
00259         ZERO_STRUCT(q_u);
00260         ZERO_STRUCT(r_u);
00261 
00262 
00263         /* grab the lsa netlogon ctrl2 query... */
00264         if(!net_io_q_logon_ctrl2("", &q_u, data, 0)) {
00265                 DEBUG(0,("api_net_logon_ctrl2: Failed to unmarshall NET_Q_LOGON_CTRL2.\n"));
00266                 return False;
00267         }
00268 
00269         r_u.status = _net_logon_ctrl2(p, &q_u, &r_u);
00270 
00271         if(!net_io_r_logon_ctrl2("", &r_u, rdata, 0)) {
00272                 DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL2.\n"));
00273                 return False;
00274         }
00275 
00276         return True;
00277 }
00278 
00279 /*************************************************************************
00280  api_net_logon_ctrl:
00281  *************************************************************************/
00282 
00283 static BOOL api_net_logon_ctrl(pipes_struct *p)
00284 {
00285         NET_Q_LOGON_CTRL q_u;
00286         NET_R_LOGON_CTRL r_u;
00287         prs_struct *data = &p->in_data.data;
00288         prs_struct *rdata = &p->out_data.rdata;
00289 
00290         ZERO_STRUCT(q_u);
00291         ZERO_STRUCT(r_u);
00292 
00293         /* grab the lsa netlogon ctrl query... */
00294         if(!net_io_q_logon_ctrl("", &q_u, data, 0)) {
00295                 DEBUG(0,("api_net_logon_ctrl: Failed to unmarshall NET_Q_LOGON_CTRL.\n"));
00296                 return False;
00297         }
00298 
00299         r_u.status = _net_logon_ctrl(p, &q_u, &r_u);
00300 
00301         if(!net_io_r_logon_ctrl("", &r_u, rdata, 0)) {
00302                 DEBUG(0,("net_reply_logon_ctrl2: Failed to marshall NET_R_LOGON_CTRL.\n"));
00303                 return False;
00304         }
00305 
00306         return True;
00307 }
00308 
00309 /*************************************************************************
00310  api_net_sam_logon_ex:
00311  *************************************************************************/
00312 
00313 static BOOL api_net_sam_logon_ex(pipes_struct *p)
00314 {
00315         NET_Q_SAM_LOGON_EX q_u;
00316         NET_R_SAM_LOGON_EX r_u;
00317         prs_struct *data = &p->in_data.data;
00318         prs_struct *rdata = &p->out_data.rdata;
00319     
00320         ZERO_STRUCT(q_u);
00321         ZERO_STRUCT(r_u);
00322 
00323         if(!net_io_q_sam_logon_ex("", &q_u, data, 0)) {
00324                 DEBUG(0, ("api_net_sam_logon_ex: Failed to unmarshall NET_Q_SAM_LOGON_EX.\n"));
00325                 return False;
00326         }
00327    
00328         r_u.status = _net_sam_logon_ex(p, &q_u, &r_u);
00329 
00330         /* store the response in the SMB stream */
00331         if(!net_io_r_sam_logon_ex("", &r_u, rdata, 0)) {
00332                 DEBUG(0,("api_net_sam_logon_ex: Failed to marshall NET_R_SAM_LOGON_EX.\n"));
00333                 return False;
00334         }
00335 
00336         return True;
00337 }
00338 
00339 
00340 /*************************************************************************
00341  api_ds_enum_dom_trusts:
00342  *************************************************************************/
00343 
00344 #if 0   /* JERRY */
00345 static BOOL api_ds_enum_dom_trusts(pipes_struct *p)
00346 {
00347         DS_Q_ENUM_DOM_TRUSTS q_u;
00348         DS_R_ENUM_DOM_TRUSTS r_u;
00349 
00350         prs_struct *data = &p->in_data.data;
00351         prs_struct *rdata = &p->out_data.rdata;
00352 
00353         ZERO_STRUCT(q_u);
00354         ZERO_STRUCT(r_u);
00355 
00356         DEBUG(6,("api_ds_enum_dom_trusts\n"));
00357 
00358         if ( !ds_io_q_enum_domain_trusts("", data, 0, &q_u) ) {
00359                 DEBUG(0,("api_ds_enum_domain_trusts: Failed to unmarshall DS_Q_ENUM_DOM_TRUSTS.\n"));
00360                 return False;
00361         }
00362 
00363         r_u.status = _ds_enum_dom_trusts(p, &q_u, &r_u);
00364 
00365         if ( !ds_io_r_enum_domain_trusts("", rdata, 0, &r_u) ) {
00366                 DEBUG(0,("api_ds_enum_domain_trusts: Failed to marshall DS_R_ENUM_DOM_TRUSTS.\n"));
00367                 return False;
00368         }
00369 
00370         DEBUG(6,("api_ds_enum_dom_trusts\n"));
00371 
00372         return True;
00373 }
00374 #endif  /* JERRY */
00375 
00376 /*******************************************************************
00377  array of \PIPE\NETLOGON operations
00378  ********************************************************************/
00379 static struct api_struct api_net_cmds [] =
00380     {
00381       { "NET_REQCHAL"       , NET_REQCHAL       , api_net_req_chal       }, 
00382       { "NET_AUTH"          , NET_AUTH          , api_net_auth           }, 
00383       { "NET_AUTH2"         , NET_AUTH2         , api_net_auth_2         }, 
00384       { "NET_SRVPWSET"      , NET_SRVPWSET      , api_net_srv_pwset      }, 
00385       { "NET_SAMLOGON"      , NET_SAMLOGON      , api_net_sam_logon      }, 
00386       { "NET_SAMLOGOFF"     , NET_SAMLOGOFF     , api_net_sam_logoff     }, 
00387       { "NET_LOGON_CTRL2"   , NET_LOGON_CTRL2   , api_net_logon_ctrl2    }, 
00388       { "NET_TRUST_DOM_LIST", NET_TRUST_DOM_LIST, api_net_trust_dom_list },
00389       { "NET_LOGON_CTRL"    , NET_LOGON_CTRL    , api_net_logon_ctrl     },
00390       { "NET_SAMLOGON_EX"   , NET_SAMLOGON_EX   , api_net_sam_logon_ex   },
00391 #if 0   /* JERRY */
00392       { "DS_ENUM_DOM_TRUSTS", DS_ENUM_DOM_TRUSTS, api_ds_enum_dom_trusts }
00393 #endif  /* JERRY */
00394     };
00395 
00396 void netlog_get_pipe_fns( struct api_struct **fns, int *n_fns )
00397 {
00398         *fns = api_net_cmds;
00399         *n_fns = sizeof(api_net_cmds) / sizeof(struct api_struct);
00400 }
00401 
00402 NTSTATUS rpc_net_init(void)
00403 {
00404   return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "NETLOGON", "lsass", api_net_cmds,
00405                                     sizeof(api_net_cmds) / sizeof(struct api_struct));
00406 }

Sambaに対してSat Aug 29 21:23:19 2009に生成されました。  doxygen 1.4.7