2001-12-03 07:39:23 +03:00
/*
Samba Unix / Linux SMB client library
Distributed SMB / CIFS Server Management Utility
Copyright ( C ) 2001 Steve French ( sfrench @ us . ibm . com )
Copyright ( C ) 2001 Jim McDonough ( jmcd @ us . ibm . com )
Copyright ( C ) 2001 Andrew Tridgell ( tridge @ samba . org )
Copyright ( C ) 2001 Andrew Bartlett ( abartlet @ samba . org )
Originally written by Steve and Jim . Largely rewritten by tridge in
November 2001.
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
2001-12-03 07:39:23 +03:00
( at your option ) any later version .
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 .
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>. */
2001-12-03 07:39:23 +03:00
# include "includes.h"
2004-10-07 08:01:18 +04:00
# include "utils/net.h"
2001-12-03 07:39:23 +03:00
2001-12-14 05:15:04 +03:00
/* The following messages were for error checking that is not properly
2001-12-14 05:45:13 +03:00
reported at the moment . Which should be reinstated ? */
2001-12-03 07:39:23 +03:00
# define ERRMSG_TARGET_WG_NOT_VALID "\nTarget workgroup option not valid "\
" except on net rap server command, ignored "
# define ERRMSG_INVALID_HELP_OPTION "\nInvalid help option\n"
# define ERRMSG_BOTH_SERVER_IPADDRESS "\nTarget server and IP address both "\
" specified. Do not set both at the same time. The target IP address was used \n "
2002-07-15 14:35:28 +04:00
const char * share_type [ ] = {
2001-12-03 07:39:23 +03:00
" Disk " ,
" Print " ,
" Dev " ,
" IPC "
} ;
2001-12-14 05:15:04 +03:00
static int errmsg_not_implemented ( void )
{
d_printf ( " \n Not implemented \n " ) ;
return 0 ;
}
2001-12-03 10:42:18 +03:00
2001-12-11 01:25:21 +03:00
int net_rap_file_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2002-07-15 14:35:28 +04:00
return net_help_file ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
}
/***************************************************************************
list info on an open file
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static void file_fn ( const char * pPath , const char * pUser , uint16 perms ,
uint16 locks , uint32 id )
{
2002-07-15 14:35:28 +04:00
d_printf ( " %-7.1d %-20.20s 0x%-4.2x %-6.1d %s \n " ,
2001-12-03 07:39:23 +03:00
id , pUser , perms , locks , pPath ) ;
}
static void one_file_fn ( const char * pPath , const char * pUser , uint16 perms ,
uint16 locks , uint32 id )
{
2001-12-14 05:15:04 +03:00
d_printf ( " File ID %d \n " \
" User name %s \n " \
" Locks 0x%-4.2x \n " \
" Path %s \n " \
" Permissions 0x%x \n " ,
id , pUser , locks , pPath , perms ) ;
2001-12-03 07:39:23 +03:00
}
static int rap_file_close ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n Missing fileid of file to close \n \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_file_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetFileClose ( cli , atoi ( argv [ 0 ] ) ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_file_info ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
if ( argc = = 0 )
2001-12-11 01:25:21 +03:00
return net_rap_file_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetFileGetInfo ( cli , atoi ( argv [ 0 ] ) , one_file_fn ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_file_user ( int argc , const char * * argv )
{
2007-10-18 15:00:46 +04:00
struct cli_state * cli ;
int ret ;
2001-12-03 07:39:23 +03:00
if ( argc = = 0 )
2001-12-11 01:25:21 +03:00
return net_rap_file_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
2007-10-18 15:00:46 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
return - 1 ;
/* list open files */
d_printf ( " \n Enumerating open files on remote server: \n \n "
" \n FileId Opened by Perms Locks Path \n "
" ------ --------- ----- ----- ---- \n " ) ;
ret = cli_NetFileEnum ( cli , argv [ 0 ] , NULL , file_fn ) ;
2007-10-22 15:10:55 +04:00
if ( ret = = - 1 )
d_printf ( " \n Operation not supported by server! \n \n " ) ;
2007-10-18 15:00:46 +04:00
cli_shutdown ( cli ) ;
return ret ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_file ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
{ " CLOSE " , rap_file_close } ,
{ " USER " , rap_file_user } ,
{ " INFO " , rap_file_info } ,
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
/* list open files */
2007-10-18 15:00:46 +04:00
d_printf ( " \n Enumerating open files on remote server: \n \n "
" \n FileId Opened by Perms Locks Path \n "
" ------ --------- ----- ----- ---- \n " ) ;
2001-12-03 07:39:23 +03:00
ret = cli_NetFileEnum ( cli , NULL , NULL , file_fn ) ;
2007-10-22 15:10:55 +04:00
if ( ret = = - 1 )
d_printf ( " \n Operation not supported by server! \n \n " ) ;
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_file_usage ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_share_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2002-07-15 14:35:28 +04:00
return net_help_share ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-14 05:15:04 +03:00
static void long_share_fn ( const char * share_name , uint32 type ,
const char * comment , void * state )
2001-12-03 07:39:23 +03:00
{
2004-02-11 17:59:08 +03:00
d_printf ( " %-12s %-8.8s %-50s \n " ,
2001-12-14 05:15:04 +03:00
share_name , share_type [ type ] , comment ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-14 05:15:04 +03:00
static void share_fn ( const char * share_name , uint32 type ,
const char * comment , void * state )
2001-12-03 07:39:23 +03:00
{
2004-02-11 17:59:08 +03:00
d_printf ( " %s \n " , share_name ) ;
2001-12-03 07:39:23 +03:00
}
static int rap_share_delete ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
if ( argc = = 0 ) {
2001-12-14 05:45:13 +03:00
d_printf ( " \n \n Share name not specified \n " ) ;
return net_rap_share_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
}
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetShareDelete ( cli , argv [ 0 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_share_add ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
RAP_SHARE_INFO_2 sinfo ;
char * p ;
char * sharename ;
if ( argc = = 0 ) {
2001-12-14 05:45:13 +03:00
d_printf ( " \n \n Share name not specified \n " ) ;
return net_rap_share_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
}
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2004-12-07 21:25:53 +03:00
sharename = SMB_STRDUP ( argv [ 0 ] ) ;
2001-12-03 07:39:23 +03:00
p = strchr ( sharename , ' = ' ) ;
2006-03-12 01:21:27 +03:00
if ( p = = NULL ) {
d_printf ( " Server path not specified \n " ) ;
return net_rap_share_usage ( argc , argv ) ;
}
2001-12-03 07:39:23 +03:00
* p = 0 ;
strlcpy ( sinfo . share_name , sharename , sizeof ( sinfo . share_name ) ) ;
sinfo . reserved1 = ' \0 ' ;
sinfo . share_type = 0 ;
2003-01-03 11:28:12 +03:00
sinfo . comment = smb_xstrdup ( opt_comment ) ;
2001-12-03 07:39:23 +03:00
sinfo . perms = 0 ;
sinfo . maximum_users = opt_maxusers ;
sinfo . active_users = 0 ;
sinfo . path = p + 1 ;
memset ( sinfo . password , ' \0 ' , sizeof ( sinfo . password ) ) ;
sinfo . reserved2 = ' \0 ' ;
ret = cli_NetShareAdd ( cli , & sinfo ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_share ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
{ " DELETE " , rap_share_delete } ,
{ " CLOSE " , rap_share_delete } ,
{ " ADD " , rap_share_add } ,
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
if ( opt_long_list_entries ) {
2001-12-14 05:15:04 +03:00
d_printf (
" \n Enumerating shared resources (exports) on remote server: \n \n " \
" \n Share name Type Description \n " \
" ---------- ---- ----------- \n " ) ;
2001-12-03 07:39:23 +03:00
ret = cli_RNetShareEnum ( cli , long_share_fn , NULL ) ;
2004-02-11 17:59:08 +03:00
} else {
ret = cli_RNetShareEnum ( cli , share_fn , NULL ) ;
2001-12-03 07:39:23 +03:00
}
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_share_usage ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_session_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf (
" \n net rap session [misc. options] [targets] " \
" \n \t enumerates all active SMB/CIFS sessions on target server \n " ) ;
d_printf (
" \n net rap session DELETE <client_name> [misc. options] [targets] \n " \
" \t or " \
" \n net rap session CLOSE <client_name> [misc. options] [targets] " \
" \n \t Deletes (closes) a session from specified client to server \n " ) ;
2003-04-14 08:00:37 +04:00
d_printf (
" \n net rap session INFO <client_name> " \
" \n \t Enumerates all open files in specified session \n " ) ;
2001-12-14 05:15:04 +03:00
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
static void list_sessions_func ( char * wsname , char * username , uint16 conns ,
uint16 opens , uint16 users , uint32 sess_time ,
uint32 idle_time , uint32 user_flags , char * clitype )
{
int hrs = idle_time / 3600 ;
int min = ( idle_time / 60 ) % 60 ;
int sec = idle_time % 60 ;
d_printf ( " \\ \\ %-18.18s %-20.20s %-18.18s %5d %2.2d:%2.2d:%2.2d \n " ,
wsname , username , clitype , opens , hrs , min , sec ) ;
}
2001-12-14 05:15:04 +03:00
static void display_session_func ( const char * wsname , const char * username ,
uint16 conns , uint16 opens , uint16 users ,
uint32 sess_time , uint32 idle_time ,
uint32 user_flags , const char * clitype )
2001-12-03 07:39:23 +03:00
{
int ihrs = idle_time / 3600 ;
int imin = ( idle_time / 60 ) % 60 ;
int isec = idle_time % 60 ;
int shrs = sess_time / 3600 ;
int smin = ( sess_time / 60 ) % 60 ;
int ssec = sess_time % 60 ;
d_printf ( " User name %-20.20s \n " \
" Computer %-20.20s \n " \
" Guest logon %-20.20s \n " \
" Client Type %-40.40s \n " \
" Sess time %2.2d:%2.2d:%2.2d \n " \
" Idle time %2.2d:%2.2d:%2.2d \n " ,
username , wsname ,
( user_flags & 0x0 ) ? " yes " : " no " , clitype ,
shrs , smin , ssec , ihrs , imin , isec ) ;
}
2001-12-14 05:15:04 +03:00
static void display_conns_func ( uint16 conn_id , uint16 conn_type , uint16 opens ,
uint16 users , uint32 conn_time ,
const char * username , const char * netname )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf ( " %-14.14s %-8.8s %5d \n " ,
netname , share_type [ conn_type ] , opens ) ;
2001-12-03 07:39:23 +03:00
}
static int rap_session_info ( int argc , const char * * argv )
{
const char * sessname ;
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
if ( argc = = 0 )
2001-12-11 01:25:21 +03:00
return net_rap_session_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
sessname = argv [ 0 ] ;
ret = cli_NetSessionGetInfo ( cli , sessname , display_session_func ) ;
if ( ret < 0 ) {
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-14 05:15:04 +03:00
d_printf ( " Share name Type # Opens \n ------------------------- " \
" ----------------------------------------------------- \n " ) ;
2001-12-03 07:39:23 +03:00
ret = cli_NetConnectionEnum ( cli , sessname , display_conns_func ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_session_delete ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
if ( argc = = 0 )
2001-12-11 01:25:21 +03:00
return net_rap_session_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
ret = cli_NetSessionDel ( cli , argv [ 0 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_session ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
{ " INFO " , rap_session_info } ,
{ " DELETE " , rap_session_delete } ,
{ " CLOSE " , rap_session_delete } ,
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2001-12-14 05:15:04 +03:00
d_printf ( " Computer User name " \
" Client Type Opens Idle time \n " \
" ------------------------------------------ " \
" ------------------------------------ \n " ) ;
2001-12-03 07:39:23 +03:00
ret = cli_NetSessionEnum ( cli , list_sessions_func ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_session_usage ) ;
2001-12-03 07:39:23 +03:00
}
/****************************************************************************
list a server name
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-12-14 05:15:04 +03:00
static void display_server_func ( const char * name , uint32 m ,
const char * comment , void * reserved )
2001-12-03 07:39:23 +03:00
{
d_printf ( " \t %-16.16s %s \n " , name , comment ) ;
}
2001-12-11 01:25:21 +03:00
int net_rap_server_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf ( " net rap server [misc. options] [target] \n \t " \
" lists the servers in the specified domain or workgroup. \n " ) ;
d_printf ( " \n \t If domain is not specified, it uses the current " \
" domain or workgroup as \n \t the default. \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2006-10-09 11:17:37 +04:00
static int net_rap_server_name ( int argc , const char * argv [ ] )
{
struct cli_state * cli ;
char * name ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2006-10-09 11:17:37 +04:00
return - 1 ;
if ( ! cli_get_server_name ( NULL , cli , & name ) ) {
d_fprintf ( stderr , " cli_get_server_name failed \n " ) ;
cli_shutdown ( cli ) ;
return - 1 ;
}
d_printf ( " Server name = %s \n " , name ) ;
TALLOC_FREE ( name ) ;
cli_shutdown ( cli ) ;
return 0 ;
}
2001-12-03 07:39:23 +03:00
2001-12-11 01:25:21 +03:00
int net_rap_server ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct cli_state * cli ;
int ret ;
2006-10-09 11:17:37 +04:00
if ( argc > 0 ) {
2007-05-17 17:56:19 +04:00
if ( strequal ( argv [ 0 ] , " name " ) ) {
return net_rap_server_name ( argc , argv ) ;
}
/* smb4k uses 'net [rap|rpc] server domain' to query servers in a domain */
/* Fall through for 'domain', any other forms will cause to show usage message */
if ( ! strequal ( argv [ 0 ] , " domain " ) ) {
2006-10-09 11:17:37 +04:00
return net_rap_server_usage ( argc - 1 , argv + 1 ) ;
}
}
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2001-12-14 05:15:04 +03:00
d_printf ( " \n Enumerating servers in this domain or workgroup: \n \n " \
" \t Server name Server description \n " \
" \t ------------- ---------------------------- \n " ) ;
ret = cli_NetServerEnum ( cli , cli - > server_domain , SV_TYPE_ALL ,
display_server_func , NULL ) ;
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_domain_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf ( " net rap domain [misc. options] [target] \n \t lists the " \
" domains or workgroups visible on the current network \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2001-12-11 01:25:21 +03:00
int net_rap_domain ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2001-12-14 05:15:04 +03:00
d_printf ( " \n Enumerating domains: \n \n " \
" \t Domain name Server name of Browse Master \n " \
" \t ------------- ---------------------------- \n " ) ;
ret = cli_NetServerEnum ( cli , cli - > server_domain , SV_TYPE_DOMAIN_ENUM ,
display_server_func , NULL ) ;
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_printq_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf (
" net rap printq [misc. options] [targets] \n " \
" \t or \n " \
" net rap printq list [<queue_name>] [misc. options] [targets] \n " \
" \t lists the specified queue and jobs on the target server. \n " \
" \t If the queue name is not specified, all queues are listed. \n \n " ) ;
d_printf (
" net rap printq delete [<queue name>] [misc. options] [targets] \n " \
" \t deletes the specified job number on the target server, or the \n " \
" \t printer queue if no job number is specified \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-14 05:15:04 +03:00
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2001-12-14 05:15:04 +03:00
static void enum_queue ( const char * queuename , uint16 pri , uint16 start ,
uint16 until , const char * sep , const char * pproc ,
const char * dest , const char * qparms ,
const char * qcomment , uint16 status , uint16 jobcount )
{
d_printf ( " %-17.17s Queue %5d jobs " ,
queuename , jobcount ) ;
2001-12-03 07:39:23 +03:00
switch ( status ) {
case 0 :
2001-12-14 05:15:04 +03:00
d_printf ( " *Printer Active* \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
case 1 :
2001-12-14 05:15:04 +03:00
d_printf ( " *Printer Paused* \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
case 2 :
2001-12-14 05:15:04 +03:00
d_printf ( " *Printer error* \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
case 3 :
2001-12-14 05:15:04 +03:00
d_printf ( " *Delete Pending* \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
default :
2001-12-14 05:15:04 +03:00
d_printf ( " **UNKNOWN STATUS** \n " ) ;
2001-12-03 07:39:23 +03:00
}
}
2001-12-14 05:15:04 +03:00
static void enum_jobs ( uint16 jobid , const char * ownername ,
const char * notifyname , const char * datatype ,
const char * jparms , uint16 pos , uint16 status ,
2002-07-15 14:35:28 +04:00
const char * jstatus , unsigned int submitted , unsigned int jobsize ,
2001-12-14 05:15:04 +03:00
const char * comment )
{
d_printf ( " %-23.23s %5d %9d " ,
ownername , jobid , jobsize ) ;
2001-12-03 07:39:23 +03:00
switch ( status ) {
case 0 :
2001-12-14 05:15:04 +03:00
d_printf ( " Waiting \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
case 1 :
2001-12-14 05:15:04 +03:00
d_printf ( " Held in queue \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
case 2 :
2001-12-14 05:15:04 +03:00
d_printf ( " Spooling \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
case 3 :
2001-12-14 05:15:04 +03:00
d_printf ( " Printing \n " ) ;
2001-12-03 07:39:23 +03:00
break ;
default :
2001-12-14 05:15:04 +03:00
d_printf ( " **UNKNOWN STATUS** \n " ) ;
2001-12-03 07:39:23 +03:00
}
}
2001-12-14 05:15:04 +03:00
# define PRINTQ_ENUM_DISPLAY \
" Print queues at \\ \\ %s \n \n " \
" Name Job # Size Status \n \n " \
" ------------------------------------------------------------------ " \
" ------------- \n "
2001-12-03 07:39:23 +03:00
static int rap_printq_info ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
if ( argc = = 0 )
2001-12-11 01:25:21 +03:00
return net_rap_printq_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2001-12-14 05:15:04 +03:00
d_printf ( PRINTQ_ENUM_DISPLAY , cli - > desthost ) ; /* list header */
2001-12-03 07:39:23 +03:00
ret = cli_NetPrintQGetInfo ( cli , argv [ 0 ] , enum_queue , enum_jobs ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_printq_delete ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
if ( argc = = 0 )
2001-12-11 01:25:21 +03:00
return net_rap_printq_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_printjob_del ( cli , atoi ( argv [ 0 ] ) ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_printq ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct cli_state * cli ;
int ret ;
struct functable func [ ] = {
{ " INFO " , rap_printq_info } ,
{ " DELETE " , rap_printq_delete } ,
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2001-12-14 05:15:04 +03:00
d_printf ( PRINTQ_ENUM_DISPLAY , cli - > desthost ) ; /* list header */
2001-12-03 07:39:23 +03:00
ret = cli_NetPrintQEnum ( cli , enum_queue , enum_jobs ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_printq_usage ) ;
2001-12-03 07:39:23 +03:00
}
2002-04-05 05:36:28 +04:00
static int net_rap_user_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2002-04-05 05:36:28 +04:00
return net_help_user ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
}
2005-04-10 18:44:56 +04:00
static void user_fn ( const char * user_name , void * state )
2001-12-03 07:39:23 +03:00
{
d_printf ( " %-21.21s \n " , user_name ) ;
}
2001-12-14 05:15:04 +03:00
static void long_user_fn ( const char * user_name , const char * comment ,
const char * home_dir , const char * logon_script ,
void * state )
2001-12-03 07:39:23 +03:00
{
2003-05-09 16:58:28 +04:00
d_printf ( " %-21.21s %s \n " ,
2002-03-30 00:09:44 +03:00
user_name , comment ) ;
2001-12-03 07:39:23 +03:00
}
static void group_member_fn ( const char * user_name , void * state )
{
d_printf ( " %-21.21s \n " , user_name ) ;
}
static int rap_user_delete ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n \n User name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_user_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetUserDelete ( cli , argv [ 0 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_user_add ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
RAP_USER_INFO_1 userinfo ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n \n User name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_user_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
2003-03-18 14:22:52 +03:00
safe_strcpy ( userinfo . user_name , argv [ 0 ] , sizeof ( userinfo . user_name ) - 1 ) ;
2001-12-03 07:39:23 +03:00
if ( opt_flags = = - 1 )
opt_flags = 0x21 ;
userinfo . userflags = opt_flags ;
userinfo . reserved1 = ' \0 ' ;
2003-01-03 11:28:12 +03:00
userinfo . comment = smb_xstrdup ( opt_comment ) ;
2001-12-03 07:39:23 +03:00
userinfo . priv = 1 ;
userinfo . home_dir = NULL ;
userinfo . logon_script = NULL ;
2002-07-15 14:35:28 +04:00
2001-12-03 07:39:23 +03:00
ret = cli_NetUserAdd ( cli , & userinfo ) ;
2002-07-15 14:35:28 +04:00
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_user_info ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n \n User name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_user_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetUserGetGroups ( cli , argv [ 0 ] , group_member_fn , NULL ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_user ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2002-04-04 20:48:23 +04:00
int ret = - 1 ;
2001-12-03 07:39:23 +03:00
struct functable func [ ] = {
{ " ADD " , rap_user_add } ,
{ " INFO " , rap_user_info } ,
{ " DELETE " , rap_user_delete } ,
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
struct cli_state * cli ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2002-04-04 20:48:23 +04:00
goto done ;
2001-12-03 07:39:23 +03:00
if ( opt_long_list_entries ) {
2002-03-30 00:09:44 +03:00
d_printf ( " \n User name Comment " \
" \n ----------------------------- \n " ) ;
2001-12-03 07:39:23 +03:00
ret = cli_RNetUserEnum ( cli , long_user_fn , NULL ) ;
cli_shutdown ( cli ) ;
2002-04-04 20:48:23 +04:00
goto done ;
2001-12-03 07:39:23 +03:00
}
2005-04-10 18:44:56 +04:00
ret = cli_RNetUserEnum0 ( cli , user_fn , NULL ) ;
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
2002-04-04 20:48:23 +04:00
goto done ;
2001-12-03 07:39:23 +03:00
}
2002-04-04 20:48:23 +04:00
ret = net_run_function ( argc , argv , func , net_rap_user_usage ) ;
done :
if ( ret ! = 0 ) {
DEBUG ( 1 , ( " Net user returned: %d \n " , ret ) ) ;
}
return ret ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_group_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2002-07-15 14:35:28 +04:00
return net_help_group ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-14 05:15:04 +03:00
static void long_group_fn ( const char * group_name , const char * comment ,
void * state )
2001-12-03 07:39:23 +03:00
{
2003-05-09 16:58:28 +04:00
d_printf ( " %-21.21s %s \n " , group_name , comment ) ;
2001-12-03 07:39:23 +03:00
}
2005-04-10 18:44:56 +04:00
static void group_fn ( const char * group_name , void * state )
2001-12-03 07:39:23 +03:00
{
d_printf ( " %-21.21s \n " , group_name ) ;
}
static int rap_group_delete ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n \n Group name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_group_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetGroupDelete ( cli , argv [ 0 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_group_add ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
RAP_GROUP_INFO_1 grinfo ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n \n Group name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_group_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
/* BB check for length 21 or smaller explicitly ? BB */
2003-03-18 14:22:52 +03:00
safe_strcpy ( grinfo . group_name , argv [ 0 ] , sizeof ( grinfo . group_name ) - 1 ) ;
2001-12-03 07:39:23 +03:00
grinfo . reserved1 = ' \0 ' ;
2003-01-03 11:28:12 +03:00
grinfo . comment = smb_xstrdup ( opt_comment ) ;
2001-12-03 07:39:23 +03:00
ret = cli_NetGroupAdd ( cli , & grinfo ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_group ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
{ " ADD " , rap_group_add } ,
{ " DELETE " , rap_group_delete } ,
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
if ( opt_long_list_entries ) {
2001-12-14 05:45:13 +03:00
d_printf ( " Group name Comment \n " ) ;
2001-12-03 07:39:23 +03:00
d_printf ( " ----------------------------- \n " ) ;
ret = cli_RNetGroupEnum ( cli , long_group_fn , NULL ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2005-04-10 18:44:56 +04:00
ret = cli_RNetGroupEnum0 ( cli , group_fn , NULL ) ;
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_group_usage ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_groupmember_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf (
" net rap groupmember LIST <group> [misc. options] [targets] " \
" \n \t Enumerate users in a group \n " \
" \n net rap groupmember DELETE <group> <user> [misc. options] " \
" [targets] \n \t Delete sepcified user from specified group \n " \
" \n net rap groupmember ADD <group> <user> [misc. options] [targets] " \
" \n \t Add specified user to specified group \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
static int rap_groupmember_add ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc ! = 2 ) {
d_printf ( " \n \n Group or user name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_groupmember_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetGroupAddUser ( cli , argv [ 0 ] , argv [ 1 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_groupmember_delete ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc ! = 2 ) {
d_printf ( " \n \n Group or user name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_groupmember_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetGroupDelUser ( cli , argv [ 0 ] , argv [ 1 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
static int rap_groupmember_list ( int argc , const char * * argv )
{
struct cli_state * cli ;
int ret ;
2001-12-14 05:45:13 +03:00
if ( argc = = 0 ) {
d_printf ( " \n \n Group name not specified \n " ) ;
2001-12-11 01:25:21 +03:00
return net_rap_groupmember_usage ( argc , argv ) ;
2001-12-14 05:45:13 +03:00
}
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
ret = cli_NetGroupGetUsers ( cli , argv [ 0 ] , group_member_fn , NULL ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_groupmember ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
{ " ADD " , rap_groupmember_add } ,
{ " LIST " , rap_groupmember_list } ,
{ " DELETE " , rap_groupmember_delete } ,
{ NULL , NULL }
} ;
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_groupmember_usage ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_validate_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf ( " net rap validate <username> [password] \n " \
" \t Validate user and password to check whether they " \
" can access target server or domain \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2001-12-11 01:25:21 +03:00
int net_rap_validate ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
return errmsg_not_implemented ( ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_service_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf ( " net rap service [misc. options] [targets] \n " \
" \t lists all running service daemons on target server \n " ) ;
d_printf ( " \n net rap service START <name> [service startup arguments] " \
" [misc. options] [targets] " \
" \n \t Start named service on remote server \n " ) ;
d_printf ( " \n net rap service STOP <name> [misc. options] [targets] \n " \
" \n \t Stop named service on remote server \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2001-12-14 05:15:04 +03:00
static int rap_service_start ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
return errmsg_not_implemented ( ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-14 05:15:04 +03:00
static int rap_service_stop ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
return errmsg_not_implemented ( ) ;
2001-12-03 07:39:23 +03:00
}
2005-04-10 18:44:56 +04:00
static void service_fn ( const char * service_name , const char * dummy ,
void * state )
{
d_printf ( " %-21.21s \n " , service_name ) ;
}
2001-12-11 01:25:21 +03:00
int net_rap_service ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
2001-12-14 05:15:04 +03:00
{ " START " , rap_service_start } ,
{ " STOP " , rap_service_stop } ,
2001-12-03 07:39:23 +03:00
{ NULL , NULL }
} ;
if ( argc = = 0 ) {
struct cli_state * cli ;
int ret ;
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
if ( opt_long_list_entries ) {
2001-12-14 05:45:13 +03:00
d_printf ( " Service name Comment \n " ) ;
2001-12-03 07:39:23 +03:00
d_printf ( " ----------------------------- \n " ) ;
ret = cli_RNetServiceEnum ( cli , long_group_fn , NULL ) ;
}
2005-04-10 18:44:56 +04:00
ret = cli_RNetServiceEnum ( cli , service_fn , NULL ) ;
2001-12-03 07:39:23 +03:00
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
return net_run_function ( argc , argv , func , net_rap_service_usage ) ;
2001-12-03 07:39:23 +03:00
}
2001-12-11 01:25:21 +03:00
int net_rap_password_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf (
" net rap password <user> <oldpwo> <newpw> [misc. options] [target] \n " \
" \t changes the password for the specified user at target \n " ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2001-12-11 01:25:21 +03:00
int net_rap_password ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct cli_state * cli ;
int ret ;
if ( argc < 3 )
2001-12-11 01:25:21 +03:00
return net_rap_password_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
2007-09-17 19:11:20 +04:00
if ( ! NT_STATUS_IS_OK ( net_make_ipc_connection ( 0 , & cli ) ) )
2001-12-03 07:39:23 +03:00
return - 1 ;
/* BB Add check for password lengths? */
ret = cli_oem_change_password ( cli , argv [ 0 ] , argv [ 2 ] , argv [ 1 ] ) ;
cli_shutdown ( cli ) ;
return ret ;
}
2001-12-11 01:25:21 +03:00
int net_rap_admin_usage ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
d_printf (
" net rap admin <remote command> [cmd args [env]] [misc. options] [targets] " \
" \n \t executes a remote command on an os/2 target server \n " ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
2001-12-11 01:25:21 +03:00
int net_rap_admin ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
2001-12-14 05:15:04 +03:00
return errmsg_not_implemented ( ) ;
2001-12-03 07:39:23 +03:00
}
/* The help subsystem for the RAP subcommand */
int net_rap_usage ( int argc , const char * * argv )
{
d_printf ( " net rap domain \t to list domains \n " \
2002-03-15 23:03:07 +03:00
" net rap file \t \t to list open files on a server \n " \
2001-12-03 07:39:23 +03:00
" net rap group \t to list user groups \n " \
2002-03-15 23:03:07 +03:00
" net rap groupmember \t to list users in a group \n " \
" net rap password \t to change the password of a user \n " \
2001-12-03 07:39:23 +03:00
" net rap printq \t to list the print queues on a server \n " \
" net rap server \t to list servers in a domain \n " \
" net rap session \t to list clients with open sessions to a server \n " \
" net rap share \t to list shares exported by a server \n " \
2002-03-15 23:03:07 +03:00
" net rap user \t \t to list users \n " \
2001-12-03 07:39:23 +03:00
" net rap validate \t to check whether a user and the corresponding password are valid \n " \
" net rap help \n " \
" \n Type \" net help <option> \" to get more information on that option \n \n " ) ;
2002-03-15 23:03:07 +03:00
net_common_flags_usage ( argc , argv ) ;
2001-12-03 07:39:23 +03:00
return - 1 ;
}
/*
2002-03-15 23:03:07 +03:00
handle " net rap help * " subcommands
2001-12-03 07:39:23 +03:00
*/
2002-03-15 23:03:07 +03:00
int net_rap_help ( int argc , const char * * argv )
2001-12-03 07:39:23 +03:00
{
struct functable func [ ] = {
2001-12-11 01:25:21 +03:00
{ " FILE " , net_rap_file_usage } ,
{ " SHARE " , net_rap_share_usage } ,
{ " SESSION " , net_rap_session_usage } ,
{ " SERVER " , net_rap_server_usage } ,
{ " DOMAIN " , net_rap_domain_usage } ,
{ " PRINTQ " , net_rap_printq_usage } ,
{ " USER " , net_rap_user_usage } ,
{ " GROUP " , net_rap_group_usage } ,
{ " VALIDATE " , net_rap_validate_usage } ,
{ " GROUPMEMBER " , net_rap_groupmember_usage } ,
{ " ADMIN " , net_rap_admin_usage } ,
{ " SERVICE " , net_rap_service_usage } ,
{ " PASSWORD " , net_rap_password_usage } ,
2001-12-03 07:39:23 +03:00
{ NULL , NULL } } ;
2002-03-15 23:03:07 +03:00
return net_run_function ( argc , argv , func , net_rap_usage ) ;
2001-12-03 07:39:23 +03:00
}
/* Entry-point for all the RAP functions. */
int net_rap ( int argc , const char * * argv )
{
struct functable func [ ] = {
2001-12-11 01:25:21 +03:00
{ " FILE " , net_rap_file } ,
{ " SHARE " , net_rap_share } ,
{ " SESSION " , net_rap_session } ,
{ " SERVER " , net_rap_server } ,
{ " DOMAIN " , net_rap_domain } ,
{ " PRINTQ " , net_rap_printq } ,
{ " USER " , net_rap_user } ,
{ " GROUP " , net_rap_group } ,
{ " VALIDATE " , net_rap_validate } ,
{ " GROUPMEMBER " , net_rap_groupmember } ,
{ " ADMIN " , net_rap_admin } ,
{ " SERVICE " , net_rap_service } ,
{ " PASSWORD " , net_rap_password } ,
{ " HELP " , net_rap_help } ,
2001-12-03 07:39:23 +03:00
{ NULL , NULL }
} ;
return net_run_function ( argc , argv , func , net_rap_usage ) ;
}