34d7ce70932961701a6d96fada0d421f9f5a2ed6
[ira/wip.git] / docs / textdocs / security_level.txt
1 Description of SMB security levels.
2 ----------------------------------
3
4
5 A SMB server tells the client at startup what "security level" it is
6 running. There are two options "share level" and "user level". Which
7 of these two the client receives affects the way the client then tries
8 to authenticate itself. It does not directly affect (to any great
9 extent) the way the Samba server does security. I know this is
10 strange, but it fits in with the client/server approach of SMB. In SMB
11 everything is initiated and controlled by the client, and the server
12 can only tell the client what is available and whether an action is
13 allowed. 
14
15 I'll describe user level security first, as its simpler. In user level
16 security the client will send a "session setup" command directly after
17 the protocol negotiation. This contains a username and password. The
18 server can either accept or reject that username/password
19 combination. Note that at this stage the server has no idea what
20 share the client will eventually try to connect to, so it can't base
21 the "accept/reject" on anything other than:
22
23 - the username/password
24 - the machine that the client is coming from
25
26 If the server accepts the username/password then the client expects to
27 be able to mount any share (using a "tree connection") without
28 specifying a password. It expects that all access rights will be as
29 the username/password specified in the "session setup". 
30
31 It is also possible for a client to send multiple "session setup"
32 requests. When the server responds it gives the client a "uid" to use
33 as an authentication tag for that username/password. The client can
34 maintain multiple authentication contexts in this way (WinDD is an
35 example of an application that does this)
36
37
38 Ok, now for share level security. In share level security (the default
39 with samba) the client authenticates itself separately for each
40 share. It will send a password along with each "tree connection"
41 (share mount). It does not explicitly send a username with this
42 operation. The client is expecting a password to be associated with
43 each share, independent of the user. This means that samba has to work
44 out what username the client probably wants to use. It is never
45 explicitly sent the username. Some commercial SMB servers such as NT actually
46 associate passwords directly with shares in share level security, but
47 samba always uses the unix authentication scheme where it is a
48 username/password that is authenticated, not a "share/password".
49
50 Many clients send a "session setup" even if the server is in share
51 level security. They normally send a valid username but no
52 password. Samba records this username in a list of "possible
53 usernames". When the client then does a "tree connection" it also adds
54 to this list the name of the share they try to connect to (useful for
55 home directories) and any users listed in the "user =" smb.conf
56 line. The password is then checked in turn against these "possible
57 usernames". If a match is found then the client is authenticated as
58 that user.
59
60 Finally "server level" security. In server level security the samba
61 server reports to the client that it is in user level security. The
62 client then does a "session setup" as described earlier. The samba
63 server takes the username/password that the client sends and attempts
64 to login to the "password server" by sending exactly the same
65 username/password that it got from the client. If that server is in
66 user level security and accepts the password then samba accepts the
67 clients connection. This allows the samba server to use another SMB
68 server as the "password server". 
69
70 You should also note that at the very start of all this, where the
71 server tells the client what security level it is in, it also tells
72 the client if it supports encryption. If it does then it supplies the
73 client with a random "cryptkey". The client will then send all
74 passwords in encrypted form. You have to compile samba with encryption
75 enabled to support this feature, and you have to maintain a separate
76 smbpasswd file with SMB style encrypted passwords. It is
77 cryptographically impossible to translate from unix style encryption
78 to SMB style encryption, although there are some fairly simple management
79 schemes by which the two could be kept in sync.