Print this page
6817447 libgss and various mechs are hiding both the real minor_status and the error token
6405422 Solaris acceptors fail in AD-KDC environments when using non-"host" services (e.g. "cifs")
6824434 Unable to accept context establishment initiated by Windows 2000 clients
6787343 kclient's site lookups fail in certain network environments
6692646 kclient should output errors to stderr
6525327 kinit failed when arcfour-hmac-md5-exp was used for the principal's key
6745582 SUNWkdcu missing package dependencies after kclientv2 integration

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/krb5/kadmin/kclient/kclient.sh
          +++ new/usr/src/cmd/krb5/kadmin/kclient/kclient.sh
↓ open down ↓ 11 lines elided ↑ open up ↑
  12   12  # and limitations under the License.
  13   13  #
  14   14  # When distributing Covered Code, include this CDDL HEADER in each
  15   15  # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16   16  # If applicable, add the following below this CDDL HEADER, with the
  17   17  # fields enclosed by brackets "[]" replaced with your own identifying
  18   18  # information: Portions Copyright [yyyy] [name of copyright owner]
  19   19  #
  20   20  # CDDL HEADER END
  21   21  #
  22      -# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
       22 +# Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23  # Use is subject to license terms.
  24   24  #
  25   25  # This script is used to setup the Kerberos client by
  26   26  # supplying information about the Kerberos realm and kdc.
  27   27  #
  28   28  # The kerberos configuration file (/etc/krb5/krb5.conf) would
  29   29  # be generated and local host's keytab file setup. The script
  30   30  # can also optionally setup the system to do kerberized nfs and
  31   31  # bringover a master krb5.conf copy from a specified location.
  32   32  
  33   33  function cleanup {
  34      -        integer ret=$1
  35   34  
  36      -        kdestroy -q 1> $TMP_FILE 2>&1
       35 +        kdestroy -q > $TMP_FILE 2>&1
  37   36          rm -r $TMPDIR > /dev/null 2>&1
  38   37  
  39      -        exit $ret
       38 +        exit $1
  40   39  }
  41   40  function exiting {
  42   41          
  43   42          printf "\n$(gettext "Exiting setup, nothing changed").\n\n"
  44   43  
  45   44          cleanup $1
  46   45  }
  47   46  
  48   47  function error_message {
  49   48  
  50      -        printf -- "---------------------------------------------------\n"
  51      -        printf "$(gettext "Setup FAILED").\n\n"
       49 +        printf -- "---------------------------------------------------\n" >&2
       50 +        printf "$(gettext "Setup FAILED").\n\n" >&2
  52   51  
  53   52          cleanup 1
  54   53  }
  55   54  
  56   55  function check_bin {
  57   56  
  58   57          typeset bin=$1
  59   58  
  60   59          if [[ ! -x $bin ]]; then
  61      -                printf "$(gettext "Could not access/execute %s").\n" $bin
       60 +                printf "$(gettext "Could not access/execute %s").\n" $bin >&2
  62   61                  error_message
  63   62          fi
  64   63  }
  65   64  
  66   65  function cannot_create {
  67   66          typeset filename="$1"
  68   67          typeset stat="$2"
  69   68  
  70   69          if [[ $stat -ne 0 ]]; then
  71   70                  printf "\n$(gettext "Can not create/edit %s, exiting").\n" $filename >&2
↓ open down ↓ 116 lines elided ↑ open up ↑
 188  187          done
 189  188  }
 190  189  
 191  190  function writeup_krb5_conf {
 192  191          typeset dh
 193  192  
 194  193          printf "\n$(gettext "Setting up %s").\n\n" $KRB5_CONFIG_FILE
 195  194  
 196  195          exec 3>$KRB5_CONFIG
 197  196          if [[ $? -ne 0 ]]; then
 198      -                printf "\n$(gettext "Can not write to %s, exiting").\n" $KRB5_CONFIG
      197 +                printf "\n$(gettext "Can not write to %s, exiting").\n" $KRB5_CONFIG >&2
 199  198                  error_message
 200  199          fi
 201  200  
 202  201          printf "[libdefaults]\n" 1>&3
 203  202          if [[ $no_keytab == yes ]]; then
 204  203                  printf "\tverify_ap_req_nofail = false\n" 1>&3
 205  204          fi
 206  205          if [[ $dns_lookup == yes ]]; then
 207  206              printf "\t$dnsarg = on\n" 1>&3
 208  207              if [[ $dnsarg == dns_lookup_kdc ]]; then
↓ open down ↓ 649 lines elided ↑ open up ↑
 858  857          # Default
 859  858          set -A DCs -- $DomainDnsZones 389
 860  859          dc=$DomainDnsZones
 861  860  }
 862  861  
 863  862  function write_ads_krb5conf {
 864  863          printf "\n$(gettext "Setting up %s").\n\n" $KRB5_CONFIG_FILE
 865  864  
 866  865          exec 3>$KRB5_CONFIG
 867  866          if [[ $? -ne 0 ]]; then
 868      -                printf "\n$(gettext "Can not write to %s, exiting").\n" $KRB5_CONFIG
      867 +                printf "\n$(gettext "Can not write to %s, exiting").\n" $KRB5_CONFIG >&2
 869  868                  error_message
 870  869          fi
 871  870  
 872  871          printf "[libdefaults]\n" 1>&3
 873  872          printf "\tdefault_realm = $realm\n" 1>&3
 874  873          printf "\n[realms]\n" 1>&3
 875  874          printf "\t$realm = {\n" 1>&3
 876  875          for i in ${KDCs[@]}
 877  876          do
 878  877                  [[ $i == +([0-9]) ]] && continue
↓ open down ↓ 13 lines elided ↑ open up ↑
 892  891          printf "[appdefaults]\n" 1>&3
 893  892          printf "\tkinit = {\n\t\trenewable = true\n\t\tforwardable = true\n\t}\n" 1>&3
 894  893  }
 895  894  
 896  895  function getForestName {
 897  896          ldapsearch -R -T -h $dc $ldap_args \
 898  897              -b "" -s base "" schemaNamingContext| \
 899  898                  grep ^schemaNamingContext|read j schemaNamingContext
 900  899  
 901  900          if [[ $? -ne 0 ]]; then
 902      -                printf "$(gettext "Can't find forest").\n"
      901 +                printf "$(gettext "Can't find forest").\n" >&2
 903  902                  error_message
 904  903          fi
 905  904          schemaNamingContext=${schemaNamingContext#CN=Schema,CN=Configuration,}
 906  905  
 907  906          [[ -z $schemaNamingContext ]] && return 1
 908  907  
 909  908          forest=
 910  909          while [[ -n $schemaNamingContext ]]
 911  910          do
 912  911                  schemaNamingContext=${schemaNamingContext#DC=}
↓ open down ↓ 19 lines elided ↑ open up ↑
 932  931          # No site name
 933  932          set -A GCs -- $(getSRVs _ldap._tcp.gc._msdcs.$forest.)
 934  933          gc=${GCs[0]}
 935  934          [[ -n $gc ]] && return
 936  935  
 937  936          # Default
 938  937          set -A GCs -- $ForestDnsZones 3268
 939  938          gc=$ForestDnsZones
 940  939  }
 941  940  
      941 +#
      942 +# The local variables used to calculate the IP address are of type unsigned
      943 +# integer (-ui), as this is required to restrict the integer to 32b.
      944 +# Starting in ksh88, Solaris has incorrectly assummed that -i represents 64b.
      945 +#
 942  946  function ipAddr2num {
 943  947          typeset OIFS
 944      -        typeset -i16 num byte
      948 +        typeset -ui16 num
 945  949  
 946  950          if [[ "$1" != +([0-9]).+([0-9]).+([0-9]).+([0-9]) ]]
 947  951          then
 948  952                  print 0
 949  953                  return 0
 950  954          fi
 951  955  
 952  956          OIFS="$IFS"
 953  957          IFS=.
 954  958          set -- $1
 955  959          IFS="$OIFS"
 956  960  
 957  961          num=$((${1}<<24 | ${2}<<16 | ${3}<<8 | ${4}))
 958  962  
 959  963          print -- $num
 960  964  }
 961  965  
      966 +#
      967 +# The local variables used to calculate the IP address are of type unsigned
      968 +# integer (-ui), as this is required to restrict the integer to 32b.
      969 +# Starting in ksh88, Solaris has incorrectly assummed that -i represents 64b.
      970 +#
 962  971  function num2ipAddr {
 963      -        typeset -i16 num
 964      -        typeset -i10 a b c d
      972 +        typeset -ui16 num
      973 +        typeset -ui10 a b c d
 965  974  
 966  975          num=$1
 967  976          a=$((num>>24        ))
 968  977          b=$((num>>16 & 16#ff))
 969  978          c=$((num>>8  & 16#ff))
 970  979          d=$((num     & 16#ff))
 971  980          print -- $a.$b.$c.$d
 972  981  }
 973  982  
      983 +#
      984 +# The local variables used to calculate the IP address are of type unsigned
      985 +# integer (-ui), as this is required to restrict the integer to 32b.
      986 +# Starting in ksh88, Solaris has incorrectly assummed that -i represents 64b.
      987 +#
 974  988  function netmask2length {
 975      -        typeset -i16 netmask
      989 +        typeset -ui16 netmask
 976  990          typeset -i len
 977  991  
 978  992          netmask=$1
 979  993          len=32
 980  994          while [[ $((netmask % 2)) -eq 0 ]]
 981  995          do
 982  996                  netmask=$((netmask>>1))
 983  997                  len=$((len - 1))
 984  998          done
 985  999          print $len
 986 1000  }
 987 1001  
     1002 +#
     1003 +# The local variables used to calculate the IP address are of type unsigned
     1004 +# integer (-ui), as this is required to restrict the integer to 32b.
     1005 +# Starting in ksh88, Solaris has incorrectly assummed that -i represents 64b.
     1006 +#
 988 1007  function getSubnets {
 989      -        typeset -i16 addr netmask
 990      -        typeset -i16 classa=16\#ff000000
     1008 +        typeset -ui16 addr netmask
     1009 +        typeset -ui16 classa=16\#ff000000
 991 1010  
 992 1011          ifconfig -a|while read line
 993 1012          do
 994 1013                  addr=0
 995 1014                  netmask=0
 996 1015                  set -- $line
 997 1016                  [[ $1 == inet ]] || continue
 998 1017                  while [[ $# -gt 0 ]]
 999 1018                  do
1000 1019                          case "$1" in
↓ open down ↓ 104 lines elided ↑ open up ↑
1105 1124          klist -k 2>&1 | grep @ | read j hspn
1106 1125          [[ -z $hspn ]] && return
1107 1126  
1108 1127          oldDom=${hspn#*@}
1109 1128          if [[ $oldDom != $newDom ]]; then
1110 1129                  printf "$(gettext "The client is currently configured in a different domain").\n"
1111 1130                  printf "$(gettext "Currently in the '%s' domain, trying to join the '%s' domain").\n" $oldDom $newDom
1112 1131                  query "$(gettext "Do you want the client to join a new domain") ?"
1113 1132                  printf "\n"
1114 1133                  if [[ $answer != yes ]]; then
1115      -                        printf "$(gettext "Client will not be joined to the new domain").\n"
     1134 +                        printf "$(gettext "Client will not be joined to the new domain").\n" >&2
1116 1135                          error_message
1117 1136                  fi
1118 1137          fi
1119 1138  }
1120 1139  
1121 1140  function getKDCDC {
1122 1141  
1123 1142          getKDC
1124 1143          if [[ -n $kdc ]]; then
1125 1144                  KDC=$kdc
1126 1145                  dc=$kdc
1127 1146          else
1128 1147                  getDC
1129 1148                  if [[ -n $dc ]]; then
1130 1149                          KDC=$dc
1131 1150                  else
1132      -                        printf "$(gettext "Could not find domain controller server for '%s'.  Exiting").\n" $realm
     1151 +                        printf "$(gettext "Could not find domain controller server for '%s'.  Exiting").\n" $realm >&2
1133 1152                          error_message
1134 1153                  fi
1135 1154          fi
1136 1155  }
1137 1156  
1138 1157  function join_domain {
1139 1158          typeset -u upcase_nodename
1140 1159          typeset netbios_nodename fqdn
1141 1160          
1142 1161          container=Computers
1143 1162          ldap_args="-o authzid= -o mech=gssapi"
1144 1163          userAccountControlBASE=4096
1145 1164  
1146 1165          if [[ -z $ADMIN_PRINC ]]; then
1147 1166                  cprinc=Administrator
1148 1167          else
1149 1168                  cprinc=$ADMIN_PRINC
1150 1169          fi
1151 1170  
1152 1171          if ! discover_domain; then
1153      -                printf "$(gettext "Can not find realm") '%s'.\n" $realm
     1172 +                printf "$(gettext "Can not find realm") '%s'.\n" $realm >&2
1154 1173                  error_message
1155 1174          fi
1156 1175  
1157 1176          dom=$domain
1158 1177          realm=$domain
1159 1178          upcase_nodename=$hostname
1160 1179          netbios_nodename="${upcase_nodename}\$"
1161 1180          fqdn=$hostname.$domain
1162 1181          upn=host/${fqdn}
1163 1182  
↓ open down ↓ 21 lines elided ↑ open up ↑
1185 1204          else
1186 1205                  getKDCDC
1187 1206          fi
1188 1207  
1189 1208          write_ads_krb5conf
1190 1209  
1191 1210          printf "$(gettext "Attempting to join '%s' to the '%s' domain").\n\n" $upcase_nodename $realm
1192 1211  
1193 1212          kinit $cprinc@$realm
1194 1213          if [[ $? -ne 0 ]]; then
1195      -                printf "$(gettext "Could not authenticate %s.  Exiting").\n" $cprinc@$realm
     1214 +                printf "$(gettext "Could not authenticate %s.  Exiting").\n" $cprinc@$realm >&2
1196 1215                  error_message
1197 1216          fi
1198 1217  
1199 1218          if getForestName
1200 1219          then
1201 1220                  printf "\n$(gettext "Forest name found: %s")\n\n" $forest
1202 1221          else
1203 1222                  printf "\n$(gettext "Forest name not found, assuming forest is the domain name").\n"
1204 1223          fi
1205 1224  
↓ open down ↓ 5 lines elided ↑ open up ↑
1211 1230                  printf "$(gettext "Site name not found.  Local DCs/GCs will not be discovered").\n\n"
1212 1231          else
1213 1232                  printf "$(gettext "Looking for _local_ KDCs, DCs and global catalog servers (SRV RRs)").\n"
1214 1233                  getKDCDC
1215 1234                  getGC
1216 1235  
1217 1236                  write_ads_krb5conf
1218 1237          fi
1219 1238  
1220 1239          if [[ ${#GCs} -eq 0 ]]; then
1221      -                printf "$(gettext "Could not find global catalogs.  Exiting").\n"
     1240 +                printf "$(gettext "Could not find global catalogs.  Exiting").\n" >&2
1222 1241                  error_message
1223 1242          fi
1224 1243  
1225 1244          # Check to see if the client is transitioning between domains.
1226 1245          compareDomains $realm
1227 1246  
1228 1247          # Here we check domainFunctionality to see which release:
1229 1248          # 0, 1, 2: Windows 2000, 2003 Interim, 2003 respecitively
1230 1249          # 3: Windows 2008
1231 1250          level=0
1232 1251          ldapsearch -R -T -h "$dc" $ldap_args -b "" -s base "" \
1233 1252           domainControllerFunctionality| grep ^domainControllerFunctionality| \
1234 1253           read j level
1235 1254          if [[ $? -ne 0 ]]; then
1236      -                printf "$(gettext "Search for domain functionality failed, exiting").\n"
     1255 +                printf "$(gettext "Search for domain functionality failed, exiting").\n" >&2
1237 1256                  error_message
1238 1257          fi
1239 1258          # Longhorn and above can't perform an init auth from service
1240 1259          # keys if the realm is included in the UPN.  w2k3 and below
1241 1260          # can't perform an init auth when the realm is excluded.
1242 1261          [[ $level -lt 3 ]] && upn=${upn}@${realm}
1243 1262  
1244 1263          if ldapsearch -R -T -h "$dc" $ldap_args -b "$baseDN" \
1245 1264              -s sub sAMAccountName="$netbios_nodename" dn > /dev/null 2>&1
1246 1265          then
1247 1266                  :
1248 1267          else
1249      -                printf "$(gettext "Search for node failed, exiting").\n"
     1268 +                printf "$(gettext "Search for node failed, exiting").\n" >&2
1250 1269                  error_message
1251 1270          fi
1252 1271          ldapsearch -R -T -h "$dc" $ldap_args -b "$baseDN" -s sub \
1253 1272              sAMAccountName="$netbios_nodename" dn|grep "^dn:"|read j dn
1254 1273  
1255 1274          if [[ -z $dn ]]; then
1256 1275                  : # modify_existing is already false, which is what we want.
1257 1276          else
1258 1277                  printf "$(gettext "Computer account '%s' already exists in the '%s' domain").\n" $upcase_nodename $realm
1259 1278                  query "$(gettext "Do you wish to recreate this computer account") ?"
↓ open down ↓ 20 lines elided ↑ open up ↑
1280 1299                                          fi
1281 1300                                  else
1282 1301                                          printf "$(gettext "The following object will not be deleted"): %s\n" ${sub_dn#$dn}
1283 1302                                  fi
1284 1303                          done
1285 1304                  fi
1286 1305  
1287 1306                  if $recreate; then
1288 1307                          ldapdelete -h "$dc" $ldap_args "$dn" > /dev/null 2>&1
1289 1308                          if [[ $? -ne 0 ]]; then
1290      -                                printf "$(gettext "Error in deleting object: %s").\n" ${sub_dn#$dn}
     1309 +                                printf "$(gettext "Error in deleting object: %s").\n" ${sub_dn#$dn} >&2
1291 1310                                  error_message
1292 1311                          fi
1293 1312                  elif $modify_existing; then
1294 1313                          : # Nothing to delete
1295 1314                  else
1296      -                        printf "$(gettext "A machine account already exists").\n"
     1315 +                        printf "$(gettext "A machine account already exists").\n" >&2
1297 1316                          error_message
1298 1317                  fi
1299 1318          fi
1300 1319  
1301 1320          if $modify_existing; then
1302 1321                  cat > "$object" <<EOF
1303 1322  dn: CN=$upcase_nodename,$baseDN
1304 1323  changetype: modify
1305 1324  replace: userPrincipalName
1306 1325  userPrincipalName: $upn
↓ open down ↓ 4 lines elided ↑ open up ↑
1311 1330  replace: userAccountControl
1312 1331  userAccountControl: $((userAccountControlBASE + 32 + 2))
1313 1332  -
1314 1333  replace: dNSHostname
1315 1334  dNSHostname: ${fqdn}
1316 1335  EOF
1317 1336  
1318 1337                  printf "$(gettext "A machine account already exists; updating it").\n"
1319 1338                  ldapadd -h "$dc" $ldap_args -f "$object" > /dev/null 2>&1
1320 1339                  if [[ $? -ne 0 ]]; then
1321      -                        printf "$(gettext "Failed to create the AD object via LDAP").\n"
     1340 +                        printf "$(gettext "Failed to create the AD object via LDAP").\n" >&2
1322 1341                          error_message
1323 1342                  fi
1324 1343          else
1325 1344                  cat > "$object" <<EOF
1326 1345  dn: CN=$upcase_nodename,$baseDN
1327 1346  objectClass: computer
1328 1347  cn: $upcase_nodename
1329 1348  sAMAccountName: ${netbios_nodename}
1330 1349  userPrincipalName: $upn
1331 1350  servicePrincipalName: host/${fqdn}
1332 1351  userAccountControl: $((userAccountControlBASE + 32 + 2))
1333 1352  dNSHostname: ${fqdn}
1334 1353  EOF
1335 1354  
1336 1355                  printf "$(gettext "Creating the machine account in AD via LDAP").\n\n"
1337 1356  
1338 1357                  ldapadd -h "$dc" $ldap_args -f "$object" > /dev/null 2>&1
1339 1358                  if [[ $? -ne 0 ]]; then
1340      -                        printf "$(gettext "Failed to create the AD object via LDAP").\n"
     1359 +                        printf "$(gettext "Failed to create the AD object via LDAP").\n" >&2
1341 1360                          error_message
1342 1361                  fi
1343 1362          fi
1344 1363  
1345 1364          # Generate a new password for the new account
1346 1365          MAX_PASS=32
1347 1366          i=0
1348 1367  
1349 1368          while :
1350 1369          do
↓ open down ↓ 20 lines elided ↑ open up ↑
1371 1390                     ${#A} -ne $n && ${#x} -ne $n ]] && break
1372 1391                  i=0
1373 1392                  p=
1374 1393          done
1375 1394          newpw=$p
1376 1395  
1377 1396          # Set the new password
1378 1397          printf "%s" $newpw | $KSETPW ${netbios_nodename}@${realm} > /dev/null 2>&1
1379 1398          if [[ $? -ne 0 ]]
1380 1399          then
1381      -                printf "$(gettext "Failed to set account password").\n"
     1400 +                printf "$(gettext "Failed to set account password").\n" >&2
1382 1401                  error_message
1383 1402          fi
1384 1403  
1385 1404          # Lookup the new principal's kvno:
1386 1405          ldapsearch -R -T -h "$dc" $ldap_args -b "$baseDN" \
1387 1406                   -s sub cn=$upcase_nodename msDS-KeyVersionNumber| \
1388 1407                  grep "^msDS-KeyVersionNumber"|read j kvno
1389 1408          [[ -z $kvno ]] && kvno=1
1390 1409  
1391 1410          # Set supported enctypes.  This only works for Longhorn/Vista, so we
↓ open down ↓ 17 lines elided ↑ open up ↑
1409 1428          if encrypt -l|$grep -q ^arcfour
1410 1429          then
1411 1430                  ((val=val+4))
1412 1431                  enctypes[${#enctypes[@]}]=arcfour-hmac-md5
1413 1432          else
1414 1433                  # Use 1DES ONLY if we don't have arcfour
1415 1434                  userAccountControl=$((userAccountControl + 2097152))
1416 1435          fi
1417 1436          if encrypt -l | $grep -q ^des
1418 1437          then
1419      -                ((val=val+1+2))
1420      -                enctypes[${#enctypes[@]}]=des-cbc-crc
     1438 +                ((val=val+2))
1421 1439                  enctypes[${#enctypes[@]}]=des-cbc-md5
1422 1440          fi
1423 1441  
1424 1442          if [[ ${#enctypes[@]} -eq 0 ]]
1425 1443          then
1426 1444                  printf "$(gettext "No enctypes are supported").\n"
1427      -                printf "$(gettext "Please enable arcfour or 1DES, then re-join; see cryptoadm(1M)").\n"
     1445 +                printf "$(gettext "Please enable arcfour or 1DES, then re-join; see cryptoadm(1M)").\n" >&2
1428 1446                  error_message
1429 1447          fi
1430 1448  
1431 1449          # If domain crontroller is Longhorn or above then set new supported
1432 1450          # encryption type attributes.
1433 1451          if [[ $level -gt 2 ]]; then
1434 1452                  cat > "$object" <<EOF
1435 1453  dn: CN=$upcase_nodename,$baseDN
1436 1454  changetype: modify
1437 1455  replace: msDS-SupportedEncryptionTypes
↓ open down ↓ 17 lines elided ↑ open up ↑
1455 1473          # and possibly UseDesOnly (2097152) (see above)
1456 1474          #
1457 1475          cat > "$object" <<EOF
1458 1476  dn: CN=$upcase_nodename,$baseDN
1459 1477  changetype: modify
1460 1478  replace: userAccountControl
1461 1479  userAccountControl: $userAccountControl
1462 1480  EOF
1463 1481          ldapmodify -h "$dc" $ldap_args -f "$object" >/dev/null 2>&1
1464 1482          if [[ $? -ne 0 ]]; then
1465      -                printf "$(gettext "ldapmodify failed to modify account attribute").\n"
     1483 +                printf "$(gettext "ldapmodify failed to modify account attribute").\n" >&2
1466 1484                  error_message
1467 1485          fi
1468 1486  
1469 1487          # Setup a keytab file
1470 1488          set -A args --
1471 1489          for enctype in "${enctypes[@]}"
1472 1490          do
1473 1491                  args[${#args[@]}]=-e
1474 1492                  args[${#args[@]}]=$enctype
1475 1493          done
1476 1494  
1477 1495          rm $new_keytab > /dev/null 2>&1
1478 1496  
1479 1497          cat > "$object" <<EOF
1480 1498  dn: CN=$upcase_nodename,$baseDN
1481 1499  changetype: modify
1482 1500  add: servicePrincipalName
1483 1501  servicePrincipalName: nfs/${fqdn}
1484 1502  servicePrincipalName: HTTP/${fqdn}
1485 1503  servicePrincipalName: root/${fqdn}
     1504 +servicePrincipalName: cifs/${fqdn}
1486 1505  EOF
1487 1506          ldapmodify -h "$dc" $ldap_args -f "$object" >/dev/null 2>&1
1488 1507          if [[ $? -ne 0 ]]; then
1489      -                printf "$(gettext "ldapmodify failed to modify account attribute").\n"
     1508 +                printf "$(gettext "ldapmodify failed to modify account attribute").\n" >&2
1490 1509                  error_message
1491 1510          fi
1492 1511  
1493      -        printf "%s" $newpw | $KSETPW -n -v $kvno -k "$new_keytab" "${args[@]}" host/${fqdn}@${realm} > /dev/null 2>&1
     1512 +        #
     1513 +        # In Windows, unlike MIT based implementations we salt the keys with
     1514 +        # the UPN, which is based on the host/fqdn@realm elements, not with the
     1515 +        # individual SPN strings.
     1516 +        #
     1517 +        salt=host/${fqdn}@${realm}
     1518 +
     1519 +        printf "%s" $newpw | $KSETPW -n -s $salt -v $kvno -k "$new_keytab" "${args[@]}" host/${fqdn}@${realm} > /dev/null 2>&1
1494 1520          if [[ $? -ne 0 ]]
1495 1521          then
1496      -                printf "$(gettext "Failed to set account password").\n"
     1522 +                printf "$(gettext "Failed to set account password").\n" >&2
1497 1523                  error_message
1498 1524          fi
1499 1525  
     1526 +        printf "%s" $newpw | $KSETPW -n -s $salt -v $kvno -k "$new_keytab" "${args[@]}" HOST/${fqdn}@${realm} > /dev/null 2>&1
     1527 +        if [[ $? -ne 0 ]]
     1528 +        then
     1529 +                printf "$(gettext "Failed to set account password").\n" >&2
     1530 +                error_message
     1531 +        fi
     1532 +
1500 1533          # Could be setting ${netbios_nodename}@${realm}, but for now no one
1501 1534          # is requesting this.
1502 1535  
1503      -        print "%s" $newpw | $KSETPW -n -v $kvno -k "$new_keytab" "${args[@]}" nfs/${fqdn}@${realm} > /dev/null 2>&1
     1536 +        printf "%s" $newpw | $KSETPW -n -s $salt -v $kvno -k "$new_keytab" "${args[@]}" nfs/${fqdn}@${realm} > /dev/null 2>&1
1504 1537          if [[ $? -ne 0 ]]
1505 1538          then
1506      -                printf "$(gettext "Failed to set account password").\n"
     1539 +                printf "$(gettext "Failed to set account password").\n" >&2
1507 1540                  error_message
1508 1541          fi
1509 1542  
1510      -        print "%s" $newpw | $KSETPW -n -v $kvno -k "$new_keytab" "${args[@]}" HTTP/${fqdn}@${realm} > /dev/null 2>&1
     1543 +        printf "%s" $newpw | $KSETPW -n -s $salt -v $kvno -k "$new_keytab" "${args[@]}" HTTP/${fqdn}@${realm} > /dev/null 2>&1
1511 1544          if [[ $? -ne 0 ]]
1512 1545          then
1513      -                printf "$(gettext "Failed to set account password").\n"
     1546 +                printf "$(gettext "Failed to set account password").\n" >&2
1514 1547                  error_message
1515 1548          fi
1516 1549  
1517      -        print "%s" $newpw | $KSETPW -n -v $kvno -k "$new_keytab" "${args[@]}" root/${fqdn}@${realm} > /dev/null 2>&1
     1550 +        printf "%s" $newpw | $KSETPW -n -s $salt -v $kvno -k "$new_keytab" "${args[@]}" root/${fqdn}@${realm} > /dev/null 2>&1
1518 1551          if [[ $? -ne 0 ]]
1519 1552          then
1520      -                printf "$(gettext "Failed to set account password").\n"
     1553 +                printf "$(gettext "Failed to set account password").\n" >&2
1521 1554                  error_message
1522 1555          fi
1523 1556  
     1557 +        printf "%s" $newpw | $KSETPW -n -s $salt -v $kvno -k "$new_keytab" "${args[@]}" cifs/${fqdn}@${realm} > /dev/null 2>&1
     1558 +        if [[ $? -ne 0 ]]
     1559 +        then
     1560 +                printf "$(gettext "Failed to set account password").\n" >&2
     1561 +                error_message
     1562 +        fi
     1563 +
1524 1564          doKRB5config
1525 1565  
1526 1566          addDNSRR $dom
1527 1567  
1528 1568          setSMB $dom $dc
1529 1569  
1530 1570          printf -- "\n---------------------------------------------------\n"
1531 1571          printf "$(gettext "Setup COMPLETE").\n\n"
1532 1572  
1533 1573          kdestroy -q 1>$TMP_FILE 2>&1
↓ open down ↓ 23 lines elided ↑ open up ↑
1557 1597  adddns=no
1558 1598  no_keytab=no
1559 1599  checkval=""
1560 1600  profile=""
1561 1601  typeset -u realm
1562 1602  typeset -l hostname KDC
1563 1603  
1564 1604  export TMPDIR="/var/run/kclient"
1565 1605  
1566 1606  mkdir $TMPDIR > /dev/null 2>&1
     1607 +if [[ $? -ne 0 ]]; then
     1608 +        printf "\n$(gettext "Can not create directory: %s")\n\n" $TMPDIR >&2
     1609 +        exit 1
     1610 +fi
1567 1611  
1568 1612  TMP_FILE=$(mktemp -q -t kclient-tmpfile.XXXXXX)
1569 1613  export KRB5_CONFIG=$(mktemp -q -t kclient-krb5conf.XXXXXX)
1570 1614  export KRB5CCNAME=$(mktemp -q -t kclient-krb5ccache.XXXXXX) 
1571 1615  new_keytab=$(mktemp -q -t kclient-krb5keytab.XXXXXX) 
1572 1616  if [[ -z $TMP_FILE || -z $KRB5_CONFIG || -z $KRB5CCNAME || -z $new_keytab ]]
1573 1617  then
1574      -        printf "\n$(gettext "Can not create temporary file, exiting").\n" >&2
1575      -        error_message
     1618 +        printf "\n$(gettext "Can not create temporary files, exiting").\n\n" >&2
     1619 +        exit 1
1576 1620  fi
1577 1621  
1578 1622  #
1579 1623  # If we are interrupted, cleanup after ourselves
1580 1624  #
1581 1625  trap "exiting 1" HUP INT QUIT TERM
1582 1626  
1583 1627  if [[ -d /usr/bin ]]; then
1584 1628          if [[ -d /usr/sbin ]]; then
1585 1629                  PATH=/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$PATH
↓ open down ↓ 355 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX