~ubuntu-branches/ubuntu/saucy/nfs-utils/saucy-proposed

« back to all changes in this revision

Viewing changes to utils/gssd/krb5_util.c

  • Committer: Bazaar Package Importer
  • Author(s): Luk Claes
  • Date: 2011-07-09 16:28:32 UTC
  • mfrom: (1.2.20 upstream)
  • mto: (71.1.1 ubuntu)
  • mto: This revision was merged to the branch mainline in revision 41.
  • Revision ID: james.westby@ubuntu.com-20110709162832-ovaehe77pm3hyy35
Tags: 1:1.2.4-1
* New upstream version
  - Fix host_reliable_addrinfo (Closes: #633155)
  - Allow multiple RPC listeners to share listener port number
  (Closes: #619877)
  - Add --enable-libmount-mount (Closes: #626478)
  - 12-svcgssd-document-n-option.patch applied upstream
  - Refresh 19-exports.man-Fix-comment-syntax.patch
  - 21-anticipate-RLIMIT_FSIZE.patch applied upstream
  - Add nfsidmap binary and manpage
  - Use autoreconf to avoid build failure

Show diffs side-by-side

added added

removed removed

Lines of Context:
768
768
        krb5_error_code code;
769
769
        char **realmnames = NULL;
770
770
        char myhostname[NI_MAXHOST], targethostname[NI_MAXHOST];
 
771
        char myhostad[NI_MAXHOST+1];
771
772
        int i, j, retval;
772
773
        char *default_realm = NULL;
773
774
        char *realm;
789
790
                printerr(1, "%s while getting local hostname\n", k5err);
790
791
                goto out;
791
792
        }
 
793
 
 
794
        /* Compute the active directory machine name HOST$ */
 
795
        strcpy(myhostad, myhostname);
 
796
        for (i = 0; myhostad[i] != 0; ++i)
 
797
                myhostad[i] = toupper(myhostad[i]);
 
798
        myhostad[i] = '$';
 
799
        myhostad[i+1] = 0;
 
800
 
792
801
        retval = get_full_hostname(myhostname, myhostname, sizeof(myhostname));
793
802
        if (retval)
794
803
                goto out;
833
842
                if (strcmp(realm, default_realm) == 0)
834
843
                        tried_default = 1;
835
844
                for (j = 0; svcnames[j] != NULL; j++) {
836
 
                        code = krb5_build_principal_ext(context, &princ,
837
 
                                                        strlen(realm),
838
 
                                                        realm,
839
 
                                                        strlen(svcnames[j]),
840
 
                                                        svcnames[j],
841
 
                                                        strlen(myhostname),
842
 
                                                        myhostname,
843
 
                                                        NULL);
 
845
                        char spn[300];
 
846
 
 
847
                        /*
 
848
                         * The special svcname "$" means 'try the active
 
849
                         * directory machine account'
 
850
                         */
 
851
                        if (strcmp(svcnames[j],"$") == 0) {
 
852
                                snprintf(spn, sizeof(spn), "%s@%s", myhostad, realm);
 
853
                                code = krb5_build_principal_ext(context, &princ,
 
854
                                                                strlen(realm),
 
855
                                                                realm,
 
856
                                                                strlen(myhostad),
 
857
                                                                myhostad,
 
858
                                                                NULL);
 
859
                        } else {
 
860
                                snprintf(spn, sizeof(spn), "%s/%s@%s",
 
861
                                         svcnames[j], myhostname, realm);
 
862
                                code = krb5_build_principal_ext(context, &princ,
 
863
                                                                strlen(realm),
 
864
                                                                realm,
 
865
                                                                strlen(svcnames[j]),
 
866
                                                                svcnames[j],
 
867
                                                                strlen(myhostname),
 
868
                                                                myhostname,
 
869
                                                                NULL);
 
870
                        }
 
871
 
844
872
                        if (code) {
845
873
                                k5err = gssd_k5_err_msg(context, code);
846
 
                                printerr(1, "%s while building principal for "
847
 
                                         "'%s/%s@%s'\n", k5err, svcnames[j],
848
 
                                         myhostname, realm);
 
874
                                printerr(1, "%s while building principal for '%s'\n",
 
875
                                         k5err, spn);
849
876
                                continue;
850
877
                        }
851
878
                        code = krb5_kt_get_entry(context, kt, princ, 0, 0, kte);
852
879
                        krb5_free_principal(context, princ);
853
880
                        if (code) {
854
881
                                k5err = gssd_k5_err_msg(context, code);
855
 
                                printerr(3, "%s while getting keytab entry for "
856
 
                                         "'%s/%s@%s'\n", k5err, svcnames[j],
857
 
                                         myhostname, realm);
 
882
                                printerr(3, "%s while getting keytab entry for '%s'\n",
 
883
                                         k5err, spn);
858
884
                        } else {
859
 
                                printerr(3, "Success getting keytab entry for "
860
 
                                         "'%s/%s@%s'\n",
861
 
                                         svcnames[j], myhostname, realm);
 
885
                                printerr(3, "Success getting keytab entry for '%s'\n",spn);
862
886
                                retval = 0;
863
887
                                goto out;
864
888
                        }
870
894
                 */
871
895
                for (j = 0; svcnames[j] != NULL; j++) {
872
896
                        int found = 0;
 
897
                        if (strcmp(svcnames[j],"$") == 0)
 
898
                                continue;
873
899
                        code = gssd_search_krb5_keytab(context, kt, realm,
874
900
                                                       svcnames[j], &found, kte);
875
901
                        if (!code && found) {
1160
1186
        krb5_keytab kt = NULL;;
1161
1187
        int retval = 0;
1162
1188
        char *k5err = NULL;
1163
 
        const char *svcnames[4] = { "root", "nfs", "host", NULL };
 
1189
        const char *svcnames[5] = { "$", "root", "nfs", "host", NULL };
1164
1190
 
1165
1191
        /*
1166
1192
         * If a specific service name was specified, use it.