|
Sams Teach Yourself Samba in 24 Hours |
|||||||||||||||||
|
Hour 10: Server-Side Automation |
|||||||||||||||||
|
You have already seen some uses for variables. For example, you used the %m variable in the log file parameter value to provide logs on a per-machine basis. You could also do the same on a per-user basis with the following:
log file = /usr/local/samba/var/log.%U
So far, I have not really explained the difference between %u and %U. Both variables are expanded to a username, but the %U variable is expanded to the username sent during the session setup. For example, here is a portion of the tcpdump output I showed you in Hour 6, "Security Levels and Passwords." The packet was transmitted from a Windows 95 OSR2 client and contains the password testpass and username boss:
[000] 54 45 53 54 50 41 53 53 00 00 00 00 00 00 42 4F TESTPASS ......BO [010] 53 53 00 00 00 00 00 00 42 4F 53 53 00 43 48 49 SS...... BOSS.CHI [020] 50 53 4E 44 49 50 53 00 57 69 6E 64 6F 77 73 20 PSNDIPS. Windows [030] 34 2E 30 00 57 69 6E 64 6F 77 73 20 34 2E 30 00 4.0.Wind ows 4.0.
The log file created for this connection would be
/usr/local/samba/var/log.boss
The %u variable is expanded to the username of the current service. Normally %U and %u are the same except under certain circumstances such as when using the force user parameter in user-level security.
Here's an example when %U and %u are different. Let's use this service definition for [src]:
[src]
root preexec = echo "%T : U is %U and u is %u" >> /var/log/log.src
comment = /usr/local/src
path = /usr/local/src
create mode = 0644
directory mode = 0755
force user = jerryc
As you can tell, the preexec value simply logs the values of %U and %u to file. This is the easiest way to determine what values Samba is using.
The smbclient is a good testing tool for this type of experimentation. I'll simply specify that I want to connect to the [src] service using the username boss:
/usr/local/samba/bin/smbclient //bilbo/src -U boss Added interface ip=192.168.1.73 bcast=192.168.1.255 nmask=255.255.255.0 Password: Domain=[FOWLPLAY] OS=[Unix] Server=[Samba 2.0.0beta5] smb: \>
Now if I look at the output that was created in /var/log/log.src, I see that %U expanded to the username I specified with which to connect, boss, and that the actual username I was accessing the service as was jerryc:
1999/01/09 10:08:02 : U is boss and u is jerryc
The %G and %g variables are directly related to the %U and %u variables. The discussion of the difference between the two group variables is analogous to the differences between the two username parameters.
|
Sams Teach Yourself Samba in 24 Hours |
|||||||||||||||||
|
Hour 10: Server-Side Automation |
|||||||||||||||||
|
© Copyright Macmillan USA. All rights reserved.