1998-09-26 02:34:40 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
1998-09-26 02:34:40 +04:00
SMB parameters and setup
Copyright ( C ) Andrew Tridgell 1992 - 1998
Copyright ( C ) Luke Kenneth Casson Leighton 1996 - 1998
Copyright ( C ) Jeremy Allison 1998
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 .
*/
# ifndef _CLIENT_H
# define _CLIENT_H
1998-10-04 11:50:44 +04:00
/* the client asks for a smaller buffer to save ram and also to get more
1998-10-04 13:42:51 +04:00
overlap on the wire . This size gives us a nice read / write size , which
will be a multiple of the page size on almost any system */
1999-12-13 16:27:58 +03:00
# define CLI_BUFFER_SIZE (0xFFFF)
1998-10-04 11:50:44 +04:00
2001-02-20 11:09:06 +03:00
1998-09-26 02:34:40 +04:00
/*
* These definitions depend on smb . h
*/
1998-10-02 16:34:14 +04:00
typedef struct file_info
1998-09-29 01:43:48 +04:00
{
2002-12-11 02:44:33 +03:00
SMB_BIG_UINT size ;
1998-11-09 23:33:37 +03:00
uint16 mode ;
1998-10-24 12:08:05 +04:00
uid_t uid ;
gid_t gid ;
/* these times are normally kept in GMT */
time_t mtime ;
time_t atime ;
time_t ctime ;
pstring name ;
2001-09-25 09:20:43 +04:00
char short_name [ 13 * 3 ] ; /* the *3 is to cope with multi-byte */
1998-09-29 01:43:48 +04:00
} file_info ;
1998-10-04 13:42:51 +04:00
struct print_job_info
{
uint16 id ;
uint16 priority ;
size_t size ;
fstring user ;
fstring name ;
time_t t ;
} ;
1999-12-13 16:27:58 +03:00
struct cli_state {
1999-01-25 04:46:14 +03:00
int port ;
1998-10-09 03:57:46 +04:00
int fd ;
2002-10-01 10:50:38 +04:00
int smb_rw_error ; /* Copy of last read or write error. */
1998-10-09 03:57:46 +04:00
uint16 cnum ;
uint16 pid ;
uint16 mid ;
uint16 vuid ;
int protocol ;
int sec_mode ;
int rap_error ;
1999-11-25 01:45:09 +03:00
int privileges ;
1998-10-09 03:57:46 +04:00
fstring desthost ;
1999-12-13 16:27:58 +03:00
fstring user_name ;
fstring domain ;
1998-10-09 03:57:46 +04:00
1998-11-13 01:17:51 +03:00
/*
* The following strings are the
* ones returned by the server if
* the protocol > NT1 .
*/
fstring server_type ;
fstring server_os ;
fstring server_domain ;
1998-10-09 03:57:46 +04:00
fstring share ;
fstring dev ;
struct nmb_name called ;
struct nmb_name calling ;
1999-12-13 16:27:58 +03:00
fstring full_dest_host_name ;
1998-10-09 03:57:46 +04:00
struct in_addr dest_ip ;
1999-12-13 16:27:58 +03:00
struct pwd_info pwd ;
2001-10-11 11:42:52 +04:00
DATA_BLOB secblob ; /* cryptkey or negTokenInit */
1998-10-09 03:57:46 +04:00
uint32 sesskey ;
int serverzone ;
uint32 servertime ;
int readbraw_supported ;
int writebraw_supported ;
1999-12-13 16:27:58 +03:00
int timeout ; /* in milliseconds. */
2003-03-18 02:04:03 +03:00
size_t max_xmit ;
size_t max_mux ;
1998-10-09 03:57:46 +04:00
char * outbuf ;
char * inbuf ;
2003-03-13 03:51:05 +03:00
unsigned int bufsize ;
1998-10-09 03:57:46 +04:00
int initialised ;
int win95 ;
uint32 capabilities ;
2000-07-27 04:47:19 +04:00
TALLOC_CTX * mem_ctx ;
2002-07-15 14:35:28 +04:00
smb_sign_info sign_info ;
2003-02-24 05:55:00 +03:00
/* the session key for this CLI, outside
any per - pipe authenticaion */
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
DATA_BLOB user_session_key ;
2003-02-24 05:55:00 +03:00
1998-10-09 03:57:46 +04:00
/*
* Only used in NT domain calls .
*/
Jeremy requested that I get my NTLMSSP patch into CVS. He didn't request
the schannel code, but I've included that anyway. :-)
This patch revives the client-side NTLMSSP support for RPC named pipes
in Samba, and cleans up the client and server schannel code. The use of the
new code is enabled by the 'sign', 'seal' and 'schannel' commands in
rpcclient.
The aim was to prove that our separate NTLMSSP client library actually
implements NTLMSSP signing and sealing as per Microsoft's NTLMv1 implementation,
in the hope that knowing this will assist us in correctly implementing
NTLMSSP signing for SMB packets. (Still not yet functional)
This patch replaces the NTLMSSP implementation in rpc_client/cli_pipe.c with
calls to libsmb/ntlmssp.c. In the process, we have gained the ability to
use the more secure NT password, and the ability to sign-only, instead of
having to seal the pipe connection. (Previously we were limited to sealing,
and could only use the LM-password derived key).
Our new client-side NTLMSSP code also needed alteration to cope with our
comparatively simple server-side implementation. A future step is to replace
it with calls to the same NTLMSSP library.
Also included in this patch is the schannel 'sign only' patch I submitted to
the team earlier. While not enabled (and not functional, at this stage) the
work in this patch makes the code paths *much* easier to follow. I have also
included similar hooks in rpccleint to allow the use of schannel on *any* pipe.
rpcclient now defaults to not using schannel (or any other extra per-pipe
authenticiation) for any connection. The 'schannel' command enables schannel
for all pipes until disabled.
This code is also much more secure than the previous code, as changes to our
cli_pipe routines ensure that the authentication footer cannot be removed
by an attacker, and more error states are correctly handled.
(The same needs to be done to our server)
Andrew Bartlett
(This used to be commit 5472ddc9eaf4e79c5b2e1c8ee8c7f190dc285f19)
2003-07-14 12:46:32 +04:00
int pipe_idx ; /* Index (into list of known pipes)
of the pipe we ' re talking to ,
if any */
1999-12-13 16:27:58 +03:00
uint16 nt_pipe_fnum ; /* Pipe handle. */
2003-04-09 19:54:17 +04:00
Jeremy requested that I get my NTLMSSP patch into CVS. He didn't request
the schannel code, but I've included that anyway. :-)
This patch revives the client-side NTLMSSP support for RPC named pipes
in Samba, and cleans up the client and server schannel code. The use of the
new code is enabled by the 'sign', 'seal' and 'schannel' commands in
rpcclient.
The aim was to prove that our separate NTLMSSP client library actually
implements NTLMSSP signing and sealing as per Microsoft's NTLMv1 implementation,
in the hope that knowing this will assist us in correctly implementing
NTLMSSP signing for SMB packets. (Still not yet functional)
This patch replaces the NTLMSSP implementation in rpc_client/cli_pipe.c with
calls to libsmb/ntlmssp.c. In the process, we have gained the ability to
use the more secure NT password, and the ability to sign-only, instead of
having to seal the pipe connection. (Previously we were limited to sealing,
and could only use the LM-password derived key).
Our new client-side NTLMSSP code also needed alteration to cope with our
comparatively simple server-side implementation. A future step is to replace
it with calls to the same NTLMSSP library.
Also included in this patch is the schannel 'sign only' patch I submitted to
the team earlier. While not enabled (and not functional, at this stage) the
work in this patch makes the code paths *much* easier to follow. I have also
included similar hooks in rpccleint to allow the use of schannel on *any* pipe.
rpcclient now defaults to not using schannel (or any other extra per-pipe
authenticiation) for any connection. The 'schannel' command enables schannel
for all pipes until disabled.
This code is also much more secure than the previous code, as changes to our
cli_pipe routines ensure that the authentication footer cannot be removed
by an attacker, and more error states are correctly handled.
(The same needs to be done to our server)
Andrew Bartlett
(This used to be commit 5472ddc9eaf4e79c5b2e1c8ee8c7f190dc285f19)
2003-07-14 12:46:32 +04:00
/* Secure pipe parameters */
int pipe_auth_flags ;
2003-04-09 19:54:17 +04:00
uint16 saved_netlogon_pipe_fnum ; /* The "first" pipe to get
the session key for the
schannel . */
struct netsec_auth_struct auth_info ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
NTLMSSP_STATE * ntlmssp_pipe_state ;
Jeremy requested that I get my NTLMSSP patch into CVS. He didn't request
the schannel code, but I've included that anyway. :-)
This patch revives the client-side NTLMSSP support for RPC named pipes
in Samba, and cleans up the client and server schannel code. The use of the
new code is enabled by the 'sign', 'seal' and 'schannel' commands in
rpcclient.
The aim was to prove that our separate NTLMSSP client library actually
implements NTLMSSP signing and sealing as per Microsoft's NTLMv1 implementation,
in the hope that knowing this will assist us in correctly implementing
NTLMSSP signing for SMB packets. (Still not yet functional)
This patch replaces the NTLMSSP implementation in rpc_client/cli_pipe.c with
calls to libsmb/ntlmssp.c. In the process, we have gained the ability to
use the more secure NT password, and the ability to sign-only, instead of
having to seal the pipe connection. (Previously we were limited to sealing,
and could only use the LM-password derived key).
Our new client-side NTLMSSP code also needed alteration to cope with our
comparatively simple server-side implementation. A future step is to replace
it with calls to the same NTLMSSP library.
Also included in this patch is the schannel 'sign only' patch I submitted to
the team earlier. While not enabled (and not functional, at this stage) the
work in this patch makes the code paths *much* easier to follow. I have also
included similar hooks in rpccleint to allow the use of schannel on *any* pipe.
rpcclient now defaults to not using schannel (or any other extra per-pipe
authenticiation) for any connection. The 'schannel' command enables schannel
for all pipes until disabled.
This code is also much more secure than the previous code, as changes to our
cli_pipe routines ensure that the authentication footer cannot be removed
by an attacker, and more error states are correctly handled.
(The same needs to be done to our server)
Andrew Bartlett
(This used to be commit 5472ddc9eaf4e79c5b2e1c8ee8c7f190dc285f19)
2003-07-14 12:46:32 +04:00
1998-10-09 03:57:46 +04:00
unsigned char sess_key [ 16 ] ; /* Current session key. */
DOM_CRED clnt_cred ; /* Client credential. */
1999-12-13 16:27:58 +03:00
fstring mach_acct ; /* MYNAME$. */
fstring srv_name_slash ; /* \\remote server. */
fstring clnt_name_slash ; /* \\local client. */
1998-10-15 09:47:29 +04:00
uint16 max_xmit_frag ;
uint16 max_recv_frag ;
Jeremy requested that I get my NTLMSSP patch into CVS. He didn't request
the schannel code, but I've included that anyway. :-)
This patch revives the client-side NTLMSSP support for RPC named pipes
in Samba, and cleans up the client and server schannel code. The use of the
new code is enabled by the 'sign', 'seal' and 'schannel' commands in
rpcclient.
The aim was to prove that our separate NTLMSSP client library actually
implements NTLMSSP signing and sealing as per Microsoft's NTLMv1 implementation,
in the hope that knowing this will assist us in correctly implementing
NTLMSSP signing for SMB packets. (Still not yet functional)
This patch replaces the NTLMSSP implementation in rpc_client/cli_pipe.c with
calls to libsmb/ntlmssp.c. In the process, we have gained the ability to
use the more secure NT password, and the ability to sign-only, instead of
having to seal the pipe connection. (Previously we were limited to sealing,
and could only use the LM-password derived key).
Our new client-side NTLMSSP code also needed alteration to cope with our
comparatively simple server-side implementation. A future step is to replace
it with calls to the same NTLMSSP library.
Also included in this patch is the schannel 'sign only' patch I submitted to
the team earlier. While not enabled (and not functional, at this stage) the
work in this patch makes the code paths *much* easier to follow. I have also
included similar hooks in rpccleint to allow the use of schannel on *any* pipe.
rpcclient now defaults to not using schannel (or any other extra per-pipe
authenticiation) for any connection. The 'schannel' command enables schannel
for all pipes until disabled.
This code is also much more secure than the previous code, as changes to our
cli_pipe routines ensure that the authentication footer cannot be removed
by an attacker, and more error states are correctly handled.
(The same needs to be done to our server)
Andrew Bartlett
(This used to be commit 5472ddc9eaf4e79c5b2e1c8ee8c7f190dc285f19)
2003-07-14 12:46:32 +04:00
2001-10-12 08:49:42 +04:00
BOOL use_kerberos ;
2001-10-22 10:48:35 +04:00
BOOL use_spnego ;
1998-09-26 02:34:40 +04:00
1999-12-13 16:27:58 +03:00
BOOL use_oplocks ; /* should we use oplocks? */
2000-11-16 03:59:18 +03:00
BOOL use_level_II_oplocks ; /* should we use level II oplocks? */
2001-06-18 12:26:15 +04:00
/* a oplock break request handler */
BOOL ( * oplock_handler ) ( struct cli_state * cli , int fnum , unsigned char level ) ;
2001-11-25 05:58:15 +03:00
BOOL force_dos_errors ;
2004-06-15 22:36:45 +04:00
BOOL case_sensitive ; /* False by default. */
2001-11-27 06:29:20 +03:00
/* was this structure allocated by cli_initialise? If so, then
free in cli_shutdown ( ) */
BOOL allocated ;
2002-01-02 08:38:09 +03:00
/* Name of the pipe we're talking to, if any */
fstring pipe_name ;
1999-12-13 16:27:58 +03:00
} ;
1999-11-28 00:50:11 +03:00
2002-07-15 14:35:28 +04:00
# define CLI_FULL_CONNECTION_DONT_SPNEGO 0x0001
# define CLI_FULL_CONNECTION_USE_KERBEROS 0x0002
# define CLI_FULL_CONNECTION_ANNONYMOUS_FALLBACK 0x0004
1998-09-26 02:34:40 +04:00
# endif /* _CLIENT_H */