2005-09-22 22:35:08 +04:00
/*
Unix SMB / CIFS implementation .
Main winbindd samba3 server routines
Copyright ( C ) Stefan Metzmacher 2005
Copyright ( C ) Volker Lendecke 2005
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
# include "nsswitch/winbindd_nss.h"
# include "winbind/wb_server.h"
# include "winbind/wb_samba3_protocol.h"
uint32_t wbsrv_samba3_packet_length ( DATA_BLOB blob )
{
uint32_t * len = ( uint32_t * ) blob . data ;
return * len ;
}
2005-10-01 20:36:04 +04:00
NTSTATUS wbsrv_samba3_pull_request ( DATA_BLOB blob , TALLOC_CTX * mem_ctx ,
struct wbsrv_call * * _call )
2005-09-22 22:35:08 +04:00
{
struct wbsrv_call * call ;
struct wbsrv_samba3_call * s3_call ;
if ( blob . length ! = sizeof ( s3_call - > request ) ) {
2005-11-30 06:20:25 +03:00
DEBUG ( 0 , ( " wbsrv_samba3_pull_request: invalid blob length %lu should be %lu \n "
2005-09-22 22:35:08 +04:00
" make sure you use the correct winbind client tools! \n " ,
2005-11-30 06:20:25 +03:00
( long ) blob . length , ( long ) sizeof ( s3_call - > request ) ) ) ;
2005-09-22 22:35:08 +04:00
return NT_STATUS_INVALID_PARAMETER ;
}
call = talloc_zero ( mem_ctx , struct wbsrv_call ) ;
NT_STATUS_HAVE_NO_MEMORY ( call ) ;
s3_call = talloc_zero ( call , struct wbsrv_samba3_call ) ;
NT_STATUS_HAVE_NO_MEMORY ( s3_call ) ;
2005-09-23 04:38:22 +04:00
s3_call - > call = call ;
2005-09-22 22:35:08 +04:00
/* the packet layout is the same as the in memory layout of the request, so just copy it */
memcpy ( & s3_call - > request , blob . data , sizeof ( s3_call - > request ) ) ;
call - > private_data = s3_call ;
* _call = call ;
return NT_STATUS_OK ;
}
NTSTATUS wbsrv_samba3_handle_call ( struct wbsrv_call * call )
{
struct wbsrv_samba3_call * s3call = talloc_get_type ( call - > private_data ,
struct wbsrv_samba3_call ) ;
DEBUG ( 10 , ( " Got winbind samba3 request %d \n " , s3call - > request . cmd ) ) ;
2005-10-19 17:45:44 +04:00
s3call - > response . length = sizeof ( s3call - > response ) ;
2005-09-22 22:35:08 +04:00
switch ( s3call - > request . cmd ) {
case WINBINDD_INTERFACE_VERSION :
return wbsrv_samba3_interface_version ( s3call ) ;
2005-11-06 02:46:57 +03:00
#if 0
2005-09-26 17:42:42 +04:00
case WINBINDD_CHECK_MACHACC :
return wbsrv_samba3_check_machacc ( s3call ) ;
2005-11-06 02:46:57 +03:00
# endif
2005-09-22 22:35:08 +04:00
case WINBINDD_PING :
return wbsrv_samba3_ping ( s3call ) ;
2005-09-26 01:01:56 +04:00
2005-09-26 17:42:42 +04:00
case WINBINDD_INFO :
2005-10-15 01:41:08 +04:00
return wbsrv_samba3_info ( s3call ) ;
2005-09-26 17:42:42 +04:00
case WINBINDD_DOMAIN_NAME :
return wbsrv_samba3_domain_name ( s3call ) ;
case WINBINDD_NETBIOS_NAME :
return wbsrv_samba3_netbios_name ( s3call ) ;
case WINBINDD_PRIV_PIPE_DIR :
return wbsrv_samba3_priv_pipe_dir ( s3call ) ;
2005-10-03 21:36:49 +04:00
case WINBINDD_LOOKUPNAME :
return wbsrv_samba3_lookupname ( s3call ) ;
2005-10-09 16:13:05 +04:00
2005-10-19 17:45:44 +04:00
case WINBINDD_LOOKUPSID :
return wbsrv_samba3_lookupsid ( s3call ) ;
2005-10-09 16:13:05 +04:00
case WINBINDD_PAM_AUTH :
return wbsrv_samba3_pam_auth ( s3call ) ;
case WINBINDD_PAM_AUTH_CRAP :
return wbsrv_samba3_pam_auth_crap ( s3call ) ;
2005-10-16 02:01:15 +04:00
case WINBINDD_GETDCNAME :
return wbsrv_samba3_getdcname ( s3call ) ;
2005-10-16 16:43:09 +04:00
case WINBINDD_GETUSERDOMGROUPS :
return wbsrv_samba3_userdomgroups ( s3call ) ;
2005-10-19 17:45:44 +04:00
case WINBINDD_GETUSERSIDS :
return wbsrv_samba3_usersids ( s3call ) ;
2005-10-20 01:53:03 +04:00
case WINBINDD_LIST_TRUSTDOM :
return wbsrv_samba3_list_trustdom ( s3call ) ;
2005-11-10 06:48:56 +03:00
/* Unimplemented commands */
case WINBINDD_GETPWNAM :
case WINBINDD_GETPWUID :
case WINBINDD_GETGRNAM :
case WINBINDD_GETGRGID :
case WINBINDD_GETGROUPS :
case WINBINDD_SETPWENT :
case WINBINDD_ENDPWENT :
case WINBINDD_GETPWENT :
case WINBINDD_SETGRENT :
case WINBINDD_ENDGRENT :
case WINBINDD_GETGRENT :
case WINBINDD_PAM_CHAUTHTOK :
case WINBINDD_LIST_USERS :
case WINBINDD_LIST_GROUPS :
case WINBINDD_SID_TO_UID :
case WINBINDD_SID_TO_GID :
case WINBINDD_UID_TO_SID :
case WINBINDD_GID_TO_SID :
case WINBINDD_ALLOCATE_RID :
case WINBINDD_ALLOCATE_RID_AND_GID :
case WINBINDD_CHECK_MACHACC :
case WINBINDD_DOMAIN_INFO :
case WINBINDD_SHOW_SEQUENCE :
case WINBINDD_WINS_BYIP :
case WINBINDD_WINS_BYNAME :
case WINBINDD_GETGRLST :
case WINBINDD_INIT_CONNECTION :
case WINBINDD_DUAL_SID2UID :
case WINBINDD_DUAL_SID2GID :
case WINBINDD_DUAL_IDMAPSET :
case WINBINDD_DUAL_UID2NAME :
case WINBINDD_DUAL_NAME2UID :
case WINBINDD_DUAL_GID2NAME :
case WINBINDD_DUAL_NAME2GID :
case WINBINDD_DUAL_USERINFO :
case WINBINDD_DUAL_GETSIDALIASES :
case WINBINDD_NUM_CMDS :
DEBUG ( 10 , ( " Unimplemented winbind samba3 request %d \n " ,
s3call - > request . cmd ) ) ;
break ;
2005-09-22 22:35:08 +04:00
}
s3call - > response . result = WINBINDD_ERROR ;
return NT_STATUS_OK ;
}
NTSTATUS wbsrv_samba3_push_reply ( struct wbsrv_call * call , TALLOC_CTX * mem_ctx , DATA_BLOB * _blob )
{
struct wbsrv_samba3_call * s3call = talloc_get_type ( call - > private_data ,
struct wbsrv_samba3_call ) ;
DATA_BLOB blob ;
uint8_t * extra_data ;
size_t extra_data_len = 0 ;
extra_data = s3call - > response . extra_data ;
if ( extra_data ) {
2005-10-19 17:45:44 +04:00
extra_data_len = s3call - > response . length -
sizeof ( s3call - > response ) ;
2005-09-22 22:35:08 +04:00
}
2005-10-19 17:45:44 +04:00
blob = data_blob_talloc ( mem_ctx , NULL , s3call - > response . length ) ;
2005-09-22 22:35:08 +04:00
NT_STATUS_HAVE_NO_MEMORY ( blob . data ) ;
/* don't push real pointer values into sockets */
if ( extra_data ) {
s3call - > response . extra_data = ( void * ) 0xFFFFFFFF ;
}
memcpy ( blob . data , & s3call - > response , sizeof ( s3call - > response ) ) ;
/* set back the pointer */
s3call - > response . extra_data = extra_data ;
if ( extra_data ) {
memcpy ( blob . data + sizeof ( s3call - > response ) , extra_data , extra_data_len ) ;
}
* _blob = blob ;
return NT_STATUS_OK ;
}