r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
[tprouty/samba.git] / source / libsmb / clifsinfo.c
index be988a433f19387ad0241f03e293da7ccb6d3f6b..48865c98caf613ba4a0b6976deaebb934c84f788 100644 (file)
@@ -6,7 +6,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -15,8 +15,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include "includes.h"
@@ -66,7 +65,7 @@ BOOL cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor, uint16 *
 
        *pmajor = SVAL(rdata,0);
        *pminor = SVAL(rdata,2);
-       *pcaplow = IVAL(rdata,4);
+       cli->posix_capabilities = *pcaplow = IVAL(rdata,4);
        *pcaphigh = IVAL(rdata,8);
 
        /* todo: but not yet needed 
@@ -368,6 +367,21 @@ static struct smb_trans_enc_state *make_cli_enc_state(enum smb_trans_enc_type sm
        }
        ZERO_STRUCTP(es);
        es->smb_enc_type = smb_enc_type;
+
+       if (smb_enc_type == SMB_TRANS_ENC_GSS) {
+#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
+               es->s.gss_state = SMB_MALLOC_P(struct smb_tran_enc_state_gss);
+               if (!es->s.gss_state) {
+                       SAFE_FREE(es);
+                       return NULL;
+               }
+               ZERO_STRUCTP(es->s.gss_state);
+#else
+               DEBUG(0,("make_cli_enc_state: no krb5 compiled.\n"));
+               SAFE_FREE(es);
+               return NULL;
+#endif
+       }
        return es;
 }
 
@@ -380,9 +394,9 @@ NTSTATUS cli_raw_ntlm_smb_encryption_start(struct cli_state *cli,
                                const char *pass,
                                const char *domain)
 {
-       DATA_BLOB blob_in = data_blob(NULL, 0);
-       DATA_BLOB blob_out = data_blob(NULL, 0);
-       DATA_BLOB param_out = data_blob(NULL, 0);
+       DATA_BLOB blob_in = data_blob_null;
+       DATA_BLOB blob_out = data_blob_null;
+       DATA_BLOB param_out = data_blob_null;
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
        struct smb_trans_enc_state *es = make_cli_enc_state(SMB_TRANS_ENC_NTLM);
 
@@ -455,19 +469,22 @@ static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
                                DATA_BLOB spnego_blob_in,
                                DATA_BLOB *p_blob_out)
 {
-       const char *krb_mechs[] = {OID_KERBEROS5_OLD, OID_KERBEROS5, NULL};
+       const char *krb_mechs[] = {OID_KERBEROS5, NULL};
        OM_uint32 ret;
        OM_uint32 min;
        gss_name_t srv_name;
        gss_buffer_desc input_name;
        gss_buffer_desc *p_tok_in;
        gss_buffer_desc tok_out, tok_in;
-       DATA_BLOB blob_out = data_blob(NULL, 0);
-       DATA_BLOB blob_in = data_blob(NULL, 0);
+       DATA_BLOB blob_out = data_blob_null;
+       DATA_BLOB blob_in = data_blob_null;
        char *host_princ_s = NULL;
        OM_uint32 ret_flags = 0;
        NTSTATUS status = NT_STATUS_OK;
 
+       gss_OID_desc nt_hostbased_service =
+       {10, CONST_DISCARD(char *,"\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")};
+
        memset(&tok_out, '\0', sizeof(tok_out));
 
        /* Get a ticket for the service@host */
@@ -481,7 +498,7 @@ static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
 
        ret = gss_import_name(&min,
                                &input_name,
-                               GSS_C_NT_HOSTBASED_SERVICE,
+                               &nt_hostbased_service,
                                &srv_name);
 
        if (ret != GSS_S_COMPLETE) {
@@ -518,6 +535,9 @@ static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
 
        status = map_nt_error_from_gss(ret, min);
        if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status,NT_STATUS_MORE_PROCESSING_REQUIRED)) {
+               ADS_STATUS adss = ADS_ERROR_GSS(ret, min);
+               DEBUG(10,("make_cli_gss_blob: gss_init_sec_context failed with %s\n",
+                       ads_errstr(adss)));
                goto fail;
        }
 
@@ -548,9 +568,9 @@ static NTSTATUS make_cli_gss_blob(struct smb_trans_enc_state *es,
 
 NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
 {
-       DATA_BLOB blob_recv = data_blob(NULL, 0);
-       DATA_BLOB blob_send = data_blob(NULL, 0);
-       DATA_BLOB param_out = data_blob(NULL, 0);
+       DATA_BLOB blob_recv = data_blob_null;
+       DATA_BLOB blob_send = data_blob_null;
+       DATA_BLOB param_out = data_blob_null;
        NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
        fstring fqdn;
        const char *servicename;
@@ -599,4 +619,9 @@ NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
        common_free_encryption_state(&es);
        return status;
 }
+#else
+NTSTATUS cli_gss_smb_encryption_start(struct cli_state *cli)
+{
+       return NT_STATUS_NOT_SUPPORTED;
+}
 #endif