r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / client / cifs_resolver.sh
blob2229d5a5f5b4d0bef0084646198df10b23d0fda1
1 #!/bin/sh
2 ###############################################################################
4 # Written by Igor Mammedov (niallain@gmail.com)
5 # Modified by Steve French <sfrench@samba.org>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version
10 # 2 of the License, or (at your option) any later version.
12 ###############################################################################
14 # linux-cifs-client dns name resolver helper
15 # called by cifs kernel module upcall to key API to resolve server name
16 # to IP when module connects to DFS link. We may eventually make this
17 # C code, but this is a good starting point.
18 # You should have appropriate kernel and keyutils installed.
19 # CIFS DFS Support will require Linux kernel module
20 # cifs.ko version 1.48 or later.
22 # Consult the CIFS client users guide for more details
23 # http://www.samba.org/samba/ftp/cifs-cvs/linux-cifs-client-guide.pdf
25 # Put the following string in /etc/request-key.conf without comment sign :)
26 # create cifs_resolver * * /sbin/cifs_resolver.sh %k %d %S
28 # Put this script into /sbin directory
29 # Call: /sbin/cifs_resolver.sh <keyid> <desc> <session-keyring>
31 # <desc> - is server name to resolve
34 status=0
36 echo "cifs_resolver: resolving: $2"
38 DATAA=`/usr/bin/host $2`
39 status=$?
41 if [ "x$status" != "x0" ]; then
42 echo "cifs_resolver: failed to resolve: $2"
43 exit $status
44 else
45 DATAA=`echo "$DATAA" | sed 's/.*has address //'`
46 echo "cifs_resolver: resolved: $2 to $DATAA"
47 keyctl instantiate $1 "$DATAA" $3 || exit 1
49 # if you want to debug the upcall, replace /dev/null (below) with ttyS0 or file
50 } >&/dev/null
51 exit 0