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,
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"
open the tdb
***********************************************************************/
-BOOL netsamlogon_cache_init(void)
+bool netsamlogon_cache_init(void)
{
if (!netsamlogon_tdb) {
netsamlogon_tdb = tdb_open_log(lock_path(NETSAMLOGON_TDB), 0,
Shutdown samlogon_cache database
***********************************************************************/
-BOOL netsamlogon_cache_shutdown(void)
+bool netsamlogon_cache_shutdown(void)
{
if(netsamlogon_tdb)
return (tdb_close(netsamlogon_tdb) == 0);
***********************************************************************/
void netsamlogon_clear_cached_user(TDB_CONTEXT *tdb, NET_USER_INFO_3 *user)
{
- TDB_DATA key;
- BOOL got_tdb = False;
+ bool got_tdb = False;
DOM_SID sid;
fstring key_str, sid_string;
fstr_sprintf(key_str, "UG/%s", sid_to_string(sid_string, &sid));
- DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key.dptr));
+ DEBUG(10, ("netsamlogon_clear_cached_user: clearing %s\n", key_str));
tdb_delete(tdb, string_tdb_data(key_str));
username should be in UTF-8 format
***********************************************************************/
-BOOL netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user )
+bool netsamlogon_cache_store( const char *username, NET_USER_INFO_3 *user )
{
TDB_DATA data;
fstring keystr;
prs_struct ps;
- BOOL result = False;
+ bool result = False;
DOM_SID user_sid;
time_t t = time(NULL);
TALLOC_CTX *mem_ctx;
if ( net_io_user_info3("", user, &ps, 0, 3, 0) )
{
data.dsize = prs_offset( &ps );
- data.dptr = prs_data_p( &ps );
+ data.dptr = (uint8 *)prs_data_p( &ps );
if (tdb_store_bystring(netsamlogon_tdb, keystr, data, TDB_REPLACE) != -1)
result = True;
data = tdb_fetch_bystring( netsamlogon_tdb, keystr );
if ( data.dptr ) {
-
- if ( (user = SMB_MALLOC_P(NET_USER_INFO_3)) == NULL )
+
+ user = TALLOC_ZERO_P(mem_ctx, NET_USER_INFO_3);
+ if (user == NULL) {
return NULL;
-
+ }
+
prs_init( &ps, 0, mem_ctx, UNMARSHALL );
- prs_give_memory( &ps, data.dptr, data.dsize, True );
+ prs_give_memory( &ps, (char *)data.dptr, data.dsize, True );
if ( !prs_uint32( "timestamp", &ps, 0, &t ) ) {
prs_mem_free( &ps );
- SAFE_FREE(user);
+ TALLOC_FREE(user);
return False;
}
if ( !net_io_user_info3("", user, &ps, 0, 3, 0) ) {
- SAFE_FREE( user );
+ TALLOC_FREE( user );
}
prs_mem_free( &ps );
if ( (time_diff < 0 ) || (time_diff > lp_winbind_cache_time()) ) {
DEBUG(10,("netsamlogon_cache_get: cache entry expired \n"));
tdb_delete( netsamlogon_tdb, key );
- SAFE_FREE( user );
+ TALLOC_FREE( user );
}
#endif
}
return user;
}
-BOOL netsamlogon_cache_have(const DOM_SID *user_sid)
+bool netsamlogon_cache_have(const DOM_SID *user_sid)
{
TALLOC_CTX *mem_ctx = talloc_init("netsamlogon_cache_have");
NET_USER_INFO_3 *user = NULL;
- BOOL result;
+ bool result;
if (!mem_ctx)
return False;
result = (user != NULL);
talloc_destroy(mem_ctx);
- SAFE_FREE(user);
return result;
}