up, all the errors returned are DOS errors, not NT status codes. */
#include "includes.h"
+#include "ntdomain.h"
#include "nt_printing.h"
#include "srv_spoolss_util.h"
#include "../librpc/gen_ndr/srv_spoolss.h"
#include "../librpc/gen_ndr/ndr_spoolss_c.h"
#include "rpc_client/init_spoolss.h"
-#include "librpc/gen_ndr/messaging.h"
+#include "rpc_client/cli_pipe.h"
#include "../libcli/security/security.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "registry.h"
#include "secrets.h"
#include "../librpc/gen_ndr/netlogon.h"
#include "rpc_misc.h"
+#include "printing/notify.h"
+#include "serverid.h"
+#include "../libcli/registry/util_reg.h"
+#include "smbd/smbd.h"
+#include "auth.h"
+#include "messages.h"
+#include "rpc_server/spoolss/srv_spoolss_nt.h"
+#include "util_tdb.h"
+#include "libsmb/libsmb.h"
+#include "printing/printer_list.h"
+#include "rpc_client/cli_winreg_spoolss.h"
/* macros stolen from s4 spoolss server */
#define SPOOLSS_BUFFER_UNION(fn,info,level) \
if (prn_hnd->notify.cli_chan) {
prn_hnd->notify.cli_chan->active_connections--;
+ prn_hnd->notify.cli_chan = NULL;
}
}
/* this does not need a become root since the access check has been
done on the handle already */
- result = winreg_delete_printer_key(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_delete_printer_key_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
Printer->sharename,
"");
return WERR_BADFID;
}
- result = delete_printer_hook(p->mem_ctx, p->server_info->ptok,
+ result = delete_printer_hook(p->mem_ctx, p->session_info->security_token,
Printer->sharename, p->msg_ctx);
if (!W_ERROR_IS_OK(result)) {
return result;
****************************************************************************/
static WERROR set_printer_hnd_name(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
struct printer_handle *Printer,
const char *handlename)
continue;
}
- result = winreg_get_printer(mem_ctx,
- server_info,
+ result = winreg_get_printer_internal(mem_ctx,
+ session_info,
msg_ctx,
sname,
&info2);
}
result = set_printer_hnd_name(p->mem_ctx,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
new_printer, name);
if (!W_ERROR_IS_OK(result)) {
DATA_BLOB *data)
{
TALLOC_CTX *tmp_ctx;
- struct auth_serversupplied_info *server_info = NULL;
+ struct auth_serversupplied_info *session_info = NULL;
struct spoolss_PrinterInfo2 *pinfo2;
NTSTATUS status;
WERROR result;
const char *drivername;
int snum;
int n_services = lp_numservices();
+ struct dcerpc_binding_handle *b = NULL;
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) return;
- status = make_server_info_system(tmp_ctx, &server_info);
+ status = make_session_info_system(tmp_ctx, &session_info);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("do_drv_upgrade_printer: "
- "Could not create system server_info\n"));
+ "Could not create system session_info\n"));
goto done;
}
continue;
}
- result = winreg_get_printer(tmp_ctx, server_info, msg,
+ if (b == NULL) {
+ result = winreg_printer_binding_handle(tmp_ctx,
+ session_info,
+ msg,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ break;
+ }
+ }
+
+ result = winreg_get_printer(tmp_ctx, b,
lp_const_servicename(snum),
&pinfo2);
DEBUG(6,("Updating printer [%s]\n", pinfo2->printername));
/* all we care about currently is the change_id */
- result = winreg_printer_update_changeid(tmp_ctx,
- server_info,
- msg,
+ result = winreg_printer_update_changeid(tmp_ctx, b,
pinfo2->printername);
if (!W_ERROR_IS_OK(result)) {
return WERR_INVALID_PARAM;
}
- if (r->in.level < 0 || r->in.level > 3) {
+ if (r->in.level > 3) {
return WERR_INVALID_PARAM;
}
if ((r->in.level == 1 && !r->in.userlevel.level1) ||
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !security_token_has_privilege(p->server_info->ptok, SEC_PRIV_PRINT_OPERATOR) &&
- !nt_token_check_sid(&global_sid_Builtin_Print_Operators, p->server_info->ptok) &&
+ if ((p->session_info->utok.uid != sec_initial_uid()) &&
+ !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_PRINT_OPERATOR) &&
+ !nt_token_check_sid(&global_sid_Builtin_Print_Operators, p->session_info->security_token) &&
!token_contains_name_in_list(
- uidtoname(p->server_info->utok.uid),
- p->server_info->info3->base.domain.string,
+ uidtoname(p->session_info->utok.uid),
+ p->session_info->info3->base.domain.string,
NULL,
- p->server_info->ptok,
+ p->session_info->security_token,
lp_printer_admin(snum))) {
close_printer_handle(p, r->out.handle);
ZERO_STRUCTP(r->out.handle);
return WERR_ACCESS_DENIED;
}
- if (!user_ok_token(uidtoname(p->server_info->utok.uid), NULL,
- p->server_info->ptok, snum) ||
- !print_access_check(p->server_info,
+ if (!user_ok_token(uidtoname(p->session_info->utok.uid), NULL,
+ p->session_info->security_token, snum) ||
+ !print_access_check(p->session_info,
p->msg_ctx,
snum,
r->in.access_mask)) {
DEBUG(4,("Setting printer access = %s\n", (r->in.access_mask == PRINTER_ACCESS_ADMINISTER)
? "PRINTER_ACCESS_ADMINISTER" : "PRINTER_ACCESS_USE" ));
- winreg_create_printer(p->mem_ctx,
- get_server_info_system(),
+ winreg_create_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum));
}
if (get_printer_snum(p, r->in.handle, &snum, NULL)) {
- winreg_delete_printer_key(p->mem_ctx,
- get_server_info_system(),
+ winreg_delete_printer_key_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
"");
{NULL, "", -1 }
};
+static const int drv_cversion[] = {SPOOLSS_DRIVER_VERSION_9X,
+ SPOOLSS_DRIVER_VERSION_NT35,
+ SPOOLSS_DRIVER_VERSION_NT4,
+ SPOOLSS_DRIVER_VERSION_200X,
+ -1};
+
static int get_version_id(const char *arch)
{
int i;
{
struct spoolss_DriverInfo8 *info = NULL;
- struct spoolss_DriverInfo8 *info_win2k = NULL;
int version;
WERROR status;
+ struct dcerpc_binding_handle *b;
+ TALLOC_CTX *tmp_ctx = NULL;
+ int i;
+ bool found;
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ( (p->server_info->utok.uid != sec_initial_uid())
- && !security_token_has_privilege(p->server_info->ptok, SEC_PRIV_PRINT_OPERATOR)
+ if ( (p->session_info->utok.uid != sec_initial_uid())
+ && !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_PRINT_OPERATOR)
&& !token_contains_name_in_list(
- uidtoname(p->server_info->utok.uid),
- p->server_info->info3->base.domain.string,
+ uidtoname(p->session_info->utok.uid),
+ p->session_info->info3->base.domain.string,
NULL,
- p->server_info->ptok,
+ p->session_info->security_token,
lp_printer_admin(-1)) )
{
return WERR_ACCESS_DENIED;
if ((version = get_version_id(r->in.architecture)) == -1)
return WERR_INVALID_ENVIRONMENT;
- status = winreg_get_driver(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- r->in.architecture, r->in.driver,
- version, &info);
- if (!W_ERROR_IS_OK(status)) {
- /* try for Win2k driver if "Windows NT x86" */
+ tmp_ctx = talloc_new(p->mem_ctx);
+ if (!tmp_ctx) {
+ return WERR_NOMEM;
+ }
- if ( version == 2 ) {
- version = 3;
+ status = winreg_printer_binding_handle(tmp_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(status)) {
+ goto done;
+ }
- status = winreg_get_driver(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- r->in.architecture,
- r->in.driver,
- version, &info);
- if (!W_ERROR_IS_OK(status)) {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
- goto done;
- }
+ for (found = false, i = 0; drv_cversion[i] >= 0; i++) {
+ status = winreg_get_driver(tmp_ctx, b,
+ r->in.architecture, r->in.driver,
+ drv_cversion[i], &info);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(5, ("skipping del of driver with version %d\n",
+ drv_cversion[i]));
+ continue;
}
- /* otherwise it was a failure */
- else {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
+ found = true;
+
+ if (printer_driver_in_use(tmp_ctx, get_session_info_system(),
+ p->msg_ctx, info)) {
+ status = WERR_PRINTER_DRIVER_IN_USE;
goto done;
}
+ status = winreg_del_driver(tmp_ctx, b, info, drv_cversion[i]);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0, ("failed del of driver with version %d\n",
+ drv_cversion[i]));
+ goto done;
+ }
}
+ if (found == false) {
+ DEBUG(0, ("driver %s not found for deletion\n", r->in.driver));
+ status = WERR_UNKNOWN_PRINTER_DRIVER;
+ } else {
+ status = WERR_OK;
+ }
+
+done:
+ talloc_free(tmp_ctx);
+ return status;
+}
- if (printer_driver_in_use(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- info)) {
+static WERROR spoolss_dpd_version(TALLOC_CTX *mem_ctx,
+ struct pipes_struct *p,
+ struct spoolss_DeletePrinterDriverEx *r,
+ struct dcerpc_binding_handle *b,
+ struct spoolss_DriverInfo8 *info)
+{
+ WERROR status;
+ bool delete_files;
+
+ if (printer_driver_in_use(mem_ctx, get_session_info_system(),
+ p->msg_ctx, info)) {
status = WERR_PRINTER_DRIVER_IN_USE;
goto done;
}
- if (version == 2) {
- status = winreg_get_driver(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- r->in.architecture,
- r->in.driver, 3, &info_win2k);
- if (W_ERROR_IS_OK(status)) {
- /* if we get to here, we now have 2 driver info structures to remove */
- /* remove the Win2k driver first*/
-
- status = winreg_del_driver(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- info_win2k, 3);
- talloc_free(info_win2k);
+ /*
+ * we have a couple of cases to consider.
+ * (1) Are any files in use? If so and DPD_DELETE_ALL_FILES is set,
+ * then the delete should fail if **any** files overlap with
+ * other drivers
+ * (2) If DPD_DELETE_UNUSED_FILES is set, then delete all
+ * non-overlapping files
+ * (3) If neither DPD_DELETE_ALL_FILES nor DPD_DELETE_UNUSED_FILES
+ * is set, then do not delete any files
+ * Refer to MSDN docs on DeletePrinterDriverEx() for details.
+ */
- /* this should not have failed---if it did, report to client */
- if (!W_ERROR_IS_OK(status)) {
- goto done;
- }
+ delete_files = r->in.delete_flags
+ & (DPD_DELETE_ALL_FILES | DPD_DELETE_UNUSED_FILES);
+
+ if (delete_files) {
+ bool in_use = printer_driver_files_in_use(mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ info);
+ if (in_use && (r->in.delete_flags & DPD_DELETE_ALL_FILES)) {
+ status = WERR_PRINTER_DRIVER_IN_USE;
+ goto done;
}
+ /*
+ * printer_driver_files_in_use() has trimmed overlapping files
+ * from info so they are not removed on DPD_DELETE_UNUSED_FILES
+ */
}
- status = winreg_del_driver(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- info, version);
+ status = winreg_del_driver(mem_ctx, b, info, info->version);
+ if (!W_ERROR_IS_OK(status)) {
+ goto done;
+ }
-done:
- talloc_free(info);
+ /*
+ * now delete any associated files if delete_files is
+ * true. Even if this part failes, we return succes
+ * because the driver doesn not exist any more
+ */
+ if (delete_files) {
+ delete_driver_files(get_session_info_system(), info);
+ }
+done:
return status;
}
WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct *p,
struct spoolss_DeletePrinterDriverEx *r)
{
- struct spoolss_DriverInfo8 *info = NULL;
- struct spoolss_DriverInfo8 *info_win2k = NULL;
- int version;
- bool delete_files;
+ struct spoolss_DriverInfo8 *info = NULL;
WERROR status;
+ struct dcerpc_binding_handle *b;
+ TALLOC_CTX *tmp_ctx = NULL;
+ int i;
+ bool found;
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ( (p->server_info->utok.uid != sec_initial_uid())
- && !security_token_has_privilege(p->server_info->ptok, SEC_PRIV_PRINT_OPERATOR)
+ if ( (p->session_info->utok.uid != sec_initial_uid())
+ && !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_PRINT_OPERATOR)
&& !token_contains_name_in_list(
- uidtoname(p->server_info->utok.uid),
- p->server_info->info3->base.domain.string,
+ uidtoname(p->session_info->utok.uid),
+ p->session_info->info3->base.domain.string,
NULL,
- p->server_info->ptok, lp_printer_admin(-1)) )
+ p->session_info->security_token, lp_printer_admin(-1)) )
{
return WERR_ACCESS_DENIED;
}
/* check that we have a valid driver name first */
- if ((version = get_version_id(r->in.architecture)) == -1) {
+ if (get_version_id(r->in.architecture) == -1) {
/* this is what NT returns */
return WERR_INVALID_ENVIRONMENT;
}
- if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
- version = r->in.version;
-
- status = winreg_get_driver(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
- r->in.architecture,
- r->in.driver,
- version,
- &info);
- if (!W_ERROR_IS_OK(status)) {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
-
- /*
- * if the client asked for a specific version,
- * or this is something other than Windows NT x86,
- * then we've failed
- */
-
- if ( (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
- goto done;
-
- /* try for Win2k driver if "Windows NT x86" */
-
- version = 3;
- status = winreg_get_driver(info,
- get_server_info_system(),
- p->msg_ctx,
- r->in.architecture,
- r->in.driver,
- version, &info);
- if (!W_ERROR_IS_OK(status)) {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
- goto done;
- }
- }
-
- if (printer_driver_in_use(info,
- get_server_info_system(),
- p->msg_ctx,
- info)) {
- status = WERR_PRINTER_DRIVER_IN_USE;
- goto done;
+ tmp_ctx = talloc_new(p->mem_ctx);
+ if (!tmp_ctx) {
+ return WERR_NOMEM;
}
- /*
- * we have a couple of cases to consider.
- * (1) Are any files in use? If so and DPD_DELTE_ALL_FILE is set,
- * then the delete should fail if **any** files overlap with
- * other drivers
- * (2) If DPD_DELTE_UNUSED_FILES is sert, then delete all
- * non-overlapping files
- * (3) If neither DPD_DELTE_ALL_FILE nor DPD_DELTE_ALL_FILES
- * is set, the do not delete any files
- * Refer to MSDN docs on DeletePrinterDriverEx() for details.
- */
-
- delete_files = r->in.delete_flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
-
- /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
-
- if (delete_files &&
- (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
- printer_driver_files_in_use(info,
- get_server_info_system(),
- p->msg_ctx,
- info)) {
- /* no idea of the correct error here */
- status = WERR_ACCESS_DENIED;
+ status = winreg_printer_binding_handle(tmp_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(status)) {
goto done;
}
+ for (found = false, i = 0; drv_cversion[i] >= 0; i++) {
+ if ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
+ && (drv_cversion[i] != r->in.version)) {
+ continue;
+ }
- /* also check for W32X86/3 if necessary; maybe we already have? */
-
- if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
- status = winreg_get_driver(info,
- get_server_info_system(),
- p->msg_ctx,
- r->in.architecture,
- r->in.driver, 3, &info_win2k);
- if (W_ERROR_IS_OK(status)) {
-
- if (delete_files &&
- (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
- printer_driver_files_in_use(info,
- get_server_info_system(),
- p->msg_ctx,
- info_win2k)) {
- /* no idea of the correct error here */
- talloc_free(info_win2k);
- status = WERR_ACCESS_DENIED;
- goto done;
- }
-
- /* if we get to here, we now have 2 driver info structures to remove */
- /* remove the Win2k driver first*/
-
- status = winreg_del_driver(info,
- get_server_info_system(),
- p->msg_ctx,
- info_win2k,
- 3);
-
- /* this should not have failed---if it did, report to client */
-
- if (!W_ERROR_IS_OK(status)) {
- goto done;
- }
-
- /*
- * now delete any associated files if delete_files is
- * true. Even if this part failes, we return succes
- * because the driver doesn not exist any more
- */
- if (delete_files) {
- delete_driver_files(get_server_info_system(),
- info_win2k);
- }
+ /* check if a driver with this version exists before delete */
+ status = winreg_get_driver(tmp_ctx, b,
+ r->in.architecture, r->in.driver,
+ drv_cversion[i], &info);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(5, ("skipping del of driver with version %d\n",
+ drv_cversion[i]));
+ continue;
}
- }
+ found = true;
- status = winreg_del_driver(info,
- get_server_info_system(),
- p->msg_ctx,
- info,
- version);
- if (!W_ERROR_IS_OK(status)) {
- goto done;
+ status = spoolss_dpd_version(tmp_ctx, p, r, b, info);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0, ("failed to delete driver with version %d\n",
+ drv_cversion[i]));
+ goto done;
+ }
}
-
- /*
- * now delete any associated files if delete_files is
- * true. Even if this part failes, we return succes
- * because the driver doesn not exist any more
- */
- if (delete_files) {
- delete_driver_files(get_server_info_system(), info);
+ if (found == false) {
+ DEBUG(0, ("driver %s not found for deletion\n", r->in.driver));
+ status = WERR_UNKNOWN_PRINTER_DRIVER;
+ } else {
+ status = WERR_OK;
}
done:
- talloc_free(info);
+ talloc_free(tmp_ctx);
return status;
}
DEBUG(10,("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
"client_address is %s\n", p->client_id->addr));
+ if (!lp_print_notify_backchannel(snum)) {
+ DEBUG(10, ("_spoolss_RemoteFindFirstPrinterChangeNotifyEx: "
+ "backchannel disabled\n"));
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
if (!interpret_string_addr(&client_ss, p->client_id->addr,
AI_NUMERICHOST)) {
return WERR_SERVER_UNAVAILABLE;
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
- SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, pinfo2->location);
+ const char *loc = pinfo2->location;
+ NTSTATUS status;
+
+ status = printer_list_get_printer(mem_ctx,
+ pinfo2->sharename,
+ NULL,
+ &loc,
+ NULL);
+ if (NT_STATUS_IS_OK(status)) {
+ if (loc == NULL) {
+ loc = pinfo2->location;
+ }
+ }
+
+ SETUP_SPOOLSS_NOTIFY_DATA_STRING(data, loc);
}
/*******************************************************************
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
- SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(data, queue->job);
+ SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(data, queue->sysjob);
}
/*******************************************************************
uint16_t field;
struct spoolss_Notify *current_data;
- print_queue_struct *queue=NULL;
type = option_type->type;
pinfo2->printername));
notify_info_data_table[j].fn(msg_ctx, snum, current_data,
- queue, pinfo2, mem_ctx);
+ NULL, pinfo2, mem_ctx);
info->count++;
}
continue; /* skip */
}
- /* Maybe we should use the SYSTEM server_info here... */
- result = winreg_get_printer(mem_ctx,
- get_server_info_system(),
+ /* Maybe we should use the SYSTEM session_info here... */
+ result = winreg_get_printer_internal(mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_servicename(snum),
&pinfo2);
if ( !option )
return WERR_BADFID;
- get_printer_snum(p, hnd, &snum, NULL);
+ if (!get_printer_snum(p, hnd, &snum, NULL)) {
+ return WERR_BADFID;
+ }
- /* Maybe we should use the SYSTEM server_info here... */
- result = winreg_get_printer(mem_ctx,
- get_server_info_system(),
+ /* Maybe we should use the SYSTEM session_info here... */
+ result = winreg_get_printer_internal(mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_servicename(snum), &pinfo2);
if (!W_ERROR_IS_OK(result)) {
return WERR_BADFID;
}
+ /*
+ * When sending a PRINTER_NOTIFY_FIELD_SERVER_NAME we should send the
+ * correct servername.
+ */
+ pinfo2->servername = talloc_strdup(pinfo2, Printer->servername);
+ if (pinfo2->servername == NULL) {
+ return WERR_NOMEM;
+ }
+
for (i=0; i<option->count; i++) {
option_type = option->types[i];
&queue[j], info,
pinfo2, snum,
&option_type,
- queue[j].job,
+ queue[j].sysjob,
mem_ctx);
}
* We are now using the change value, and
* I should check for PRINTER_NOTIFY_OPTIONS_REFRESH but as
* I don't have a global notification system, I'm sending back all the
- * informations even when _NOTHING_ has changed.
+ * information even when _NOTHING_ has changed.
*/
/* We need to keep track of the change value to send back in
********************************************************************/
static WERROR construct_printer_info0(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
struct spoolss_PrinterInfo2 *info2,
const char *servername,
r->high_part_total_bytes = 0x0;
/* ChangeID in milliseconds*/
- winreg_printer_get_changeid(mem_ctx, server_info, msg_ctx,
+ winreg_printer_get_changeid_internal(mem_ctx, session_info, msg_ctx,
info2->sharename, &r->change_id);
r->last_error = WERR_OK;
}
W_ERROR_HAVE_NO_MEMORY(r->comment);
- r->location = talloc_strdup(mem_ctx, info2->location);
+ r->location = talloc_strdup(mem_ctx, info2->location);
+ if (info2->location[0] == '\0') {
+ const char *loc = NULL;
+ NTSTATUS nt_status;
+
+ nt_status = printer_list_get_printer(mem_ctx,
+ info2->sharename,
+ NULL,
+ &loc,
+ NULL);
+ if (NT_STATUS_IS_OK(nt_status)) {
+ if (loc != NULL) {
+ r->location = talloc_strdup(mem_ctx, loc);
+ }
+ }
+ }
W_ERROR_HAVE_NO_MEMORY(r->location);
+
r->sepfile = talloc_strdup(mem_ctx, info2->sepfile);
W_ERROR_HAVE_NO_MEMORY(r->sepfile);
r->printprocessor = talloc_strdup(mem_ctx, info2->printprocessor);
struct spoolss_PrinterInfo7 *r,
int snum)
{
- struct auth_serversupplied_info *server_info;
+ struct auth_serversupplied_info *session_info;
struct GUID guid;
NTSTATUS status;
- status = make_server_info_system(mem_ctx, &server_info);
+ status = make_session_info_system(mem_ctx, &session_info);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("construct_printer_info7: "
- "Could not create system server_info\n"));
+ "Could not create system session_info\n"));
return WERR_NOMEM;
}
- if (is_printer_published(mem_ctx, server_info, msg_ctx,
+ if (is_printer_published(mem_ctx, session_info, msg_ctx,
servername,
lp_servicename(snum), &guid, NULL)) {
r->guid = talloc_strdup_upper(mem_ctx, GUID_string2(mem_ctx, &guid));
}
W_ERROR_HAVE_NO_MEMORY(r->guid);
- TALLOC_FREE(server_info);
+ TALLOC_FREE(session_info);
return WERR_OK;
}
********************************************************************/
static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
uint32_t level,
union spoolss_PrinterInfo *info = NULL;
uint32_t count = 0;
WERROR result = WERR_OK;
+ struct dcerpc_binding_handle *b = NULL;
*count_p = 0;
*info_p = NULL;
DEBUG(4,("Found a printer in smb.conf: %s[%x]\n",
printer, snum));
- result = winreg_create_printer(mem_ctx,
- server_info,
- msg_ctx,
+ if (b == NULL) {
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
+ }
+
+ result = winreg_create_printer(mem_ctx, b,
printer);
if (!W_ERROR_IS_OK(result)) {
goto out;
goto out;
}
- result = winreg_get_printer(mem_ctx, server_info, msg_ctx,
+ result = winreg_get_printer(mem_ctx, b,
printer, &info2);
if (!W_ERROR_IS_OK(result)) {
goto out;
switch (level) {
case 0:
- result = construct_printer_info0(info, server_info,
+ result = construct_printer_info0(info, session_info,
msg_ctx, info2,
servername,
&info[count].info0, snum);
********************************************************************/
static WERROR enumprinters_level0(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
uint32_t flags,
const char *servername,
{
DEBUG(4,("enum_all_printers_info_0\n"));
- return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_level(mem_ctx, session_info, msg_ctx,
servername, 0, flags, info, count);
}
********************************************************************/
static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
uint32_t flags,
{
DEBUG(4,("enum_all_printers_info_1\n"));
- return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_level(mem_ctx, session_info, msg_ctx,
servername, 1, flags, info, count);
}
*********************************************************************/
static WERROR enum_all_printers_info_1_local(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
union spoolss_PrinterInfo **info,
{
DEBUG(4,("enum_all_printers_info_1_local\n"));
- return enum_all_printers_info_1(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_1(mem_ctx, session_info, msg_ctx,
servername, PRINTER_ENUM_ICON8, info, count);
}
*********************************************************************/
static WERROR enum_all_printers_info_1_name(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
union spoolss_PrinterInfo **info,
return WERR_INVALID_NAME;
}
- return enum_all_printers_info_1(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_1(mem_ctx, session_info, msg_ctx,
servername, PRINTER_ENUM_ICON8, info, count);
}
*********************************************************************/
static WERROR enum_all_printers_info_1_network(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
union spoolss_PrinterInfo **info,
return WERR_CAN_NOT_COMPLETE;
}
- return enum_all_printers_info_1(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_1(mem_ctx, session_info, msg_ctx,
servername, PRINTER_ENUM_NAME, info, count);
}
********************************************************************/
static WERROR enum_all_printers_info_2(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
union spoolss_PrinterInfo **info,
{
DEBUG(4,("enum_all_printers_info_2\n"));
- return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_level(mem_ctx, session_info, msg_ctx,
servername, 2, 0, info, count);
}
********************************************************************/
static WERROR enumprinters_level1(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
uint32_t flags,
const char *servername,
/* Not all the flags are equals */
if (flags & PRINTER_ENUM_LOCAL) {
- return enum_all_printers_info_1_local(mem_ctx, server_info,
+ return enum_all_printers_info_1_local(mem_ctx, session_info,
msg_ctx, servername, info, count);
}
if (flags & PRINTER_ENUM_NAME) {
- return enum_all_printers_info_1_name(mem_ctx, server_info,
+ return enum_all_printers_info_1_name(mem_ctx, session_info,
msg_ctx, servername, info,
count);
}
if (flags & PRINTER_ENUM_NETWORK) {
- return enum_all_printers_info_1_network(mem_ctx, server_info,
+ return enum_all_printers_info_1_network(mem_ctx, session_info,
msg_ctx, servername, info,
count);
}
********************************************************************/
static WERROR enumprinters_level2(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
uint32_t flags,
const char *servername,
{
if (flags & PRINTER_ENUM_LOCAL) {
- return enum_all_printers_info_2(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_2(mem_ctx, session_info, msg_ctx,
servername,
info, count);
}
return WERR_INVALID_NAME;
}
- return enum_all_printers_info_2(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_2(mem_ctx, session_info, msg_ctx,
servername,
info, count);
}
********************************************************************/
static WERROR enumprinters_level4(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
uint32_t flags,
const char *servername,
{
DEBUG(4,("enum_all_printers_info_4\n"));
- return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_level(mem_ctx, session_info, msg_ctx,
servername, 4, flags, info, count);
}
********************************************************************/
static WERROR enumprinters_level5(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
uint32_t flags,
const char *servername,
{
DEBUG(4,("enum_all_printers_info_5\n"));
- return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
+ return enum_all_printers_info_level(mem_ctx, session_info, msg_ctx,
servername, 5, flags, info, count);
}
WERROR _spoolss_EnumPrinters(struct pipes_struct *p,
struct spoolss_EnumPrinters *r)
{
- const struct auth_serversupplied_info *server_info = get_server_info_system();
+ const struct auth_serversupplied_info *session_info = get_session_info_system();
WERROR result;
/* that's an [in out] buffer */
switch (r->in.level) {
case 0:
- result = enumprinters_level0(p->mem_ctx, server_info,
+ result = enumprinters_level0(p->mem_ctx, session_info,
p->msg_ctx, r->in.flags,
r->in.server,
r->out.info, r->out.count);
break;
case 1:
- result = enumprinters_level1(p->mem_ctx, server_info,
+ result = enumprinters_level1(p->mem_ctx, session_info,
p->msg_ctx, r->in.flags,
r->in.server,
r->out.info, r->out.count);
break;
case 2:
- result = enumprinters_level2(p->mem_ctx, server_info,
+ result = enumprinters_level2(p->mem_ctx, session_info,
p->msg_ctx, r->in.flags,
r->in.server,
r->out.info, r->out.count);
break;
case 4:
- result = enumprinters_level4(p->mem_ctx, server_info,
+ result = enumprinters_level4(p->mem_ctx, session_info,
p->msg_ctx, r->in.flags,
r->in.server,
r->out.info, r->out.count);
break;
case 5:
- result = enumprinters_level5(p->mem_ctx, server_info,
+ result = enumprinters_level5(p->mem_ctx, session_info,
p->msg_ctx, r->in.flags,
r->in.server,
r->out.info, r->out.count);
return WERR_BADFID;
}
- result = winreg_get_printer(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_get_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
&info2);
switch (r->in.level) {
case 0:
result = construct_printer_info0(p->mem_ctx,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
info2,
Printer->servername,
********************************************************************/
static WERROR construct_printer_driver_info_level(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
uint32_t level,
union spoolss_DriverInfo *r,
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
struct spoolss_DriverInfo8 *driver;
WERROR result;
+ struct dcerpc_binding_handle *b;
if (level == 101) {
return WERR_UNKNOWN_LEVEL;
}
- result = winreg_get_printer(mem_ctx,
- server_info,
- msg_ctx,
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ result = winreg_get_printer(mem_ctx, b,
lp_const_servicename(snum),
&pinfo2);
return WERR_INVALID_PRINTER_NAME;
}
- result = winreg_get_driver(mem_ctx, server_info, msg_ctx,
+ result = winreg_get_driver(mem_ctx, b,
architecture,
pinfo2->drivername, version, &driver);
/* Yes - try again with a WinNT driver. */
version = 2;
- result = winreg_get_driver(mem_ctx, server_info, msg_ctx,
+ result = winreg_get_driver(mem_ctx, b,
architecture,
pinfo2->drivername,
version, &driver);
}
result = construct_printer_driver_info_level(p->mem_ctx,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
r->in.level, r->out.info,
snum, printer->servername,
return WERR_BADFID;
}
- werr = print_job_start(p->server_info,
+ werr = print_job_start(p->session_info,
p->msg_ctx,
p->client_id->name,
snum,
static WERROR control_printer(struct policy_handle *handle, uint32_t command,
struct pipes_struct *p)
{
- const struct auth_serversupplied_info *server_info = p->server_info;
+ const struct auth_serversupplied_info *session_info = p->session_info;
int snum;
WERROR errcode = WERR_BADFUNC;
struct printer_handle *Printer = find_printer_index_by_hnd(p, handle);
switch (command) {
case SPOOLSS_PRINTER_CONTROL_PAUSE:
- errcode = print_queue_pause(server_info, p->msg_ctx, snum);
+ errcode = print_queue_pause(session_info, p->msg_ctx, snum);
break;
case SPOOLSS_PRINTER_CONTROL_RESUME:
case SPOOLSS_PRINTER_CONTROL_UNPAUSE:
- errcode = print_queue_resume(server_info, p->msg_ctx, snum);
+ errcode = print_queue_resume(session_info, p->msg_ctx, snum);
break;
case SPOOLSS_PRINTER_CONTROL_PURGE:
- errcode = print_queue_purge(server_info, p->msg_ctx, snum);
+ errcode = print_queue_purge(session_info, p->msg_ctx, snum);
break;
default:
return WERR_UNKNOWN_LEVEL;
return WERR_SPL_NO_STARTDOC;
}
- errcode = print_job_delete(p->server_info,
+ errcode = print_job_delete(p->session_info,
p->msg_ctx,
snum,
Printer->jobid);
const char *printer;
WERROR result;
int snum;
-
struct printer_handle *Printer = find_printer_index_by_hnd(p, handle);
+ struct dcerpc_binding_handle *b;
if (!Printer || !get_printer_snum(p, handle, &snum, NULL)) {
DEBUG(2,("update_printer_sec: Invalid handle (%s:%u:%u)\n",
goto done;
}
+ result = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
/* NT seems to like setting the security descriptor even though
nothing may have actually changed. */
- result = winreg_get_printer_secdesc(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_get_printer_secdesc(p->mem_ctx, b,
printer,
&old_secdesc);
if (!W_ERROR_IS_OK(result)) {
- DEBUG(2,("update_printer_sec: winreg_get_printer_secdesc() failed\n"));
+ DEBUG(2,("update_printer_sec: winreg_get_printer_secdesc_internal() failed\n"));
result = WERR_BADFID;
goto done;
}
goto done;
}
- result = winreg_set_printer_secdesc(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_set_printer_secdesc(p->mem_ctx, b,
printer,
new_secdesc);
}
static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
int snum,
struct spoolss_SetPrinterInfo2 *printer,
const char *spooling;
DATA_BLOB buffer;
WERROR result = WERR_OK;
+ struct dcerpc_binding_handle *b;
+
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
if (force_update || !strequal(printer->drivername, old_printer->drivername)) {
push_reg_sz(mem_ctx, &buffer, printer->drivername);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_DRIVERNAME,
if (force_update || !strequal(printer->comment, old_printer->comment)) {
push_reg_sz(mem_ctx, &buffer, printer->comment);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_DESCRIPTION,
if (force_update || !strequal(printer->sharename, old_printer->sharename)) {
push_reg_sz(mem_ctx, &buffer, printer->sharename);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSHARENAME,
}
push_reg_sz(mem_ctx, &buffer, p);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTERNAME,
if (force_update || !strequal(printer->portname, old_printer->portname)) {
push_reg_sz(mem_ctx, &buffer, printer->portname);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PORTNAME,
if (force_update || !strequal(printer->location, old_printer->location)) {
push_reg_sz(mem_ctx, &buffer, printer->location);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_LOCATION,
if (force_update || !strequal(printer->sepfile, old_printer->sepfile)) {
push_reg_sz(mem_ctx, &buffer, printer->sepfile);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSEPARATORFILE,
if (force_update || printer->starttime != old_printer->starttime) {
buffer = data_blob_talloc(mem_ctx, NULL, 4);
SIVAL(buffer.data, 0, printer->starttime);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSTARTTIME,
if (force_update || printer->untiltime != old_printer->untiltime) {
buffer = data_blob_talloc(mem_ctx, NULL, 4);
SIVAL(buffer.data, 0, printer->untiltime);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTENDTIME,
if (force_update || printer->priority != old_printer->priority) {
buffer = data_blob_talloc(mem_ctx, NULL, 4);
SIVAL(buffer.data, 0, printer->priority);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRIORITY,
buffer = data_blob_talloc(mem_ctx, NULL, 4);
SIVAL(buffer.data, 0, (printer->attributes &
PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS));
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTKEEPPRINTEDJOBS,
spooling = "unknown";
}
push_reg_sz(mem_ctx, &buffer, spooling);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSPOOLING,
}
push_reg_sz(mem_ctx, &buffer, global_myname());
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_SHORTSERVERNAME,
}
push_reg_sz(mem_ctx, &buffer, longname);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_SERVERNAME,
uncname = talloc_asprintf(mem_ctx, "\\\\%s\\%s",
global_myname(), printer->sharename);
push_reg_sz(mem_ctx, &buffer, uncname);
- winreg_set_printer_dataex(mem_ctx,
- server_info,
- msg_ctx,
+ winreg_set_printer_dataex(mem_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_UNCNAME,
int snum;
WERROR result = WERR_OK;
TALLOC_CTX *tmp_ctx;
+ struct dcerpc_binding_handle *b;
DEBUG(8,("update_printer\n"));
goto done;
}
- result = winreg_get_printer(tmp_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_printer_binding_handle(tmp_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
+
+ result = winreg_get_printer(tmp_ctx, b,
lp_const_servicename(snum),
&old_printer);
if (!W_ERROR_IS_OK(result)) {
!strequal(printer->location, old_printer->location)) )
{
/* add_printer_hook() will call reload_services() */
- if (!add_printer_hook(tmp_ctx, p->server_info->ptok,
+ if (!add_printer_hook(tmp_ctx, p->session_info->security_token,
printer, p->client_id->addr,
p->msg_ctx)) {
result = WERR_ACCESS_DENIED;
}
update_dsspooler(tmp_ctx,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
snum,
printer,
if (devmode == NULL) {
printer_mask &= ~SPOOLSS_PRINTER_INFO_DEVMODE;
}
- result = winreg_update_printer(tmp_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_update_printer(tmp_ctx, b,
printer->sharename,
printer_mask,
printer,
if (!get_printer_snum(p, handle, &snum, NULL))
return WERR_BADFID;
- result = winreg_get_printer(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_get_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_servicename(snum),
&pinfo2);
}
nt_printer_publish(pinfo2,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
pinfo2,
info7->action);
return WERR_ACCESS_DENIED;
}
- return winreg_update_printer(p->mem_ctx,
- get_server_info_system(),
+ return winreg_update_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
info2_mask,
t = gmtime(&queue->time);
- r->job_id = queue->job;
+ r->job_id = queue->sysjob;
r->printer_name = talloc_strdup(mem_ctx, lp_servicename(snum));
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
t = gmtime(&queue->time);
- r->job_id = queue->job;
+ r->job_id = queue->sysjob;
r->printer_name = talloc_strdup(mem_ctx, lp_servicename(snum));
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
int position, int snum,
struct spoolss_PrinterInfo2 *pinfo2)
{
- r->job_id = queue->job;
+ r->job_id = queue->sysjob;
r->next_job_id = 0;
if (next_queue) {
- r->next_job_id = next_queue->job;
+ r->next_job_id = next_queue->sysjob;
}
r->reserved = 0;
return WERR_BADFID;
}
- result = winreg_get_printer(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_get_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
&pinfo2);
WERROR _spoolss_SetJob(struct pipes_struct *p,
struct spoolss_SetJob *r)
{
- const struct auth_serversupplied_info *server_info = p->server_info;
+ const struct auth_serversupplied_info *session_info = p->session_info;
int snum;
WERROR errcode = WERR_BADFUNC;
switch (r->in.command) {
case SPOOLSS_JOB_CONTROL_CANCEL:
case SPOOLSS_JOB_CONTROL_DELETE:
- errcode = print_job_delete(server_info, p->msg_ctx,
+ errcode = print_job_delete(session_info, p->msg_ctx,
snum, r->in.job_id);
if (W_ERROR_EQUAL(errcode, WERR_PRINTER_HAS_JOBS_QUEUED)) {
errcode = WERR_OK;
}
break;
case SPOOLSS_JOB_CONTROL_PAUSE:
- if (print_job_pause(server_info, p->msg_ctx,
- snum, r->in.job_id, &errcode)) {
- errcode = WERR_OK;
- }
+ errcode = print_job_pause(session_info, p->msg_ctx,
+ snum, r->in.job_id);
break;
case SPOOLSS_JOB_CONTROL_RESTART:
case SPOOLSS_JOB_CONTROL_RESUME:
- if (print_job_resume(server_info, p->msg_ctx,
- snum, r->in.job_id, &errcode)) {
- errcode = WERR_OK;
- }
+ errcode = print_job_resume(session_info, p->msg_ctx,
+ snum, r->in.job_id);
break;
case 0:
errcode = WERR_OK;
****************************************************************************/
static WERROR enumprinterdrivers_level_by_architecture(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
const char *architecture,
WERROR result = WERR_OK;
uint32_t num_drivers;
const char **drivers;
+ struct dcerpc_binding_handle *b;
*count_p = 0;
*info_p = NULL;
+ result = winreg_printer_binding_handle(mem_ctx,
+ session_info,
+ msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ goto out;
+ }
+
for (version=0; version<DRIVER_MAX_VERSION; version++) {
- result = winreg_get_driver_list(mem_ctx, server_info, msg_ctx,
+ result = winreg_get_driver_list(mem_ctx, b,
architecture, version,
&num_drivers, &drivers);
if (!W_ERROR_IS_OK(result)) {
for (i = 0; i < num_drivers; i++) {
DEBUG(5, ("\tdriver: [%s]\n", drivers[i]));
- result = winreg_get_driver(mem_ctx, server_info,
- msg_ctx,
+ result = winreg_get_driver(mem_ctx, b,
architecture, drivers[i],
version, &driver);
if (!W_ERROR_IS_OK(result)) {
****************************************************************************/
static WERROR enumprinterdrivers_level(TALLOC_CTX *mem_ctx,
- const struct auth_serversupplied_info *server_info,
+ const struct auth_serversupplied_info *session_info,
struct messaging_context *msg_ctx,
const char *servername,
const char *architecture,
uint32_t count = 0;
result = enumprinterdrivers_level_by_architecture(mem_ctx,
- server_info,
+ session_info,
msg_ctx,
servername,
archi_table[a].long_archi,
}
return enumprinterdrivers_level_by_architecture(mem_ctx,
- server_info,
+ session_info,
msg_ctx,
servername,
architecture,
}
result = enumprinterdrivers_level(p->mem_ctx,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
cservername,
r->in.environment,
switch (r->in.level) {
case 1:
- result = winreg_printer_enumforms1(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_printer_enumforms1_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
r->out.count,
r->out.info);
switch (r->in.level) {
case 1:
- result = winreg_printer_getform1(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_printer_getform1_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
r->in.form_name,
&r->out.info->info1);
trying to add a printer like this --jerry */
if (*lp_addprinter_cmd() ) {
- if ( !add_printer_hook(p->mem_ctx, p->server_info->ptok,
+ if ( !add_printer_hook(p->mem_ctx, p->session_info->security_token,
info2, p->client_id->addr,
p->msg_ctx) ) {
return WERR_ACCESS_DENIED;
}
} else {
- DEBUG(0,("spoolss_addprinterex_level_2: add printer for printer %s called and no"
- "smb.conf parameter \"addprinter command\" is defined. This"
+ DEBUG(0,("spoolss_addprinterex_level_2: add printer for printer %s called and no "
+ "smb.conf parameter \"addprinter command\" is defined. This "
"parameter must exist for this call to succeed\n",
info2->sharename ));
}
}
/* you must be a printer admin to add a new printer */
- if (!print_access_check(p->server_info,
+ if (!print_access_check(p->session_info,
p->msg_ctx,
snum,
PRINTER_ACCESS_ADMINISTER)) {
}
update_dsspooler(p->mem_ctx,
- get_server_info_system(),
+ get_session_info_system(),
p->msg_ctx,
0,
info2,
NULL);
- err = winreg_update_printer(p->mem_ctx,
- get_server_info_system(),
+ err = winreg_update_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
info2->sharename,
info2_mask,
}
DEBUG(5,("Cleaning driver's information\n"));
- err = clean_up_driver_struct(p->mem_ctx, p, r->in.info_ctr);
+ err = clean_up_driver_struct(p->mem_ctx, p->session_info, r->in.info_ctr);
if (!W_ERROR_IS_OK(err))
goto done;
DEBUG(5,("Moving driver to final destination\n"));
- if( !W_ERROR_IS_OK(err = move_driver_to_download_area(p, r->in.info_ctr,
- &err)) ) {
+ err = move_driver_to_download_area(p->session_info, r->in.info_ctr);
+ if (!W_ERROR_IS_OK(err)) {
goto done;
}
- err = winreg_add_driver(p->mem_ctx,
- get_server_info_system(),
+ err = winreg_add_driver_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
r->in.info_ctr,
&driver_name,
struct spoolss_AddFormInfo1 *form = r->in.info.info1;
int snum = -1;
WERROR status = WERR_OK;
-
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
+ struct dcerpc_binding_handle *b;
DEBUG(5,("_spoolss_AddForm\n"));
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !security_token_has_privilege(p->server_info->ptok, SEC_PRIV_PRINT_OPERATOR) &&
- !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
- p->server_info->info3->base.domain.string,
+ if ((p->session_info->utok.uid != sec_initial_uid()) &&
+ !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_PRINT_OPERATOR) &&
+ !token_contains_name_in_list(uidtoname(p->session_info->utok.uid),
+ p->session_info->info3->base.domain.string,
NULL,
- p->server_info->ptok,
+ p->session_info->security_token,
lp_printer_admin(snum))) {
DEBUG(2,("_spoolss_Addform: denied by insufficient permissions.\n"));
return WERR_ACCESS_DENIED;
return WERR_INVALID_PARAM;
}
- status = winreg_printer_addform1(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(status)) {
+ return status;
+ }
+
+ status = winreg_printer_addform1(p->mem_ctx, b,
form);
if (!W_ERROR_IS_OK(status)) {
return status;
return WERR_BADFID;
}
- status = winreg_printer_update_changeid(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_update_changeid(p->mem_ctx, b,
lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status)) {
return status;
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
int snum = -1;
WERROR status = WERR_OK;
+ struct dcerpc_binding_handle *b;
DEBUG(5,("_spoolss_DeleteForm\n"));
return WERR_BADFID;
}
- if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !security_token_has_privilege(p->server_info->ptok, SEC_PRIV_PRINT_OPERATOR) &&
- !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
- p->server_info->info3->base.domain.string,
+ if ((p->session_info->utok.uid != sec_initial_uid()) &&
+ !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_PRINT_OPERATOR) &&
+ !token_contains_name_in_list(uidtoname(p->session_info->utok.uid),
+ p->session_info->info3->base.domain.string,
NULL,
- p->server_info->ptok,
+ p->session_info->security_token,
lp_printer_admin(snum))) {
DEBUG(2,("_spoolss_DeleteForm: denied by insufficient permissions.\n"));
return WERR_ACCESS_DENIED;
}
- status = winreg_printer_deleteform1(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(status)) {
+ return status;
+ }
+
+ status = winreg_printer_deleteform1(p->mem_ctx, b,
form_name);
if (!W_ERROR_IS_OK(status)) {
return status;
return WERR_BADFID;
}
- status = winreg_printer_update_changeid(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_update_changeid(p->mem_ctx, b,
lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status)) {
return status;
const char *form_name = r->in.form_name;
int snum = -1;
WERROR status = WERR_OK;
+ struct dcerpc_binding_handle *b;
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
- if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !security_token_has_privilege(p->server_info->ptok, SEC_PRIV_PRINT_OPERATOR) &&
- !token_contains_name_in_list(uidtoname(p->server_info->utok.uid),
- p->server_info->info3->base.domain.string,
+ if ((p->session_info->utok.uid != sec_initial_uid()) &&
+ !security_token_has_privilege(p->session_info->security_token, SEC_PRIV_PRINT_OPERATOR) &&
+ !token_contains_name_in_list(uidtoname(p->session_info->utok.uid),
+ p->session_info->info3->base.domain.string,
NULL,
- p->server_info->ptok,
+ p->session_info->security_token,
lp_printer_admin(snum))) {
DEBUG(2,("_spoolss_Setform: denied by insufficient permissions.\n"));
return WERR_ACCESS_DENIED;
}
- status = winreg_printer_setform1(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(status)) {
+ return status;
+ }
+
+ status = winreg_printer_setform1(p->mem_ctx, b,
form_name,
form);
if (!W_ERROR_IS_OK(status)) {
return WERR_BADFID;
}
- status = winreg_printer_update_changeid(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_update_changeid(p->mem_ctx, b,
lp_const_servicename(snum));
if (!W_ERROR_IS_OK(status)) {
return status;
bool found = false;
for (i=0; i<count; i++) {
- if (queue[i].job == (int)jobid) {
+ if (queue[i].sysjob == (int)jobid) {
found = true;
break;
}
WERROR result;
for (i=0; i<count; i++) {
- if (queue[i].job == (int)jobid) {
+ if (queue[i].sysjob == (int)jobid) {
found = true;
break;
}
* a failure condition
*/
- devmode = print_job_devmode(lp_const_servicename(snum), jobid);
+ devmode = print_job_devmode(mem_ctx, lp_const_servicename(snum), jobid);
if (!devmode) {
result = spoolss_create_default_devmode(mem_ctx,
pinfo2->printername,
return WERR_BADFID;
}
- result = winreg_get_printer(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_get_printer_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
&pinfo2);
int snum = 0;
WERROR result = WERR_OK;
DATA_BLOB blob;
- enum winreg_Type val_type;
- uint8_t *val_data;
- uint32_t val_size;
-
+ enum winreg_Type val_type = REG_NONE;
+ uint8_t *val_data = NULL;
+ uint32_t val_size = 0;
+ struct dcerpc_binding_handle *b;
DEBUG(4,("_spoolss_GetPrinterDataEx\n"));
return WERR_INVALID_PARAM;
}
+ result = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
/* XP sends this and wants the ChangeID value from PRINTER_INFO_0 */
if (strequal(r->in.key_name, SPOOL_PRINTERDATA_KEY) &&
strequal(r->in.value_name, "ChangeId")) {
if (r->in.offered >= *r->out.needed) {
uint32_t changeid = 0;
- result = winreg_printer_get_changeid(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_printer_get_changeid(p->mem_ctx, b,
printer,
&changeid);
if (!W_ERROR_IS_OK(result)) {
goto done;
}
- result = winreg_get_printer_dataex(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_get_printer_dataex(p->mem_ctx, b,
printer,
r->in.key_name,
r->in.value_name,
WERROR result = WERR_OK;
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
char *oid_string;
+ struct dcerpc_binding_handle *b;
DEBUG(4,("_spoolss_SetPrinterDataEx\n"));
return WERR_ACCESS_DENIED;
}
- result = winreg_get_printer(Printer,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ result = winreg_get_printer(Printer, b,
lp_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
/* save the registry data */
- result = winreg_set_printer_dataex(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_set_printer_dataex(p->mem_ctx, b,
pinfo2->sharename,
r->in.key_name,
r->in.value_name,
* previous set_printer_dataex() call. I have no idea if
* this is right. --jerry
*/
- winreg_set_printer_dataex(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ winreg_set_printer_dataex(p->mem_ctx, b,
pinfo2->sharename,
str,
r->in.value_name,
strlen(oid_string) + 1);
}
- result = winreg_printer_update_changeid(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ result = winreg_printer_update_changeid(p->mem_ctx, b,
lp_const_servicename(snum));
}
}
printer = lp_const_servicename(snum);
- status = winreg_delete_printer_dataex(p->mem_ctx,
- get_server_info_system(),
+ status = winreg_delete_printer_dataex_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
printer,
r->in.key_name,
r->in.value_name);
if (W_ERROR_IS_OK(status)) {
- status = winreg_printer_update_changeid(p->mem_ctx,
- get_server_info_system(),
+ status = winreg_printer_update_changeid_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
printer);
}
return WERR_BADFID;
}
- result = winreg_enum_printer_key(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_enum_printer_key_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
r->in.key_name,
int snum=0;
WERROR status;
const char *printer;
+ struct dcerpc_binding_handle *b;
DEBUG(5,("_spoolss_DeletePrinterKey\n"));
printer = lp_const_servicename(snum);
+ status = winreg_printer_binding_handle(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ &b);
+ if (!W_ERROR_IS_OK(status)) {
+ return status;
+ }
+
/* delete the key and all subkeys */
- status = winreg_delete_printer_key(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_delete_printer_key(p->mem_ctx, b,
printer,
r->in.key_name);
if (W_ERROR_IS_OK(status)) {
- status = winreg_printer_update_changeid(p->mem_ctx,
- get_server_info_system(),
- p->msg_ctx,
+ status = winreg_printer_update_changeid(p->mem_ctx, b,
printer);
}
}
/* now look for a match on the key name */
- result = winreg_enum_printer_dataex(p->mem_ctx,
- get_server_info_system(),
+ result = winreg_enum_printer_dataex_internal(p->mem_ctx,
+ get_session_info_system(),
p->msg_ctx,
lp_const_servicename(snum),
r->in.key_name,
switch ( Printer->printer_type ) {
case SPLHND_PORTMON_TCP:
werror = process_xcvtcp_command(p->mem_ctx,
- p->server_info->ptok,
+ p->session_info->security_token,
r->in.function_name,
&r->in.in_data, &out_data,
r->out.needed);
break;
case SPLHND_PORTMON_LOCAL:
werror = process_xcvlocal_command(p->mem_ctx,
- p->server_info->ptok,
+ p->session_info->security_token,
r->in.function_name,
&r->in.in_data, &out_data,
r->out.needed);