1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

libsmb: Remove a call to SMBC_errno()

This involves converting cli_printjob_del() to NTSTATUS and thus
touches a few callers.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2023-09-22 18:42:24 -07:00 committed by Jeremy Allison
parent bb8ec33340
commit 15ff9c1819
5 changed files with 61 additions and 28 deletions

View File

@ -2282,11 +2282,12 @@ static int cmd_mput(void)
static int do_cancel(int job)
{
if (cli_printjob_del(cli, job)) {
NTSTATUS status = cli_printjob_del(cli, job);
if (NT_STATUS_IS_OK(status)) {
d_printf("Job %d cancelled\n",job);
return 0;
} else {
NTSTATUS status = cli_nt_error(cli);
d_printf("Error cancelling job %d : %s\n",
job, nt_errstr(status));
return 1;

View File

@ -152,14 +152,15 @@ NTSTATUS cli_print_queue(struct cli_state *cli,
cancel a print job
****************************************************************************/
int cli_printjob_del(struct cli_state *cli, int job)
NTSTATUS cli_printjob_del(struct cli_state *cli, int job)
{
char *rparam = NULL;
char *rdata = NULL;
char *p;
unsigned int rdrcnt,rprcnt;
int ret = -1;
uint8_t *rparam = NULL;
uint8_t *rdata = NULL;
char *p = NULL;
uint32_t rdrcnt, rprcnt;
int result_code;
char param[1024];
NTSTATUS status = NT_STATUS_OK;
memset(param,'\0',sizeof(param));
@ -173,16 +174,46 @@ int cli_printjob_del(struct cli_state *cli, int job)
SSVAL(p,0,job);
p += 2;
if (cli_api(cli,
param, PTR_DIFF(p,param), 1024, /* Param, length, maxlen */
NULL, 0, CLI_BUFFER_SIZE, /* data, length, maxlen */
&rparam, &rprcnt, /* return params, length */
&rdata, &rdrcnt)) { /* return data, length */
ret = SVAL(rparam,0);
status = cli_trans(talloc_tos(),
cli,
SMBtrans, /* trans_cmd */
"\\PIPE\\LANMAN", /* name */
0, /* fid */
0, /* function */
0, /* flags */
NULL, /* setup */
0, /* num_setup */
0, /* max_setup */
(uint8_t *)param, /* param */
PTR_DIFF(p, param), /* num_param */
1024, /* max_param */
NULL, /* data */
0, /* num_data */
CLI_BUFFER_SIZE, /* max_data */
NULL, /* recv_flags2 */
NULL, /* rsetup */
0, /* min_rsetup */
NULL, /* num_rsetup */
&rparam, /* rparam */
8, /* min_rparam */
&rprcnt, /* num_rparam */
&rdata, /* rdata */
0, /* min_rdata */
&rdrcnt); /* num_rdata */
if (!NT_STATUS_IS_OK(status)) {
cli->raw_status = status;
return status;
}
SAFE_FREE(rparam);
SAFE_FREE(rdata);
result_code = SVAL(rparam, 0);
return ret;
TALLOC_FREE(rparam);
TALLOC_FREE(rdata);
if (result_code == ERRnosuchprintjob) {
status = NT_STATUS_INVALID_PARAMETER;
cli->raw_status = NT_STATUS_INVALID_PARAMETER;
}
return status;
}

View File

@ -271,9 +271,9 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
char *password = NULL;
char *workgroup = NULL;
char *path = NULL;
int err;
uint16_t port = 0;
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
if (!context || !context->internal->initialized) {
errno = EINVAL;
@ -322,14 +322,12 @@ SMBC_unlink_print_job_ctx(SMBCCTX *context,
return -1; /* errno set by SMBC_server */
}
if ((err = cli_printjob_del(srv->cli, id)) != 0) {
if (err < 0)
errno = SMBC_errno(context, srv->cli);
else if (err == ERRnosuchprintjob)
errno = EINVAL;
status = cli_printjob_del(srv->cli, id);
if (!NT_STATUS_IS_OK(status)) {
errno = cli_status_to_errno(status);
TALLOC_FREE(frame);
return -1;
}
}
TALLOC_FREE(frame);
return 0;

View File

@ -816,7 +816,7 @@ NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
NTSTATUS cli_print_queue(struct cli_state *cli,
void (*fn)(struct print_job_info *));
int cli_printjob_del(struct cli_state *cli, int job);
NTSTATUS cli_printjob_del(struct cli_state *cli, int job);
/* The following definitions come from libsmb/cliquota.c */

View File

@ -712,7 +712,7 @@ static int rap_printq_info(struct net_context *c, int argc, const char **argv)
static int rap_printq_delete(struct net_context *c, int argc, const char **argv)
{
struct cli_state *cli;
int ret;
NTSTATUS status;
if (argc == 0 || c->display_usage)
return net_rap_printq_usage(c, argc, argv);
@ -720,9 +720,12 @@ static int rap_printq_delete(struct net_context *c, int argc, const char **argv)
if (!NT_STATUS_IS_OK(net_make_ipc_connection(c, 0, &cli)))
return -1;
ret = cli_printjob_del(cli, atoi(argv[0]));
status = cli_printjob_del(cli, atoi(argv[0]));
cli_shutdown(cli);
return ret;
if (!NT_STATUS_IS_OK(status)) {
return -1;
}
return 0;
}
int net_rap_printq(struct net_context *c, int argc, const char **argv)