1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-30 13:18:05 +03:00

well, i stuffed up the spooler commands.

This commit is contained in:
Luke Leighton 0001-01-01 00:00:00 +00:00
parent 0aaf0c9c80
commit 7a69633058
5 changed files with 144 additions and 140 deletions

View File

@ -2056,26 +2056,22 @@ BOOL samr_query_dispinfo( POLICY_HND *pol_domain, uint16 level,
/*The following definitions come from rpc_client/cli_spoolss.c */
BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum,
uint32 flags, const char *servername,
BOOL spoolss_enum_printers(uint32 flags, const char *srv_name,
uint32 level,
uint32 *count,
void ***printers);
uint32 spoolss_enum_jobs(struct cli_state *cli, uint16 fnum,
const PRINTER_HND *hnd,
uint32 spoolss_enum_jobs( const POLICY_HND *hnd,
uint32 firstjob,
uint32 numofjobs,
uint32 level,
uint32 *buf_size,
uint32 *count,
void ***jobs);
BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
const char *printername,
BOOL spoolss_open_printer_ex( const char *printername,
uint32 cbbuf, uint32 devmod, uint32 des_access,
const char *station,
const char *username,
PRINTER_HND *hnd);
BOOL spoolss_closeprinter(struct cli_state *cli, uint16 fnum, PRINTER_HND *hnd);
const char *station, const char *username,
POLICY_HND *hnd);
BOOL spoolss_closeprinter(POLICY_HND *hnd);
/*The following definitions come from rpc_client/cli_srvsvc.c */
@ -3170,12 +3166,12 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
const char *username);
BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth);
BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
PRINTER_HND *handle,
POLICY_HND *handle,
char *valuename,
uint32 size);
BOOL spoolss_io_q_getprinterdata(char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_struct *ps, int depth);
BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, PRINTER_HND *hnd);
BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd);
BOOL spoolss_io_q_closeprinter(char *desc, SPOOL_Q_CLOSEPRINTER *q_u, prs_struct *ps, int depth);
BOOL spoolss_io_r_closeprinter(char *desc, SPOOL_R_CLOSEPRINTER *r_u, prs_struct *ps, int depth);
BOOL spoolss_io_q_startdocprinter(char *desc, SPOOL_Q_STARTDOCPRINTER *q_u, prs_struct *ps, int depth);
@ -3218,7 +3214,7 @@ BOOL spoolss_io_r_getprinter(char *desc,
SPOOL_R_GETPRINTER *r_u,
prs_struct *ps, int depth);
BOOL make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER *q_u,
PRINTER_HND *hnd,
POLICY_HND *hnd,
uint32 level,
uint32 buf_size);
BOOL spoolss_io_q_getprinter(char *desc, SPOOL_Q_GETPRINTER *q_u,
@ -3231,7 +3227,7 @@ BOOL spoolss_io_r_addjob(char *desc, SPOOL_R_ADDJOB *r_u, prs_struct *ps, int de
BOOL spoolss_io_q_addjob(char *desc, SPOOL_Q_ADDJOB *q_u, prs_struct *ps, int depth);
void free_r_enumjobs(SPOOL_R_ENUMJOBS *r_u);
BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, int depth);
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const PRINTER_HND *hnd,
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
uint32 firstjob,
uint32 numofjobs,
uint32 level,
@ -3629,18 +3625,15 @@ void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_spoolss.c */
BOOL msrpc_spoolss_enum_printers(struct cli_state *cli,
const char* srv_name,
BOOL msrpc_spoolss_enum_printers( const char* srv_name,
uint32 level,
uint32 *num,
void ***ctr,
PRINT_INFO_FN(fn));
void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]);
void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]);
BOOL msrpc_spoolss_enum_jobs(struct cli_state *cli,
const char* srv_name,
const char* user_name,
const char* printer_name,
BOOL msrpc_spoolss_enum_jobs( const char* printer_name,
const char* station, const char* user_name,
uint32 level,
uint32 *num,
void ***ctr,

View File

@ -177,7 +177,7 @@
#define JOB_WRITE STANDARD_RIGHTS_WRITE|JOB_ACCESS_ADMINISTER
#define JOB_EXECUTE STANDARD_RIGHTS_EXECUTE|JOB_ACCESS_ADMINISTER
#define PRINTER_HND_SIZE 20
#define POLICY_HND_SIZE 20
#define ONE_VALUE 01
#define TWO_VALUE 02
@ -498,13 +498,6 @@ typedef struct s_buffer
} BUFFER;
/* PRINTER_HND */
typedef struct printer_policy_info
{
uint8 data[PRINTER_HND_SIZE]; /* printer handle */
} PRINTER_HND;
/* SPOOL_Q_OPEN_PRINTER_EX request to open a printer */
typedef struct spool_q_open_printer_ex
{
@ -532,14 +525,14 @@ typedef struct spool_q_open_printer_ex
/* SPOOL_Q_OPEN_PRINTER_EX reply to an open printer */
typedef struct spool_r_open_printer_ex
{
PRINTER_HND handle; /* handle used along all transactions (20*uint8) */
POLICY_HND handle; /* handle used along all transactions (20*uint8) */
uint32 status;
} SPOOL_R_OPEN_PRINTER_EX;
typedef struct spool_q_getprinterdata
{
PRINTER_HND handle;
POLICY_HND handle;
UNISTR2 valuename;
uint32 size;
} SPOOL_Q_GETPRINTERDATA;
@ -556,18 +549,18 @@ typedef struct spool_r_getprinterdata
typedef struct spool_q_closeprinter
{
PRINTER_HND handle;
POLICY_HND handle;
} SPOOL_Q_CLOSEPRINTER;
typedef struct spool_r_closeprinter
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 status;
} SPOOL_R_CLOSEPRINTER;
typedef struct spool_q_startpageprinter
{
PRINTER_HND handle;
POLICY_HND handle;
} SPOOL_Q_STARTPAGEPRINTER;
typedef struct spool_r_startpageprinter
@ -577,7 +570,7 @@ typedef struct spool_r_startpageprinter
typedef struct spool_q_endpageprinter
{
PRINTER_HND handle;
POLICY_HND handle;
} SPOOL_Q_ENDPAGEPRINTER;
typedef struct spool_r_endpageprinter
@ -609,7 +602,7 @@ typedef struct spool_doc_info_container
typedef struct spool_q_startdocprinter
{
PRINTER_HND handle;
POLICY_HND handle;
DOC_INFO_CONTAINER doc_info_container;
} SPOOL_Q_STARTDOCPRINTER;
@ -621,7 +614,7 @@ typedef struct spool_r_startdocprinter
typedef struct spool_q_enddocprinter
{
PRINTER_HND handle;
POLICY_HND handle;
} SPOOL_Q_ENDDOCPRINTER;
typedef struct spool_r_enddocprinter
@ -631,7 +624,7 @@ typedef struct spool_r_enddocprinter
typedef struct spool_q_writeprinter
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 buffer_size;
uint8 *buffer;
uint32 buffer_size2;
@ -695,7 +688,7 @@ typedef struct spool_notify_info
/* RemoteFindFirstPrinterChangeNotificationEx query struct */
typedef struct spoolss_q_rffpcnex
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 flags;
uint32 options;
UNISTR2 localmachine;
@ -711,7 +704,7 @@ typedef struct spool_r_rffpcnex
/* Remote Find Next Printer Change Notify Ex */
typedef struct spool_q_rfnpcnex
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 change;
SPOOL_NOTIFY_OPTION option;
} SPOOL_Q_RFNPCNEX;
@ -725,7 +718,7 @@ typedef struct spool_r_rfnpcnex
/* Find Close Printer Notify */
typedef struct spool_q_fcpn
{
PRINTER_HND handle;
POLICY_HND handle;
} SPOOL_Q_FCPN;
typedef struct spool_r_fcpn
@ -828,7 +821,7 @@ typedef struct spool_r_enumprinters
typedef struct spool_q_getprinter
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 level;
uint8* buffer;
uint32 offered;
@ -837,7 +830,7 @@ typedef struct spool_q_getprinter
typedef struct spool_r_getprinter
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 level;
uint32 offered;
@ -862,7 +855,7 @@ struct s_notify_info_data_table
typedef struct spool_q_getprinterdriver2
{
PRINTER_HND handle;
POLICY_HND handle;
UNISTR2 architecture;
uint32 level;
BUFFER buffer;
@ -922,7 +915,7 @@ typedef struct add_jobinfo_1
typedef struct spool_q_addjob
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 level;
BUFFER buffer;
uint32 buf_size;
@ -997,7 +990,7 @@ typedef struct s_job_info_2
typedef struct spool_q_enumjobs
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 firstjob;
uint32 numofjobs;
uint32 level;
@ -1020,7 +1013,7 @@ typedef struct spool_r_enumjobs
typedef struct spool_q_schedulejob
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 jobid;
} SPOOL_Q_SCHEDULEJOB;
@ -1071,7 +1064,7 @@ typedef struct spool_r_enumports
typedef struct spool_q_setjob
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 jobid;
uint32 level;
union {
@ -1122,7 +1115,7 @@ typedef struct spool_form_1
typedef struct spool_q_enumforms
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 level;
BUFFER buffer;
uint32 buf_size;
@ -1234,7 +1227,7 @@ typedef struct spool_user_level
typedef struct spool_q_setprinter
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 level;
SPOOL_PRINTER_INFO_LEVEL info;
@ -1287,7 +1280,7 @@ typedef struct spool_q_addprinterex
typedef struct spool_r_addprinterex
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 status;
} SPOOL_R_ADDPRINTEREX;
@ -1397,7 +1390,7 @@ typedef struct spool_r_enumprintmonitors
typedef struct spool_q_enumprinterdata
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 index;
uint32 valuesize;
uint32 datasize;
@ -1417,7 +1410,7 @@ typedef struct spool_r_enumprinterdata
typedef struct spool_q_setprinterdata
{
PRINTER_HND handle;
POLICY_HND handle;
UNISTR2 value;
uint32 type;
uint32 max_len;
@ -1446,7 +1439,7 @@ typedef struct _form
typedef struct spool_q_addform
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 level;
uint32 level2;
FORM form;
@ -1459,7 +1452,7 @@ typedef struct spool_r_addform
typedef struct spool_q_setform
{
PRINTER_HND handle;
POLICY_HND handle;
UNISTR2 name;
uint32 level;
uint32 level2;
@ -1473,7 +1466,7 @@ typedef struct spool_r_setform
typedef struct spool_q_getjob
{
PRINTER_HND handle;
POLICY_HND handle;
uint32 jobid;
uint32 level;
BUFFER buffer;

View File

@ -35,8 +35,7 @@ extern int DEBUGLEVEL;
/****************************************************************************
do a SPOOLSS Enum Printers
****************************************************************************/
BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum,
uint32 flags, const char *servername,
BOOL spoolss_enum_printers(uint32 flags, const char *srv_name,
uint32 level,
uint32 *count,
void ***printers)
@ -46,6 +45,13 @@ BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum,
SPOOL_Q_ENUMPRINTERS q_o;
BOOL valid_pol = False;
struct cli_connection *con = NULL;
if (!cli_connection_init(srv_name, PIPE_LSARPC, &con))
{
return False;
}
if (count == NULL || printers == NULL) return False;
prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
@ -54,15 +60,15 @@ BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum,
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
DEBUG(5,("SPOOLSS Enum Printers (Server: %s level: %d)\n",
servername, level));
srv_name, level));
make_spoolss_q_enumprinters(&q_o, flags, servername, level, 0x50);
make_spoolss_q_enumprinters(&q_o, flags, srv_name, level, 0x50);
/* turn parameters into data stream */
spoolss_io_q_enumprinters("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
if (rpc_api_pipe_req(cli, fnum, SPOOLSS_ENUMPRINTERS, &buf, &rbuf))
if (rpc_con_pipe_req(con, SPOOLSS_ENUMPRINTERS, &buf, &rbuf))
{
SPOOL_R_ENUMPRINTERS r_o;
BOOL p;
@ -93,14 +99,15 @@ BOOL spoolss_enum_printers(struct cli_state *cli, uint16 fnum,
prs_mem_free(&rbuf);
prs_mem_free(&buf );
cli_connection_unlink(con);
return valid_pol;
}
/****************************************************************************
do a SPOOLSS Enum Jobs
****************************************************************************/
uint32 spoolss_enum_jobs(struct cli_state *cli, uint16 fnum,
const PRINTER_HND *hnd,
uint32 spoolss_enum_jobs( const POLICY_HND *hnd,
uint32 firstjob,
uint32 numofjobs,
uint32 level,
@ -133,7 +140,7 @@ uint32 spoolss_enum_jobs(struct cli_state *cli, uint16 fnum,
spoolss_io_q_enumjobs("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
if (rpc_api_pipe_req(cli, fnum, SPOOLSS_ENUMJOBS, &buf, &rbuf))
if (rpc_hnd_pipe_req(hnd, SPOOLSS_ENUMJOBS, &buf, &rbuf))
{
SPOOL_R_ENUMJOBS r_o;
BOOL p;
@ -172,17 +179,34 @@ uint32 spoolss_enum_jobs(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a SPOOLSS Open Printer Ex
****************************************************************************/
BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
const char *printername,
BOOL spoolss_open_printer_ex( const char *printername,
uint32 cbbuf, uint32 devmod, uint32 des_access,
const char *station,
const char *username,
PRINTER_HND *hnd)
const char *station, const char *username,
POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
SPOOL_Q_OPEN_PRINTER_EX q_o;
BOOL valid_pol = False;
fstring srv_name;
char *s;
struct cli_connection *con = NULL;
memset(srv_name, 0, sizeof(srv_name));
fstrcpy(srv_name, printername);
s = strchr(&srv_name[2], '\\');
if (s != NULL)
{
*s = 0;
}
if (!cli_connection_init(srv_name, PIPE_LSARPC, &con))
{
return False;
}
if (hnd == NULL) return False;
@ -201,7 +225,7 @@ BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
spoolss_io_q_open_printer_ex("", &q_o, &buf, 0);
/* send the data on \PIPE\ */
if (rpc_api_pipe_req(cli, fnum, SPOOLSS_OPENPRINTEREX, &buf, &rbuf))
if (rpc_con_pipe_req(con, SPOOLSS_OPENPRINTEREX, &buf, &rbuf))
{
SPOOL_R_OPEN_PRINTER_EX r_o;
BOOL p;
@ -220,7 +244,10 @@ BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
{
/* ok, at last: we're happy. return the policy handle */
memcpy(hnd, r_o.handle.data, sizeof(hnd->data));
valid_pol = True;
valid_pol = register_policy_hnd(hnd) &&
set_policy_con(hnd, con,
cli_connection_unlink);
}
}
@ -233,7 +260,7 @@ BOOL spoolss_open_printer_ex(struct cli_state *cli, uint16 fnum,
/****************************************************************************
do a SPOOL Close
****************************************************************************/
BOOL spoolss_closeprinter(struct cli_state *cli, uint16 fnum, PRINTER_HND *hnd)
BOOL spoolss_closeprinter(POLICY_HND *hnd)
{
prs_struct rbuf;
prs_struct buf;
@ -256,7 +283,7 @@ BOOL spoolss_closeprinter(struct cli_state *cli, uint16 fnum, PRINTER_HND *hnd)
spoolss_io_q_closeprinter("", &q_c, &buf, 0);
/* send the data on \PIPE\ */
if (rpc_api_pipe_req(cli, fnum, SPOOLSS_CLOSEPRINTER, &buf, &rbuf))
if (rpc_hnd_pipe_req(hnd, SPOOLSS_CLOSEPRINTER, &buf, &rbuf))
{
SPOOL_R_CLOSEPRINTER r_c;
BOOL p;
@ -295,6 +322,8 @@ BOOL spoolss_closeprinter(struct cli_state *cli, uint16 fnum, PRINTER_HND *hnd)
prs_mem_free(&rbuf);
prs_mem_free(&buf );
close_policy_hnd(hnd);
return valid_close;
}

View File

@ -76,9 +76,9 @@ BOOL make_systemtime(SYSTEMTIME *systime, struct tm *unixtime)
}
/*******************************************************************
reads or writes an PRINTER_HND structure.
reads or writes an POLICY_HND structure.
********************************************************************/
static BOOL smb_io_prt_hnd(char *desc, PRINTER_HND *hnd, prs_struct *ps, int depth)
static BOOL smb_io_prt_hnd(char *desc, POLICY_HND *hnd, prs_struct *ps, int depth)
{
if (hnd == NULL) return False;
@ -87,7 +87,7 @@ static BOOL smb_io_prt_hnd(char *desc, PRINTER_HND *hnd, prs_struct *ps, int dep
prs_align(ps);
prs_uint8s (False, "data", ps, depth, hnd->data, PRINTER_HND_SIZE);
prs_uint8s (False, "data", ps, depth, hnd->data, POLICY_HND_SIZE);
return True;
}
@ -505,7 +505,7 @@ BOOL spoolss_io_q_open_printer_ex(char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_
* make a structure.
********************************************************************/
BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
PRINTER_HND *handle,
POLICY_HND *handle,
char *valuename,
uint32 size)
{
@ -574,7 +574,7 @@ BOOL spoolss_io_r_getprinterdata(char *desc, SPOOL_R_GETPRINTERDATA *r_u, prs_st
/*******************************************************************
* make a structure.
********************************************************************/
BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, PRINTER_HND *hnd)
BOOL make_spoolss_q_closeprinter(SPOOL_Q_CLOSEPRINTER *q_u, POLICY_HND *hnd)
{
if (q_u == NULL) return False;
@ -2321,7 +2321,7 @@ static BOOL spoolss_io_read_buffer8(char *desc, prs_struct *ps, uint8 **buffer,
* called from spoolss_getprinter (srv_spoolss.c)
********************************************************************/
BOOL make_spoolss_q_getprinter(SPOOL_Q_GETPRINTER *q_u,
PRINTER_HND *hnd,
POLICY_HND *hnd,
uint32 level,
uint32 buf_size)
{
@ -2691,7 +2691,7 @@ BOOL spoolss_io_r_enumjobs(char *desc, SPOOL_R_ENUMJOBS *r_u, prs_struct *ps, in
/*******************************************************************
********************************************************************/
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const PRINTER_HND *hnd,
BOOL make_spoolss_q_enumjobs(SPOOL_Q_ENUMJOBS *q_u, const POLICY_HND *hnd,
uint32 firstjob,
uint32 numofjobs,
uint32 level,

View File

@ -34,33 +34,21 @@ extern int DEBUGLEVEL;
extern FILE* out_hnd;
extern struct cli_state *smb_cli;
extern struct user_credentials *usr_creds;
extern int smb_tidx;
/****************************************************************************
nt spoolss query
****************************************************************************/
BOOL msrpc_spoolss_enum_printers(struct cli_state *cli,
const char* srv_name,
BOOL msrpc_spoolss_enum_printers( const char* srv_name,
uint32 level,
uint32 *num,
void ***ctr,
PRINT_INFO_FN(fn))
{
uint16 nt_pipe_fnum;
BOOL res = True;
/* open SPOOLSS session. */
res = cli_nt_session_open(cli, PIPE_SPOOLSS, &nt_pipe_fnum);
res = res ? spoolss_enum_printers(cli, nt_pipe_fnum,
0x40, srv_name, level, num, ctr) : False;
/* close the session */
cli_nt_session_close(cli, nt_pipe_fnum);
if (res && fn != NULL)
if (spoolss_enum_printers( 0x40, srv_name, level, num, ctr) &&
fn != NULL)
{
fn(srv_name, level, *num, *ctr);
}
@ -87,10 +75,10 @@ void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[])
fstring srv_name;
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, smb_cli->desthost);
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
if (msrpc_spoolss_enum_printers(smb_cli, srv_name, level, &num, &ctr,
if (msrpc_spoolss_enum_printers(srv_name, level, &num, &ctr,
spool_print_info_ctr))
{
DEBUG(5,("cmd_spoolss_enum_printer: query succeeded\n"));
@ -108,8 +96,8 @@ nt spoolss query
****************************************************************************/
void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring srv_name;
fstring station;
char *printer_name;
PRINTER_HND hnd;
@ -123,28 +111,30 @@ void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[
printer_name = argv[1];
fstrcpy(station, "\\\\");
fstrcat(station, info->myhostname);
strupper(station);
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->myhostname);
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
if (!strnequal("\\\\", printer_name, 2))
{
fstrcat(srv_name, "\\");
fstrcat(srv_name, printer_name);
printer_name = srv_name;
}
DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n",
printer_name, srv_name, usr_creds->user_name));
printer_name, station, usr_creds->user_name));
DEBUG(5, ("cmd_spoolss_open_printer_ex: smb_cli->fd:%d\n", smb_cli->fd));
/* open SPOOLSS session. */
res = res ? cli_nt_session_open(smb_cli, PIPE_SPOOLSS, &nt_pipe_fnum) : False;
res = res ? spoolss_open_printer_ex(smb_cli, nt_pipe_fnum,
printer_name,
res = res ? spoolss_open_printer_ex( printer_name,
0, 0, 0,
srv_name, usr_creds->user_name,
station, usr_creds->user_name,
&hnd) : False;
res = res ? spoolss_closeprinter(smb_cli, nt_pipe_fnum, &hnd) : False;
/* close the session */
cli_nt_session_close(smb_cli, nt_pipe_fnum);
res = res ? spoolss_closeprinter(&hnd) : False;
if (res)
{
@ -160,16 +150,13 @@ void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[
/****************************************************************************
nt spoolss query
****************************************************************************/
BOOL msrpc_spoolss_enum_jobs(struct cli_state *cli,
const char* srv_name,
const char* user_name,
const char* printer_name,
BOOL msrpc_spoolss_enum_jobs( const char* printer_name,
const char* station, const char* user_name,
uint32 level,
uint32 *num,
void ***ctr,
JOB_INFO_FN(fn))
{
uint16 nt_pipe_fnum;
PRINTER_HND hnd;
uint32 buf_size = 0x0;
uint32 status = 0x0;
@ -178,51 +165,41 @@ BOOL msrpc_spoolss_enum_jobs(struct cli_state *cli,
BOOL res1 = True;
DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n",
printer_name, srv_name, user_name));
printer_name, station, user_name));
DEBUG(5, ("cmd_spoolss_open_printer_ex: smb_cli->fd:%d\n", smb_cli->fd));
/* open SPOOLSS session. */
res = res ? cli_nt_session_open(smb_cli, PIPE_SPOOLSS, &nt_pipe_fnum) : False;
res = res ? spoolss_open_printer_ex(smb_cli, nt_pipe_fnum,
printer_name,
res = res ? spoolss_open_printer_ex( printer_name,
0, 0, 0,
srv_name, user_name,
station, user_name,
&hnd) : False;
if (status == 0x0)
{
status = spoolss_enum_jobs(smb_cli, nt_pipe_fnum,
&hnd,
status = spoolss_enum_jobs( &hnd,
0, 1000, level, &buf_size,
num, ctr);
}
if (status == ERROR_INSUFFICIENT_BUFFER)
{
status = spoolss_enum_jobs(smb_cli, nt_pipe_fnum,
&hnd,
status = spoolss_enum_jobs( &hnd,
0, 1000, level, &buf_size,
num, ctr);
}
res1 = (status == 0x0);
res = res ? spoolss_closeprinter(smb_cli, nt_pipe_fnum, &hnd) : False;
/* close the session */
cli_nt_session_close(smb_cli, nt_pipe_fnum);
res = res ? spoolss_closeprinter(&hnd) : False;
if (res1 && fn != NULL)
{
fn(srv_name, printer_name, level, *num, *ctr);
fn(printer_name, station, level, *num, *ctr);
}
return res1;
}
static void spool_job_info_ctr(const char* srv_name, const char* printer_name,
static void spool_job_info_ctr( const char* printer_name,
const char* station,
uint32 level,
uint32 num, void *const *const ctr)
{
@ -237,6 +214,7 @@ nt spoolss query
void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[])
{
fstring srv_name;
fstring station;
char *printer_name;
void **ctr = NULL;
@ -251,15 +229,26 @@ void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[])
printer_name = argv[1];
fstrcpy(station, "\\\\");
fstrcat(station, info->myhostname);
strupper(station);
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->myhostname);
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
DEBUG(4,("spoolopen - printer: %s server: %s user: %s\n",
printer_name, srv_name, usr_creds->user_name));
if (!strnequal("\\\\", printer_name, 2))
{
fstrcat(srv_name, "\\");
fstrcat(srv_name, printer_name);
printer_name = srv_name;
}
if (msrpc_spoolss_enum_jobs(smb_cli,
srv_name, usr_creds->user_name, printer_name,
DEBUG(4,("spoolopen - printer: %s station: %s user: %s\n",
printer_name, station, usr_creds->user_name));
if (msrpc_spoolss_enum_jobs( printer_name, station,
usr_creds->user_name,
level, &num, &ctr,
spool_job_info_ctr))
{