2008-05-08 13:23:38 +04:00
/*
Samba Unix / Linux SMB client library
Distributed SMB / CIFS Server Management Utility
2002-09-11 18:07:21 +04:00
Copyright ( C ) Rafal Szczesniak 2002
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
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2002-09-11 18:07:21 +04:00
( at your option ) any later version .
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
You should have received a copy of the GNU General Public License
2008-05-10 01:22:12 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2002-09-11 18:07:21 +04:00
# include "includes.h"
# include "net.h"
2017-06-28 08:14:36 +03:00
# include "libsmb/samlogon_cache.h"
# include "../librpc/gen_ndr/netlogon.h"
# include "../librpc/gen_ndr/ndr_netlogon.h"
# include "libcli/security/dom_sid.h"
2017-08-03 17:26:04 +03:00
# include "lib/util/strv.h"
2002-09-11 18:07:21 +04:00
/**
* @ file net_cache . c
* @ brief This is part of the net tool which is basically command
* line wrapper for gencache . c functions ( mainly for testing )
*
* */
/*
* These routines are used via gencache_iterate ( ) to display the cache ' s contents
* ( print_cache_entry ) and to flush it ( delete_cache_entry ) .
* Both of them are defined by first arg of gencache_iterate ( ) routine .
*/
2010-11-28 15:14:38 +03:00
static void print_cache_entry ( const char * keystr , DATA_BLOB value ,
2003-01-04 11:48:15 +03:00
const time_t timeout , void * dptr )
2002-09-11 18:07:21 +04:00
{
2006-06-15 01:36:49 +04:00
char * timeout_str ;
2006-06-16 01:03:40 +04:00
char * alloc_str = NULL ;
2010-11-28 15:14:38 +03:00
const char * datastr ;
char * datastr_free = NULL ;
2003-01-04 11:48:15 +03:00
time_t now_t = time ( NULL ) ;
2010-11-27 21:52:11 +03:00
struct tm timeout_tm , now_tm ;
struct tm * ptimeout_tm , * pnow_tm ;
2006-06-15 01:36:49 +04:00
2010-11-27 21:52:11 +03:00
ptimeout_tm = localtime_r ( & timeout , & timeout_tm ) ;
if ( ptimeout_tm = = NULL ) {
2006-06-15 01:36:49 +04:00
return ;
}
2010-11-27 21:52:11 +03:00
pnow_tm = localtime_r ( & now_t , & now_tm ) ;
if ( pnow_tm = = NULL ) {
2006-06-15 01:36:49 +04:00
return ;
}
2003-01-04 11:48:15 +03:00
/* form up timeout string depending whether it's today's date or not */
2010-11-27 21:52:11 +03:00
if ( timeout_tm . tm_year ! = now_tm . tm_year | |
timeout_tm . tm_mon ! = now_tm . tm_mon | |
timeout_tm . tm_mday ! = now_tm . tm_mday ) {
2008-05-08 13:23:38 +04:00
2006-06-15 01:36:49 +04:00
timeout_str = asctime ( & timeout_tm ) ;
if ( ! timeout_str ) {
return ;
2008-05-08 13:23:38 +04:00
}
2006-06-15 01:36:49 +04:00
timeout_str [ strlen ( timeout_str ) - 1 ] = ' \0 ' ; /* remove tailing CR */
} else {
2009-01-01 05:06:57 +03:00
if ( asprintf ( & alloc_str , " %.2d:%.2d:%.2d " , timeout_tm . tm_hour ,
timeout_tm . tm_min , timeout_tm . tm_sec ) = = - 1 ) {
2006-06-16 01:03:40 +04:00
return ;
}
timeout_str = alloc_str ;
2006-06-15 01:36:49 +04:00
}
2008-05-08 13:23:38 +04:00
2010-11-28 15:14:38 +03:00
datastr = ( char * ) value . data ;
2017-08-03 17:26:04 +03:00
if ( strnequal ( keystr , " NAME2SID/ " , strlen ( " NAME2SID/ " ) ) ) {
const char * strv = ( char * ) value . data ;
size_t strv_len = value . length ;
const char * sid = strv_len_next ( strv , strv_len , NULL ) ;
const char * type = strv_len_next ( strv , strv_len , sid ) ;
datastr = talloc_asprintf ( talloc_tos ( ) , " %s (%s) " , sid , type ) ;
}
if ( strnequal ( keystr , " SID2NAME/ " , strlen ( " SID2NAME/ " ) ) ) {
const char * strv = ( char * ) value . data ;
size_t strv_len = value . length ;
const char * domain = strv_len_next ( strv , strv_len , NULL ) ;
const char * name = strv_len_next ( strv , strv_len , domain ) ;
const char * type = strv_len_next ( strv , strv_len , name ) ;
datastr = talloc_asprintf ( talloc_tos ( ) , " %s \\ %s (%s) " ,
domain , name , type ) ;
}
2010-11-28 15:14:38 +03:00
if ( ( value . length > 0 ) & & ( value . data [ value . length - 1 ] ! = ' \0 ' ) ) {
datastr_free = talloc_asprintf (
talloc_tos ( ) , " <binary length %d> " ,
( int ) value . length ) ;
datastr = datastr_free ;
if ( datastr = = NULL ) {
datastr = " <binary> " ;
}
}
2009-07-30 01:59:39 +04:00
d_printf ( _ ( " Key: %s \t Timeout: %s \t Value: %s %s \n " ) , keystr ,
timeout_str , datastr , timeout > now_t ? " " : _ ( " (expired) " ) ) ;
2006-06-16 01:03:40 +04:00
SAFE_FREE ( alloc_str ) ;
2002-09-11 18:07:21 +04:00
}
2003-01-04 11:48:15 +03:00
static void delete_cache_entry ( const char * keystr , const char * datastr ,
const time_t timeout , void * dptr )
2002-09-11 18:07:21 +04:00
{
if ( ! gencache_del ( keystr ) )
2009-07-30 01:59:39 +04:00
d_fprintf ( stderr , _ ( " Couldn't delete entry! key = %s \n " ) ,
keystr ) ;
2002-09-11 18:07:21 +04:00
}
/**
* Parse text representation of timeout value
*
* @ param timeout_str string containing text representation of the timeout
* @ return numeric timeout of time_t type
* */
static time_t parse_timeout ( const char * timeout_str )
{
char sign = ' \0 ' , * number = NULL , unit = ' \0 ' ;
int len , number_begin , number_end ;
time_t timeout ;
/* sign detection */
if ( timeout_str [ 0 ] = = ' ! ' | | timeout_str [ 0 ] = = ' + ' ) {
sign = timeout_str [ 0 ] ;
number_begin = 1 ;
} else {
number_begin = 0 ;
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
/* unit detection */
len = strlen ( timeout_str ) ;
switch ( timeout_str [ len - 1 ] ) {
case ' s ' :
case ' m ' :
case ' h ' :
case ' d ' :
case ' w ' : unit = timeout_str [ len - 1 ] ;
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
/* number detection */
len = ( sign ) ? strlen ( & timeout_str [ number_begin ] ) : len ;
number_end = ( unit ) ? len - 1 : len ;
2004-12-07 21:25:53 +03:00
number = SMB_STRNDUP ( & timeout_str [ number_begin ] , number_end ) ;
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
/* calculate actual timeout value */
timeout = ( time_t ) atoi ( number ) ;
switch ( unit ) {
case ' m ' : timeout * = 60 ; break ;
case ' h ' : timeout * = 60 * 60 ; break ;
case ' d ' : timeout * = 60 * 60 * 24 ; break ;
case ' w ' : timeout * = 60 * 60 * 24 * 7 ; break ; /* that's fair enough, I think :) */
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
switch ( sign ) {
case ' ! ' : timeout = time ( NULL ) - timeout ; break ;
case ' + ' :
default : timeout + = time ( NULL ) ; break ;
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
if ( number ) SAFE_FREE ( number ) ;
2008-05-08 13:23:38 +04:00
return timeout ;
2002-09-11 18:07:21 +04:00
}
/**
2003-01-04 11:48:15 +03:00
* Add an entry to the cache . If it does exist , then set it .
2008-05-08 13:23:38 +04:00
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv key , value and timeout are passed in command line
* @ return 0 on success , otherwise failure
* */
2008-05-10 01:22:12 +04:00
static int net_cache_add ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
const char * keystr , * datastr , * timeout_str ;
time_t timeout ;
2008-05-08 13:23:38 +04:00
2008-05-19 17:40:50 +04:00
if ( argc < 3 | | c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n %s " ,
_ ( " Usage: " ) ,
_ ( " net cache add <key string> <data string> "
2009-07-30 01:59:39 +04:00
" <timeout> \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
keystr = argv [ 0 ] ;
datastr = argv [ 1 ] ;
timeout_str = argv [ 2 ] ;
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
/* parse timeout given in command line */
timeout = parse_timeout ( timeout_str ) ;
if ( ! timeout ) {
2009-07-30 01:59:39 +04:00
d_fprintf ( stderr , _ ( " Invalid timeout argument. \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
2008-05-08 13:23:38 +04:00
2003-01-04 11:48:15 +03:00
if ( gencache_set ( keystr , datastr , timeout ) ) {
2009-07-30 01:59:39 +04:00
d_printf ( _ ( " New cache entry stored successfully. \n " ) ) ;
2002-09-11 18:07:21 +04:00
return 0 ;
2003-01-04 11:48:15 +03:00
}
2008-05-08 13:23:38 +04:00
2009-07-30 01:59:39 +04:00
d_fprintf ( stderr , _ ( " Entry couldn't be added. Perhaps there's already such a key. \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
/**
* Delete an entry in the cache
2008-05-08 13:23:38 +04:00
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv key to delete an entry of
* @ return 0 on success , otherwise failure
* */
2008-05-10 01:22:12 +04:00
static int net_cache_del ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
const char * keystr = argv [ 0 ] ;
2008-05-08 13:23:38 +04:00
2008-05-19 17:40:50 +04:00
if ( argc < 1 | | c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n %s " ,
_ ( " Usage: " ) ,
_ ( " net cache del <key string> \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
if ( gencache_del ( keystr ) ) {
2009-07-30 01:59:39 +04:00
d_printf ( _ ( " Entry deleted. \n " ) ) ;
2002-09-11 18:07:21 +04:00
return 0 ;
2003-01-04 11:48:15 +03:00
}
2002-09-11 18:07:21 +04:00
2009-07-30 01:59:39 +04:00
d_fprintf ( stderr , _ ( " Couldn't delete specified entry \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
/**
* Get and display an entry from the cache
2008-05-08 13:23:38 +04:00
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv key to search an entry of
* @ return 0 on success , otherwise failure
* */
2008-05-10 01:22:12 +04:00
static int net_cache_get ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
const char * keystr = argv [ 0 ] ;
2010-11-28 15:14:38 +03:00
DATA_BLOB value ;
2002-09-11 18:07:21 +04:00
time_t timeout ;
2008-05-19 17:40:50 +04:00
if ( argc < 1 | | c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n %s " ,
_ ( " Usage: " ) ,
_ ( " net cache get <key> \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
2008-05-08 13:23:38 +04:00
2013-09-04 10:22:43 +04:00
if ( gencache_get_data_blob ( keystr , NULL , & value , & timeout , NULL ) ) {
2010-11-28 15:14:38 +03:00
print_cache_entry ( keystr , value , timeout , NULL ) ;
2011-06-14 11:09:07 +04:00
data_blob_free ( & value ) ;
2002-09-11 18:07:21 +04:00
return 0 ;
2003-01-04 11:48:15 +03:00
}
2002-09-11 18:07:21 +04:00
2009-07-30 01:59:39 +04:00
d_fprintf ( stderr , _ ( " Failed to find entry \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
/**
* Search an entry / entries in the cache
2008-05-08 13:23:38 +04:00
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv key pattern to match the entries to
* @ return 0 on success , otherwise failure
* */
2008-05-10 01:22:12 +04:00
static int net_cache_search ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
const char * pattern ;
2008-05-08 13:23:38 +04:00
2008-05-19 17:40:50 +04:00
if ( argc < 1 | | c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n %s " ,
_ ( " Usage: " ) ,
_ ( " net cache search <pattern> \n " ) ) ;
2002-09-11 18:07:21 +04:00
return - 1 ;
}
2008-05-08 13:23:38 +04:00
2002-09-11 18:07:21 +04:00
pattern = argv [ 0 ] ;
2010-11-28 15:14:38 +03:00
gencache_iterate_blobs ( print_cache_entry , NULL , pattern ) ;
2002-09-11 18:07:21 +04:00
return 0 ;
}
/**
* List the contents of the cache
2008-05-08 13:23:38 +04:00
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv ignored in this functionailty
* @ return always returns 0
* */
2008-05-10 01:22:12 +04:00
static int net_cache_list ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
const char * pattern = " * " ;
2008-05-19 17:40:50 +04:00
if ( c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n "
2009-07-30 01:59:39 +04:00
" net cache list \n "
2010-01-19 13:43:54 +03:00
" %s \n " ,
_ ( " Usage: " ) ,
_ ( " List all cache entries. " ) ) ;
2008-05-19 17:40:50 +04:00
return 0 ;
}
2010-11-28 15:14:38 +03:00
gencache_iterate_blobs ( print_cache_entry , NULL , pattern ) ;
2002-09-11 18:07:21 +04:00
return 0 ;
}
/**
* Flush the whole cache
2008-05-08 13:23:38 +04:00
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv ignored in this functionality
* @ return always returns 0
* */
2008-05-10 01:22:12 +04:00
static int net_cache_flush ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
const char * pattern = " * " ;
2008-05-19 17:40:50 +04:00
if ( c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n "
2009-07-30 01:59:39 +04:00
" net cache flush \n "
2010-01-19 13:43:54 +03:00
" %s " ,
_ ( " Usage: " ) ,
_ ( " Delete all cache entries. " ) ) ;
2008-05-19 17:40:50 +04:00
return 0 ;
}
2003-01-04 11:48:15 +03:00
gencache_iterate ( delete_cache_entry , NULL , pattern ) ;
2002-09-11 18:07:21 +04:00
return 0 ;
}
2009-07-13 19:04:29 +04:00
static int net_cache_stabilize ( struct net_context * c , int argc ,
const char * * argv )
{
if ( c - > display_usage ) {
2010-01-19 13:43:54 +03:00
d_printf ( " %s \n "
" net cache stabilize \n "
" %s \n " ,
_ ( " Usage: " ) ,
_ ( " Move transient cache content to stable storage " ) ) ;
2009-07-13 19:04:29 +04:00
return 0 ;
}
if ( ! gencache_stabilize ( ) ) {
return - 1 ;
}
return 0 ;
}
2017-06-28 08:14:36 +03:00
static int netsamlog_cache_for_all_cb ( const char * sid_str ,
time_t when_cached ,
struct netr_SamInfo3 * info3 ,
void * private_data )
{
struct net_context * c = ( struct net_context * ) private_data ;
char * name = NULL ;
name = talloc_asprintf ( c , " %s \\ %s " ,
info3 - > base . logon_domain . string ,
info3 - > base . account_name . string ) ;
if ( name = = NULL ) {
return - 1 ;
}
d_printf ( " %-50s %-40s %s \n " ,
sid_str ,
name ,
timestring ( c , when_cached ) ) ;
return 0 ;
}
static int net_cache_samlogon_list ( struct net_context * c ,
int argc ,
const char * * argv )
{
int ret ;
2017-07-04 10:38:07 +03:00
d_printf ( " %-50s %-40s When cached \n " , " SID " , " Name " ) ;
d_printf ( " ------------------------------------------------------------ "
" ------------------------------------------------------------ "
" ---- \n " ) ;
2017-06-28 08:14:36 +03:00
ret = netsamlog_cache_for_all ( netsamlog_cache_for_all_cb , c ) ;
if ( ret = = - 1 ) {
return - 1 ;
}
return 0 ;
}
static int net_cache_samlogon_show ( struct net_context * c ,
int argc ,
const char * * argv )
{
const char * sid_str = argv [ 0 ] ;
struct dom_sid sid ;
struct dom_sid * user_sids = NULL ;
uint32_t num_user_sids ;
struct netr_SamInfo3 * info3 = NULL ;
char * name = NULL ;
uint32_t i ;
NTSTATUS status ;
bool ok ;
if ( argc ! = 1 | | c - > display_usage ) {
d_printf ( " %s \n "
" net cache samlogon show SID \n "
" %s \n " ,
_ ( " Usage: " ) ,
_ ( " Show samlogon cache entry for SID. " ) ) ;
return 0 ;
}
ok = string_to_sid ( & sid , sid_str ) ;
if ( ! ok ) {
d_printf ( " String to SID failed for %s \n " , sid_str ) ;
return - 1 ;
}
info3 = netsamlogon_cache_get ( c , & sid ) ;
if ( info3 = = NULL ) {
d_printf ( " SID %s not found in samlogon cache \n " , sid_str ) ;
return - 1 ;
}
name = talloc_asprintf ( c , " %s \\ %s " ,
info3 - > base . logon_domain . string ,
info3 - > base . account_name . string ) ;
if ( name = = NULL ) {
return - 1 ;
}
d_printf ( " Name: %s \n " , name ) ;
status = sid_array_from_info3 ( c ,
info3 ,
& user_sids ,
& num_user_sids ,
true ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
2018-03-30 17:15:30 +03:00
TALLOC_FREE ( user_sids ) ;
2017-06-28 08:14:36 +03:00
d_printf ( " sid_array_from_info3 failed for %s \n " , sid_str ) ;
return - 1 ;
}
for ( i = 0 ; i < num_user_sids ; i + + ) {
2018-03-30 17:16:47 +03:00
char buf [ DOM_SID_STR_BUFLEN ] ;
dom_sid_string_buf ( & user_sids [ i ] , buf , sizeof ( buf ) ) ;
d_printf ( " SID %2 " PRIu32 " : %s \n " , i , buf ) ;
2017-06-28 08:14:36 +03:00
}
2018-03-30 17:15:30 +03:00
TALLOC_FREE ( user_sids ) ;
2017-06-28 08:14:36 +03:00
return 0 ;
}
static int net_cache_samlogon_ndrdump ( struct net_context * c ,
int argc ,
const char * * argv )
{
const char * sid_str = NULL ;
struct dom_sid sid ;
struct netr_SamInfo3 * info3 = NULL ;
struct ndr_print * ndr_print = NULL ;
bool ok ;
if ( argc ! = 1 | | c - > display_usage ) {
d_printf ( " %s \n "
" net cache samlogon ndrdump SID \n "
" %s \n " ,
_ ( " Usage: " ) ,
_ ( " Show samlogon cache entry for SID. " ) ) ;
return 0 ;
}
sid_str = argv [ 0 ] ;
ok = string_to_sid ( & sid , sid_str ) ;
if ( ! ok ) {
d_printf ( " String to SID failed for %s \n " , sid_str ) ;
return - 1 ;
}
info3 = netsamlogon_cache_get ( c , & sid ) ;
if ( info3 = = NULL ) {
d_printf ( " SID %s not found in samlogon cache \n " , sid_str ) ;
return - 1 ;
}
ndr_print = talloc_zero ( c , struct ndr_print ) ;
if ( ndr_print = = NULL ) {
d_printf ( " Could not allocate memory. \n " ) ;
return - 1 ;
}
ndr_print - > print = ndr_print_printf_helper ;
ndr_print - > depth = 1 ;
ndr_print_netr_SamInfo3 ( ndr_print , " netr_SamInfo3 " , info3 ) ;
TALLOC_FREE ( ndr_print ) ;
return 0 ;
}
static int net_cache_samlogon_delete ( struct net_context * c ,
int argc ,
const char * * argv )
{
const char * sid_str = argv [ 0 ] ;
struct dom_sid sid ;
bool ok ;
if ( argc ! = 1 | | c - > display_usage ) {
d_printf ( " %s \n "
" net cache samlogon delete SID \n "
" %s \n " ,
_ ( " Usage: " ) ,
_ ( " Delete samlogon cache entry for SID. " ) ) ;
return 0 ;
}
ok = string_to_sid ( & sid , sid_str ) ;
if ( ! ok ) {
d_printf ( " String to SID failed for %s \n " , sid_str ) ;
return - 1 ;
}
netsamlogon_clear_cached_user ( & sid ) ;
return 0 ;
}
static int net_cache_samlogon ( struct net_context * c , int argc , const char * * argv )
{
struct functable func [ ] = {
{
" list " ,
net_cache_samlogon_list ,
NET_TRANSPORT_LOCAL ,
N_ ( " List samlogon cache " ) ,
N_ ( " net cache samlogon list \n "
" List samlogon cachen \n " )
} ,
{
" show " ,
net_cache_samlogon_show ,
NET_TRANSPORT_LOCAL ,
N_ ( " Show samlogon cache entry " ) ,
N_ ( " net cache samlogon show SID \n "
" Show samlogon cache entry \n " )
} ,
{
" ndrdump " ,
net_cache_samlogon_ndrdump ,
NET_TRANSPORT_LOCAL ,
N_ ( " Dump the samlogon cache entry NDR blob " ) ,
N_ ( " net cache samlogon ndrdump SID \n "
" Dump the samlogon cache entry NDR blob \n " )
} ,
{
" delete " ,
net_cache_samlogon_delete ,
NET_TRANSPORT_LOCAL ,
N_ ( " Delete samlogon cache entry " ) ,
N_ ( " net cache samlogon delete SID \n "
" Delete samlogon cache entry \n " )
} ,
{ NULL , NULL , 0 , NULL , NULL }
} ;
return net_run_function ( c , argc , argv , " net cache samlogon " , func ) ;
}
2002-09-11 18:07:21 +04:00
/**
* Entry point to ' net cache ' subfunctionality
*
2008-05-10 01:22:12 +04:00
* @ param c A net_context structure
2002-09-11 18:07:21 +04:00
* @ param argv arguments passed to further called functions
* @ return whatever further functions return
* */
2008-05-10 01:22:12 +04:00
int net_cache ( struct net_context * c , int argc , const char * * argv )
2002-09-11 18:07:21 +04:00
{
2008-06-07 04:25:08 +04:00
struct functable func [ ] = {
2008-05-19 17:40:50 +04:00
{
" add " ,
net_cache_add ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " Add new cache entry " ) ,
N_ ( " net cache add <key string> <data string> <timeout> \n "
" Add new cache entry. \n "
" key string \t Key string to add cache data under. \n "
" data string \t Data to store under given key. \n "
" timeout \t Timeout for cache data. " )
2008-05-19 17:40:50 +04:00
} ,
{
" del " ,
net_cache_del ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " Delete existing cache entry by key " ) ,
N_ ( " net cache del <key string> \n "
" Delete existing cache entry by key. \n "
" key string \t Key string to delete. " )
2008-05-19 17:40:50 +04:00
} ,
{
" get " ,
net_cache_get ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " Get cache entry by key " ) ,
N_ ( " net cache get <key string> \n "
" Get cache entry by key. \n "
" key string \t Key string to look up cache entry for. " )
2008-05-19 17:40:50 +04:00
} ,
{
" search " ,
net_cache_search ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " Search entry by pattern " ) ,
N_ ( " net cache search <pattern> \n "
" Search entry by pattern. \n "
" pattern \t Pattern to search for in cache. " )
2008-05-19 17:40:50 +04:00
} ,
{
" list " ,
net_cache_list ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " List all cache entries " ) ,
N_ ( " net cache list \n "
" List all cache entries " )
2008-05-19 17:40:50 +04:00
} ,
{
" flush " ,
net_cache_flush ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " Delete all cache entries " ) ,
N_ ( " net cache flush \n "
" Delete all cache entries " )
2008-05-19 17:40:50 +04:00
} ,
2009-07-13 19:04:29 +04:00
{
" stabilize " ,
net_cache_stabilize ,
NET_TRANSPORT_LOCAL ,
2009-07-30 01:59:39 +04:00
N_ ( " Move transient cache content to stable storage " ) ,
N_ ( " net cache stabilize \n "
" Move transient cache content to stable storage " )
2009-07-13 19:04:29 +04:00
} ,
2017-06-28 08:14:36 +03:00
{
" samlogon " ,
net_cache_samlogon ,
NET_TRANSPORT_LOCAL ,
N_ ( " List contents of the samlogon cache " ) ,
N_ ( " net cache samlogon \n "
" List contents of the samlogon cache " )
} ,
2008-05-19 17:40:50 +04:00
{ NULL , NULL , 0 , NULL , NULL }
2002-09-11 18:07:21 +04:00
} ;
2008-06-07 04:25:08 +04:00
return net_run_function ( c , argc , argv , " net cache " , func ) ;
2002-09-11 18:07:21 +04:00
}