15331Samw /* 25331Samw * CDDL HEADER START 35331Samw * 45331Samw * The contents of this file are subject to the terms of the 55331Samw * Common Development and Distribution License (the "License"). 65331Samw * You may not use this file except in compliance with the License. 75331Samw * 85331Samw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 95331Samw * or http://www.opensolaris.org/os/licensing. 105331Samw * See the License for the specific language governing permissions 115331Samw * and limitations under the License. 125331Samw * 135331Samw * When distributing Covered Code, include this CDDL HEADER in each 145331Samw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 155331Samw * If applicable, add the following below this CDDL HEADER, with the 165331Samw * fields enclosed by brackets "[]" replaced with your own identifying 175331Samw * information: Portions Copyright [yyyy] [name of copyright owner] 185331Samw * 195331Samw * CDDL HEADER END 205331Samw */ 215331Samw /* 22*7619SJose.Borrego@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 235331Samw * Use is subject to license terms. 245331Samw */ 255331Samw 265331Samw /* 275331Samw * NetLogon RPC (NETR) interface definition. This module provides 285331Samw * the server side NETR RPC interface and the interface registration 295331Samw * function. 305331Samw */ 315331Samw 325331Samw #include <strings.h> 335331Samw 345331Samw #include <smbsrv/libsmb.h> 355331Samw #include <smbsrv/mlsvc_util.h> 365331Samw #include <smbsrv/ndl/netlogon.ndl> 375331Samw #include <smbsrv/ntstatus.h> 385331Samw #include <smbsrv/nterror.h> 395331Samw #include <smbsrv/nmpipes.h> 405331Samw #include <smbsrv/netrauth.h> 415331Samw 425331Samw static int netr_s_ServerReqChallenge(void *, struct mlrpc_xaction *); 435331Samw static int netr_s_ServerAuthenticate2(void *, struct mlrpc_xaction *); 445331Samw static int netr_s_ServerPasswordSet(void *, struct mlrpc_xaction *); 455331Samw static int netr_s_SamLogon(void *, struct mlrpc_xaction *); 465331Samw static int netr_s_SamLogoff(void *, struct mlrpc_xaction *); 475331Samw 485331Samw static mlrpc_stub_table_t netr_stub_table[] = { 495331Samw { netr_s_ServerReqChallenge, NETR_OPNUM_ServerReqChallenge }, 505331Samw { netr_s_ServerAuthenticate2, NETR_OPNUM_ServerAuthenticate2 }, 515331Samw { netr_s_ServerPasswordSet, NETR_OPNUM_ServerPasswordSet }, 525331Samw { netr_s_SamLogon, NETR_OPNUM_SamLogon }, 535331Samw { netr_s_SamLogoff, NETR_OPNUM_SamLogoff }, 545331Samw {0} 555331Samw }; 565331Samw 575331Samw static mlrpc_service_t netr_service = { 585331Samw "NETR", /* name */ 595331Samw "NetLogon", /* desc */ 605331Samw "\\netlogon", /* endpoint */ 615331Samw PIPE_LSASS, /* sec_addr_port */ 625331Samw "12345678-1234-abcd-ef0001234567cffb", 1, /* abstract */ 635331Samw "8a885d04-1ceb-11c9-9fe808002b104860", 2, /* transfer */ 645331Samw 0, /* no bind_instance_size */ 655331Samw 0, /* no bind_req() */ 665331Samw 0, /* no unbind_and_close() */ 675331Samw 0, /* use generic_call_stub() */ 685331Samw &TYPEINFO(netr_interface), /* interface ti */ 695331Samw netr_stub_table /* stub_table */ 705331Samw }; 715331Samw 725331Samw /* 735331Samw * netr_initialize 745331Samw * 755331Samw * This function registers the NETR RPC interface with the RPC runtime 765331Samw * library. It must be called in order to use either the client side 775331Samw * or the server side functions. 785331Samw */ 795331Samw void 805331Samw netr_initialize(void) 815331Samw { 825331Samw (void) mlrpc_register_service(&netr_service); 835331Samw } 845331Samw 855331Samw /* 865331Samw * netr_s_ServerReqChallenge 875331Samw */ 885331Samw /*ARGSUSED*/ 895331Samw static int 905331Samw netr_s_ServerReqChallenge(void *arg, struct mlrpc_xaction *mxa) 915331Samw { 925331Samw struct netr_ServerReqChallenge *param = arg; 935331Samw 945331Samw bzero(param, sizeof (struct netr_ServerReqChallenge)); 955331Samw param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED); 965331Samw return (MLRPC_DRC_OK); 975331Samw } 985331Samw 995331Samw /* 1005331Samw * netr_s_ServerAuthenticate2 1015331Samw */ 1025331Samw /*ARGSUSED*/ 1035331Samw static int 1045331Samw netr_s_ServerAuthenticate2(void *arg, struct mlrpc_xaction *mxa) 1055331Samw { 1065331Samw struct netr_ServerAuthenticate2 *param = arg; 1075331Samw 1085331Samw bzero(param, sizeof (struct netr_ServerAuthenticate2)); 1095331Samw param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED); 1105331Samw return (MLRPC_DRC_OK); 1115331Samw } 1125331Samw 1135331Samw /* 1145331Samw * netr_s_ServerPasswordSet 1155331Samw */ 1165331Samw /*ARGSUSED*/ 1175331Samw static int 1185331Samw netr_s_ServerPasswordSet(void *arg, struct mlrpc_xaction *mxa) 1195331Samw { 1205331Samw struct netr_PasswordSet *param = arg; 1215331Samw 1225331Samw bzero(param, sizeof (struct netr_PasswordSet)); 1235331Samw param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED); 1245331Samw return (MLRPC_DRC_OK); 1255331Samw } 1265331Samw 1275331Samw /* 1285331Samw * netr_s_SamLogon 1295331Samw */ 1305331Samw /*ARGSUSED*/ 1315331Samw static int 1325331Samw netr_s_SamLogon(void *arg, struct mlrpc_xaction *mxa) 1335331Samw { 1345331Samw struct netr_SamLogon *param = arg; 1355331Samw 1365331Samw bzero(param, sizeof (struct netr_SamLogon)); 1375331Samw param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED); 1385331Samw return (MLRPC_DRC_OK); 1395331Samw } 1405331Samw 1415331Samw /* 1425331Samw * netr_s_SamLogoff 1435331Samw */ 1445331Samw /*ARGSUSED*/ 1455331Samw static int 1465331Samw netr_s_SamLogoff(void *arg, struct mlrpc_xaction *mxa) 1475331Samw { 1485331Samw struct netr_SamLogoff *param = arg; 1495331Samw 1505331Samw bzero(param, sizeof (struct netr_SamLogoff)); 1515331Samw param->status = NT_SC_ERROR(NT_STATUS_ACCESS_DENIED); 1525331Samw return (MLRPC_DRC_OK); 1535331Samw } 1545331Samw 1555331Samw /* 1565331Samw * Declare extern references. 1575331Samw */ 1585331Samw DECL_FIXUP_STRUCT(netr_validation_u); 1595331Samw DECL_FIXUP_STRUCT(netr_validation_info); 1605331Samw DECL_FIXUP_STRUCT(netr_SamLogon); 1615331Samw 1625331Samw /* 1635331Samw * Patch the netr_SamLogon union. 1645331Samw * This function is called from mlsvc_netr_ndr.c 1655331Samw */ 1665331Samw void 1675331Samw fixup_netr_SamLogon(struct netr_SamLogon *arg) 1685331Samw { 1695331Samw unsigned short size1 = 0; 1705331Samw unsigned short size2 = 0; 1715331Samw unsigned short size3 = 0; 1725331Samw WORD level = (WORD)arg->validation_level; 1735331Samw 1745331Samw switch (level) { 1755331Samw case 3: 1765331Samw /* 1775331Samw * The netr_validation_u union contains a pointer, which 1785331Samw * is a DWORD in NDR. So we need to set size1 to ensure 1795331Samw * that we can correctly decode the remaining parameters. 1805331Samw */ 1815331Samw size1 = sizeof (DWORD); 1825331Samw break; 1835331Samw 1845331Samw default: 1855331Samw /* 1865331Samw * If the request is badly formed or the level is invalid, 1875331Samw * the server returns NT_STATUS_INVALID_INFO_CLASS. Size1 1885331Samw * must be zero to correctly decode the status. 1895331Samw */ 1905331Samw size1 = 0; 1915331Samw break; 1925331Samw }; 1935331Samw 1945331Samw size2 = size1 + (2 * sizeof (DWORD)); 195*7619SJose.Borrego@Sun.COM size3 = size2 + sizeof (ndr_request_hdr_t) + sizeof (DWORD); 1965331Samw 1975331Samw FIXUP_PDU_SIZE(netr_validation_u, size1); 1985331Samw FIXUP_PDU_SIZE(netr_validation_info, size2); 1995331Samw FIXUP_PDU_SIZE(netr_SamLogon, size3); 2005331Samw } 201