diff options
Diffstat (limited to 'source3/libsmb')
-rw-r--r-- | source3/libsmb/async_smb.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clidgram.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clifsinfo.c | 2 | ||||
-rw-r--r-- | source3/libsmb/clikrb5.c | 126 | ||||
-rw-r--r-- | source3/libsmb/clilist.c | 2 | ||||
-rw-r--r-- | source3/libsmb/cliquota.c | 6 | ||||
-rw-r--r-- | source3/libsmb/clireadwrite.c | 4 | ||||
-rw-r--r-- | source3/libsmb/libsmb_file.c | 2 | ||||
-rw-r--r-- | source3/libsmb/libsmb_stat.c | 4 | ||||
-rw-r--r-- | source3/libsmb/libsmb_xattr.c | 12 |
10 files changed, 85 insertions, 77 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index ea3ca2d323..0a7697291e 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -546,7 +546,7 @@ struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx, struct iovec iov; NTSTATUS status; - iov.iov_base = CONST_DISCARD(void *, bytes); + iov.iov_base = discard_const_p(void, bytes); iov.iov_len = num_bytes; req = cli_smb_req_create(mem_ctx, ev, cli, smb_command, diff --git a/source3/libsmb/clidgram.c b/source3/libsmb/clidgram.c index f133fe0607..b699b9df55 100644 --- a/source3/libsmb/clidgram.c +++ b/source3/libsmb/clidgram.c @@ -321,7 +321,7 @@ struct tevent_req *nbt_getdc_send(TALLOC_CTX *mem_ctx, return tevent_req_post(req, ev); } state->my_mailslot = mailslot_name( - state, ((struct sockaddr_in *)dc_addr)->sin_addr); + state, ((const struct sockaddr_in *)dc_addr)->sin_addr); if (tevent_req_nomem(state->my_mailslot, req)) { return tevent_req_post(req, ev); } diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c index 4b3383a1d2..4701b0317b 100644 --- a/source3/libsmb/clifsinfo.c +++ b/source3/libsmb/clifsinfo.c @@ -693,7 +693,7 @@ static NTSTATUS make_cli_gss_blob(TALLOC_CTX *ctx, 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")}; + {10, discard_const_p(char, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x01\x04")}; memset(&tok_out, '\0', sizeof(tok_out)); diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c index a872d2df61..df8ba0ac40 100644 --- a/source3/libsmb/clikrb5.c +++ b/source3/libsmb/clikrb5.c @@ -538,6 +538,7 @@ static krb5_error_code setup_auth_context(krb5_context context, return retval; } +#if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE) static krb5_error_code create_gss_checksum(krb5_data *in_data, /* [inout] */ uint32_t gss_flags) { @@ -589,6 +590,7 @@ static krb5_error_code create_gss_checksum(krb5_data *in_data, /* [inout] */ in_data->length = base_cksum_size + orig_length; return 0; } +#endif /* we can't use krb5_mk_req because w2k wants the service to be in a particular format @@ -610,7 +612,6 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, krb5_data in_data; bool creds_ready = False; int i = 0, maxtries = 3; - uint32_t gss_flags = 0; ZERO_STRUCT(in_data); @@ -690,32 +691,35 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, } #if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE) - if( credsp->ticket_flags & TKT_FLG_OK_AS_DELEGATE ) { - /* Fetch a forwarded TGT from the KDC so that we can hand off a 2nd ticket - as part of the kerberos exchange. */ + { + uint32_t gss_flags = 0; - DEBUG( 3, ("ads_krb5_mk_req: server marked as OK to delegate to, building forwardable TGT\n") ); + if( credsp->ticket_flags & TKT_FLG_OK_AS_DELEGATE ) { + /* Fetch a forwarded TGT from the KDC so that we can hand off a 2nd ticket + as part of the kerberos exchange. */ - retval = krb5_auth_con_setuseruserkey(context, + DEBUG( 3, ("ads_krb5_mk_req: server marked as OK to delegate to, building forwardable TGT\n") ); + + retval = krb5_auth_con_setuseruserkey(context, *auth_context, &credsp->keyblock ); - if (retval) { - DEBUG(1,("krb5_auth_con_setuseruserkey failed (%s)\n", - error_message(retval))); - goto cleanup_creds; - } + if (retval) { + DEBUG(1,("krb5_auth_con_setuseruserkey failed (%s)\n", + error_message(retval))); + goto cleanup_creds; + } - /* Must use a subkey for forwarded tickets. */ - retval = krb5_auth_con_setflags(context, + /* Must use a subkey for forwarded tickets. */ + retval = krb5_auth_con_setflags(context, *auth_context, KRB5_AUTH_CONTEXT_USE_SUBKEY); - if (retval) { - DEBUG(1,("krb5_auth_con_setflags failed (%s)\n", - error_message(retval))); - goto cleanup_creds; - } + if (retval) { + DEBUG(1,("krb5_auth_con_setflags failed (%s)\n", + error_message(retval))); + goto cleanup_creds; + } - retval = krb5_fwd_tgt_creds(context,/* Krb5 context [in] */ + retval = krb5_fwd_tgt_creds(context,/* Krb5 context [in] */ *auth_context, /* Authentication context [in] */ CONST_DISCARD(char *, KRB5_TGS_NAME), /* Ticket service name ("krbtgt") [in] */ credsp->client, /* Client principal for the tgt [in] */ @@ -724,46 +728,47 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, 1, /* Turn on for "Forwardable ticket" [in] */ &in_data ); /* Resulting response [out] */ - if (retval) { - DEBUG( 3, ("krb5_fwd_tgt_creds failed (%s)\n", - error_message( retval ) ) ); - - /* - * This is not fatal. Delete the *auth_context and continue - * with krb5_mk_req_extended to get a non-forwardable ticket. - */ - - if (in_data.data) { - free( in_data.data ); - in_data.data = NULL; - in_data.length = 0; - } - krb5_auth_con_free(context, *auth_context); - *auth_context = NULL; - retval = setup_auth_context(context, auth_context); if (retval) { - DEBUG(1,("setup_auth_context failed (%s)\n", - error_message(retval))); - goto cleanup_creds; + DEBUG( 3, ("krb5_fwd_tgt_creds failed (%s)\n", + error_message( retval ) ) ); + + /* + * This is not fatal. Delete the *auth_context and continue + * with krb5_mk_req_extended to get a non-forwardable ticket. + */ + + if (in_data.data) { + free( in_data.data ); + in_data.data = NULL; + in_data.length = 0; + } + krb5_auth_con_free(context, *auth_context); + *auth_context = NULL; + retval = setup_auth_context(context, auth_context); + if (retval) { + DEBUG(1,("setup_auth_context failed (%s)\n", + error_message(retval))); + goto cleanup_creds; + } + } else { + /* We got a delegated ticket. */ + gss_flags |= GSS_C_DELEG_FLAG; } - } else { - /* We got a delegated ticket. */ - gss_flags |= GSS_C_DELEG_FLAG; } - } - /* Frees and reallocates in_data into a GSS checksum blob. */ - retval = create_gss_checksum(&in_data, gss_flags); - if (retval) { - goto cleanup_data; - } + /* Frees and reallocates in_data into a GSS checksum blob. */ + retval = create_gss_checksum(&in_data, gss_flags); + if (retval) { + goto cleanup_data; + } - /* We always want GSS-checksum types. */ - retval = krb5_auth_con_set_req_cksumtype(context, *auth_context, GSSAPI_CHECKSUM ); - if (retval) { - DEBUG(1,("krb5_auth_con_set_req_cksumtype failed (%s)\n", - error_message(retval))); - goto cleanup_data; + /* We always want GSS-checksum types. */ + retval = krb5_auth_con_set_req_cksumtype(context, *auth_context, GSSAPI_CHECKSUM ); + if (retval) { + DEBUG(1,("krb5_auth_con_set_req_cksumtype failed (%s)\n", + error_message(retval))); + goto cleanup_data; + } } #endif @@ -774,7 +779,10 @@ static krb5_error_code ads_krb5_mk_req(krb5_context context, error_message(retval))); } +#if defined(TKT_FLG_OK_AS_DELEGATE ) && defined(HAVE_KRB5_FWD_TGT_CREDS) && defined(HAVE_KRB5_AUTH_CON_SETUSERUSERKEY) && defined(KRB5_AUTH_CONTEXT_USE_SUBKEY) && defined(HAVE_KRB5_AUTH_CON_SET_REQ_CKSUMTYPE) cleanup_data: +#endif + if (in_data.data) { free( in_data.data ); in_data.length = 0; @@ -919,7 +927,7 @@ done: { static krb5_data kdata; - kdata.data = (char *)krb5_principal_get_comp_string(context, principal, i); + kdata.data = discard_const_p(char, krb5_principal_get_comp_string(context, principal, i)); kdata.length = strlen((const char *)kdata.data); return &kdata; } @@ -1131,7 +1139,7 @@ out: DEBUG(10,("smb_krb5_renew_ticket: using %s as ccache\n", ccache_string)); /* FIXME: we should not fall back to defaults */ - ret = krb5_cc_resolve(context, CONST_DISCARD(char *, ccache_string), &ccache); + ret = krb5_cc_resolve(context, discard_const_p(char, ccache_string), &ccache); if (ret) { goto done; } @@ -1150,7 +1158,7 @@ out: #ifdef HAVE_KRB5_GET_RENEWED_CREDS /* MIT */ { - ret = krb5_get_renewed_creds(context, &creds, client, ccache, CONST_DISCARD(char *, service_string)); + ret = krb5_get_renewed_creds(context, &creds, client, ccache, discard_const_p(char, service_string)); if (ret) { DEBUG(10,("smb_krb5_renew_ticket: krb5_get_kdc_cred failed: %s\n", error_message(ret))); goto done; @@ -1956,11 +1964,11 @@ char *smb_krb5_principal_get_realm(krb5_context context, krb5_principal principal) { #ifdef HAVE_KRB5_PRINCIPAL_GET_REALM /* Heimdal */ - return krb5_principal_get_realm(context, principal); + return discard_const_p(char, krb5_principal_get_realm(context, principal)); #elif defined(krb5_princ_realm) /* MIT */ krb5_data *realm; realm = krb5_princ_realm(context, principal); - return (char *)realm->data; + return discard_const_p(char, realm->data); #else return NULL; #endif diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index 1017eb54bd..f7ca9ac99c 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -320,7 +320,7 @@ static struct tevent_req *cli_list_old_send(TALLOC_CTX *mem_ctx, bytes = smb_bytes_push_str(bytes, cli_ucs2(cli), mask, strlen(mask)+1, NULL); - bytes = smb_bytes_push_bytes(bytes, 5, (uint8_t *)&zero, 2); + bytes = smb_bytes_push_bytes(bytes, 5, (const uint8_t *)&zero, 2); if (tevent_req_nomem(bytes, req)) { return tevent_req_post(req, ev); } diff --git a/source3/libsmb/cliquota.c b/source3/libsmb/cliquota.c index e5c8c831b7..94694e4530 100644 --- a/source3/libsmb/cliquota.c +++ b/source3/libsmb/cliquota.c @@ -88,7 +88,7 @@ static bool parse_user_quota_record(const uint8_t *rdata, /* the hard quotas 8 bytes (uint64_t)*/ qt.hardlim = BVAL(rdata,32); - if (!sid_parse((char *)rdata+40,sid_len,&qt.sid)) { + if (!sid_parse((const char *)rdata+40,sid_len,&qt.sid)) { return false; } @@ -262,7 +262,7 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum, ((curdata)&&(curdata_count>=8)&&(offset>0)); curdata +=offset,curdata_count -= offset) { ZERO_STRUCT(qt); - if (!parse_user_quota_record((uint8_t *)curdata, curdata_count, + if (!parse_user_quota_record((const uint8_t *)curdata, curdata_count, &offset, &qt)) { DEBUG(1,("Failed to parse the quota record\n")); goto cleanup; @@ -318,7 +318,7 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum, ((curdata)&&(curdata_count>=8)&&(offset>0)); curdata +=offset,curdata_count -= offset) { ZERO_STRUCT(qt); - if (!parse_user_quota_record((uint8_t *)curdata, + if (!parse_user_quota_record((const uint8_t *)curdata, curdata_count, &offset, &qt)) { DEBUG(1,("Failed to parse the quota record\n")); diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c index ff3dcff773..fcfb01268c 100644 --- a/source3/libsmb/clireadwrite.c +++ b/source3/libsmb/clireadwrite.c @@ -197,7 +197,7 @@ static void cli_read_andx_done(struct tevent_req *subreq) return; } - state->buf = (uint8_t *)smb_base(inbuf) + SVAL(vwv+6, 0); + state->buf = discard_const_p(uint8_t, smb_base(inbuf)) + SVAL(vwv+6, 0); if (trans_oob(smb_len(inbuf), SVAL(vwv+6, 0), state->received) || ((state->received != 0) && (state->buf < bytes))) { @@ -824,7 +824,7 @@ struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx, state->pad = 0; state->iov[0].iov_base = (void *)&state->pad; state->iov[0].iov_len = 1; - state->iov[1].iov_base = CONST_DISCARD(void *, buf); + state->iov[1].iov_base = discard_const_p(void, buf); state->iov[1].iov_len = size; subreq = cli_smb_req_create(state, ev, cli, SMBwriteX, 0, wct, vwv, diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index e21eff3029..74357f5eb9 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -480,7 +480,7 @@ SMBC_close_ctx(SMBCCTX *context, bool SMBC_getatr(SMBCCTX * context, SMBCSRV *srv, - char *path, + const char *path, uint16 *mode, SMB_OFF_T *size, struct timespec *create_time_ts, diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index 9c613508eb..817e4a1f57 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -52,7 +52,7 @@ generate_inode(SMBCCTX *context, static int setup_stat(SMBCCTX *context, struct stat *st, - char *fname, + const char *fname, SMB_OFF_T size, int mode) { @@ -180,7 +180,7 @@ SMBC_stat_ctx(SMBCCTX *context, st->st_ino = ino; - setup_stat(context, st, (char *) fname, size, mode); + setup_stat(context, st, fname, size, mode); st->st_atime = convert_timespec_to_time_t(access_time_ts); st->st_ctime = convert_timespec_to_time_t(change_time_ts); diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index af2c56ad40..f8dd7fdefb 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -567,7 +567,7 @@ dos_attr_query(SMBCCTX *context, } /* Obtain the DOS attributes */ - if (!SMBC_getatr(context, srv, CONST_DISCARD(char *, filename), + if (!SMBC_getatr(context, srv, filename, &mode, &size, &create_time_ts, &access_time_ts, @@ -700,8 +700,8 @@ cacl_get(SMBCCTX *context, SMBCSRV *srv, struct cli_state *ipc_cli, struct policy_handle *pol, - char *filename, - char *attr_name, + const char *filename, + const char *attr_name, char *buf, int bufsize) { @@ -2107,12 +2107,12 @@ SMBC_getxattr_ctx(SMBCCTX *context, StrCaseCmp(name, "system.dos_attr.inode") == 0) { /* Yup. */ - char *filename = (char *) name; + const char *filename = name; ret = cacl_get(context, talloc_tos(), srv, ipc_srv == NULL ? NULL : ipc_srv->cli, &ipc_srv->pol, path, filename, - CONST_DISCARD(char *, value), + discard_const_p(char, value), size); if (ret < 0 && errno == 0) { errno = SMBC_errno(context, srv->cli); @@ -2231,7 +2231,7 @@ SMBC_removexattr_ctx(SMBCCTX *context, /* Yup. */ ret = cacl_set(context, talloc_tos(), srv->cli, ipc_srv->cli, &ipc_srv->pol, path, - CONST_DISCARD(char *, name) + 19, + discard_const_p(char, name) + 19, SMBC_XATTR_MODE_REMOVE, 0); TALLOC_FREE(frame); return ret; |