~ubuntu-branches/ubuntu/precise/autofs5/precise

« back to all changes in this revision

Viewing changes to modules/lookup_ldap.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-03 14:35:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110703143546-nej26krjij0rf792
Tags: 5.0.6-0ubuntu1
* New upstream release:
  - Dropped upstream patches 
  - Refreshed debian/patches/17ld.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "automount.h"
34
34
#include "nsswitch.h"
35
35
#include "lookup_ldap.h"
 
36
#include "base64.h"
36
37
 
37
38
#define MAPFMT_DEFAULT "sun"
38
39
 
1024
1025
 
1025
1026
        if (auth_required == LDAP_AUTH_USESIMPLE ||
1026
1027
           (authtype && authtype_requires_creds(authtype))) {
 
1028
                char *s1 = NULL, *s2 = NULL;
1027
1029
                ret = get_property(logopt, root, "user",  &user);
1028
 
                ret |= get_property(logopt, root, "secret", &secret);
1029
 
                if (ret != 0 || (!user || !secret)) {
 
1030
                ret |= get_property(logopt, root, "secret", &s1);
 
1031
                ret |= get_property(logopt, root, "encoded_secret", &s2);
 
1032
                if (ret != 0 || (!user || (!s1 && !s2))) {
 
1033
auth_fail:
1030
1034
                        error(logopt,
1031
1035
                              MODPREFIX
1032
1036
                              "%s authentication type requires a username "
1035
1039
                        free(authtype);
1036
1040
                        if (user)
1037
1041
                                free(user);
1038
 
                        if (secret)
1039
 
                                free(secret);
 
1042
                        if (s1)
 
1043
                                free(s1);
 
1044
                        if (s2)
 
1045
                                free(s2);
1040
1046
 
1041
1047
                        ret = -1;
1042
1048
                        goto out;
1043
1049
                }
 
1050
                if (!s2)
 
1051
                        secret = s1;
 
1052
                else {
 
1053
                        char dec_buf[120];
 
1054
                        int dec_len = base64_decode(s2, dec_buf, 119);
 
1055
                        if (dec_len <= 0)
 
1056
                                goto auth_fail;
 
1057
                        secret = strdup(dec_buf);
 
1058
                        if (!secret)
 
1059
                                goto auth_fail;
 
1060
                        if (s1)
 
1061
                                free(s1);
 
1062
                        if (s2)
 
1063
                                free(s2);
 
1064
                }
1044
1065
        } else if (auth_required == LDAP_AUTH_REQUIRED &&
1045
1066
                  (authtype && !strncmp(authtype, "EXTERNAL", 8))) {
1046
1067
                ret = get_property(logopt, root, "external_cert",  &extern_cert);
1463
1484
                }
1464
1485
        }
1465
1486
 
1466
 
#ifdef WITH_SASL
1467
1487
        /*
1468
1488
         *  First, check to see if a preferred authentication method was
1469
1489
         *  specified by the user.  parse_ldap_config will return error
1476
1496
                return 1;
1477
1497
        }
1478
1498
 
 
1499
#ifdef WITH_SASL
1479
1500
        /* Init the sasl callbacks */
1480
1501
        if (!autofs_sasl_client_init(LOGOPT_NONE)) {
1481
1502
                error(LOGOPT_ANY, "failed to init sasl client");