Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libads/kerberos.c

    r478 r740  
    1212   the Free Software Foundation; either version 3 of the License, or
    1313   (at your option) any later version.
    14    
     14
    1515   This program is distributed in the hope that it will be useful,
    1616   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1717   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1818   GNU General Public License for more details.
    19    
     19
    2020   You should have received a copy of the GNU General Public License
    2121   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2323
    2424#include "includes.h"
     25#include "system/filesys.h"
    2526#include "smb_krb5.h"
     27#include "../librpc/gen_ndr/ndr_misc.h"
     28#include "libads/kerberos_proto.h"
     29#include "secrets.h"
    2630
    2731#ifdef HAVE_KRB5
     
    9195        data_blob_free(&edata);
    9296
    93         ndr_err = ndr_pull_struct_blob_all(&unwrapped_edata, mem_ctx, NULL,
    94                         &parsed_edata,
    95                         (ndr_pull_flags_fn_t)ndr_pull_KRB5_EDATA_NTSTATUS);
     97        ndr_err = ndr_pull_struct_blob_all(&unwrapped_edata, mem_ctx,
     98                &parsed_edata, (ndr_pull_flags_fn_t)ndr_pull_KRB5_EDATA_NTSTATUS);
    9699        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    97100                data_blob_free(&unwrapped_edata);
     
    191194                goto out;
    192195        }
    193        
     196
    194197        if ((code = smb_krb5_parse_name(ctx, principal, &me))) {
    195198                goto out;
     
    230233                goto out;
    231234        }
    232        
     235
    233236        if ((code = krb5_cc_store_cred(ctx, cc, &my_creds))) {
    234237                goto out;
     
    283286        }
    284287        return code;
    285 }
    286 
    287 
    288 
    289 /* run kinit to setup our ccache */
    290 int ads_kinit_password(ADS_STRUCT *ads)
    291 {
    292         char *s;
    293         int ret;
    294         const char *account_name;
    295         fstring acct_name;
    296 
    297         if (ads->auth.flags & ADS_AUTH_USER_CREDS) {
    298                 account_name = ads->auth.user_name;
    299                 goto got_accountname;
    300         }
    301 
    302         if ( IS_DC ) {
    303                 /* this will end up getting a ticket for DOMAIN@RUSTED.REA.LM */
    304                 account_name = lp_workgroup();
    305         } else {
    306                 /* always use the sAMAccountName for security = domain */
    307                 /* global_myname()$@REA.LM */
    308                 if ( lp_security() == SEC_DOMAIN ) {
    309                         fstr_sprintf( acct_name, "%s$", global_myname() );
    310                         account_name = acct_name;
    311                 }
    312                 else
    313                         /* This looks like host/global_myname()@REA.LM */
    314                         account_name = ads->auth.user_name;
    315         }
    316 
    317  got_accountname:
    318         if (asprintf(&s, "%s@%s", account_name, ads->auth.realm) == -1) {
    319                 return KRB5_CC_NOMEM;
    320         }
    321 
    322         if (!ads->auth.password) {
    323                 SAFE_FREE(s);
    324                 return KRB5_LIBOS_CANTREADPWD;
    325         }
    326        
    327         ret = kerberos_kinit_password_ext(s, ads->auth.password, ads->auth.time_offset,
    328                         &ads->auth.tgt_expire, NULL, NULL, False, False, ads->auth.renewable,
    329                         NULL);
    330 
    331         if (ret) {
    332                 DEBUG(0,("kerberos_kinit_password %s failed: %s\n",
    333                          s, error_message(ret)));
    334         }
    335         SAFE_FREE(s);
    336         return ret;
    337288}
    338289
     
    349300                return code;
    350301        }
    351  
     302
    352303        if (!cc_name) {
    353304                if ((code = krb5_cc_default(ctx, &cc))) {
     
    592543        char *unparsed_name = NULL, *salt_princ_s = NULL;
    593544        krb5_principal ret_princ = NULL;
    594        
     545
    595546        /* lookup new key first */
    596547
    597548        if ( (salt_princ_s = kerberos_secrets_fetch_des_salt()) == NULL ) {
    598        
     549
    599550                /* look under the old key.  If this fails, just use the standard key */
    600551
     
    611562                ret_princ = NULL;
    612563        }
    613        
     564
    614565        TALLOC_FREE(unparsed_name);
    615566        SAFE_FREE(salt_princ_s);
    616        
     567
    617568        return ret_princ;
    618569}
     
    655606        if (smb_krb5_parse_name(context, princ_s, &princ) != 0) {
    656607                goto out;
    657                
    658608        }
    659609        if (smb_krb5_unparse_name(talloc_tos(), context, princ, &unparsed_name) != 0) {
Note: See TracChangeset for help on using the changeset viewer.