bool page_started;
uint32 jobid; /* jobid in printing backend */
int printer_type;
- fstring servername;
+ const char *servername;
fstring sharename;
uint32 type;
uint32 access_granted;
struct xcv_api_table {
const char *name;
- WERROR(*fn) (TALLOC_CTX *mem_ctx, NT_USER_TOKEN *token, DATA_BLOB *in, DATA_BLOB *out, uint32_t *needed);
+ WERROR(*fn) (TALLOC_CTX *mem_ctx, struct security_token *token, DATA_BLOB *in, DATA_BLOB *out, uint32_t *needed);
};
static void prune_printername_cache(void);
Delete a printer given a handle.
****************************************************************************/
-static WERROR delete_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
+static WERROR delete_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
const char *sharename,
struct messaging_context *msg_ctx)
{
char *cmd = lp_deleteprinter_cmd();
char *command = NULL;
int ret;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
bool is_print_op = false;
/* can't fail if we don't try */
return WERR_NOMEM;
}
if ( token )
- is_print_op = user_has_privileges( token, &se_printop );
+ is_print_op = security_token_has_privilege(token, SEC_PRIV_PRINT_OPERATOR);
DEBUG(10,("Running [%s]\n", command));
reload_services(msg_ctx, -1, false);
unbecome_root();
- if ( lp_servicenumber( sharename ) > 0 )
+ if ( lp_servicenumber( sharename ) >= 0 )
return WERR_ACCESS_DENIED;
return WERR_OK;
bool found = false;
struct spoolss_PrinterInfo2 *info2 = NULL;
WERROR result;
+ char *p;
/*
* Hopefully nobody names his printers like this. Maybe \ or ,
if (!is_myname_or_ipaddr(servername)) {
return false;
}
-
- fstrcpy(Printer->servername, servername);
+ Printer->servername = talloc_asprintf(Printer, "\\\\%s", servername);
+ if (Printer->servername == NULL) {
+ return false;
+ }
}
if (Printer->printer_type == SPLHND_SERVER) {
DEBUGADD(5, ("searching for [%s]\n", aprinter));
+ if ((p = strchr(aprinter, ',')) != NULL) {
+ if (*p == ' ')
+ p++;
+ if (strnequal(p+1, "DrvConvert", strlen("DrvConvert")) ||
+ strnequal(p+1, " DrvConvert", strlen(" DrvConvert"))) {
+ *p = '\0';
+ } else if (strnequal(p+1, "LocalOnly", strlen("LocalOnly")) ||
+ strnequal(p+1, " LocalOnly", strlen(" LocalOnly"))) {
+ *p = '\0';
+ }
+ }
+
/* check for the Port Monitor Interface */
if ( strequal( aprinter, SPL_XCV_MONITOR_TCPMON ) ) {
Printer->printer_type = SPLHND_PORTMON_TCP;
result = winreg_get_printer(mem_ctx,
server_info,
msg_ctx,
- servername,
sname,
&info2);
if ( !W_ERROR_IS_OK(result) ) {
return true;
}
+void srv_spoolss_cleanup(void)
+{
+ struct printer_session_counter *session_counter;
+
+ for (session_counter = counter_list;
+ session_counter != NULL;
+ session_counter = counter_list) {
+ DLIST_REMOVE(counter_list, session_counter);
+ TALLOC_FREE(session_counter);
+ }
+}
+
/**********************************************************************
callback to receive a MSG_PRINTER_DRVUPGRADE message and interate
over all printers, upgrading ones as necessary
const char *drivername;
int snum;
int n_services = lp_numservices();
- size_t len;
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) return;
goto done;
}
- len = MIN(data->length,sizeof(drivername)-1);
- drivername = talloc_strndup(tmp_ctx, (const char *)data->data, len);
+ drivername = talloc_strndup(tmp_ctx, (const char *)data->data, data->length);
if (!drivername) {
DEBUG(0, ("do_drv_upgrade_printer: Out of memoery ?!\n"));
goto done;
continue;
}
+ /* ignore [printers] share */
+ if (strequal(lp_const_servicename(snum), "printers")) {
+ continue;
+ }
+
result = winreg_get_printer(tmp_ctx, server_info, msg,
- NULL,
lp_const_servicename(snum),
&pinfo2);
if ( r->in.access_mask & SERVER_ACCESS_ADMINISTER )
{
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
-
if (!lp_ms_add_printer_wizard()) {
close_printer_handle(p, r->out.handle);
ZERO_STRUCTP(r->out.handle);
and not a printer admin, then fail */
if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !user_has_privileges(p->server_info->ptok,
- &se_printop ) &&
+ !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 (!user_ok_token(uidtoname(p->server_info->utok.uid), NULL,
p->server_info->ptok, snum) ||
- !print_access_check(get_server_info_system(),
+ !print_access_check(p->server_info,
p->msg_ctx,
snum,
r->in.access_mask)) {
winreg_create_printer(p->mem_ctx,
get_server_info_system(),
p->msg_ctx,
- Printer->servername,
lp_const_servicename(snum));
break;
struct spoolss_DriverInfo8 *info_win2k = NULL;
int version;
WERROR status;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
/* 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())
- && !user_has_privileges(p->server_info->ptok, &se_printop )
+ && !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,
int version;
bool delete_files;
WERROR status;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
/* 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())
- && !user_has_privileges(p->server_info->ptok, &se_printop )
+ && !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,
result = winreg_get_printer(mem_ctx,
get_server_info_system(),
p->msg_ctx,
- Printer->servername,
lp_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
result = winreg_get_printer(mem_ctx,
get_server_info_system(),
p->msg_ctx,
- Printer->servername,
lp_servicename(snum), &pinfo2);
if (!W_ERROR_IS_OK(result)) {
return WERR_BADFID;
return result;
}
+/********************************************************************
+ ********************************************************************/
+
+static WERROR create_printername(TALLOC_CTX *mem_ctx,
+ const char *servername,
+ const char *printername,
+ const char **printername_p)
+{
+ /* FIXME: add lp_force_printername() */
+
+ if (servername == NULL) {
+ *printername_p = talloc_strdup(mem_ctx, printername);
+ W_ERROR_HAVE_NO_MEMORY(*printername_p);
+ return WERR_OK;
+ }
+
+ if (servername[0] == '\\' && servername[1] == '\\') {
+ servername += 2;
+ }
+
+ *printername_p = talloc_asprintf(mem_ctx, "\\\\%s\\%s", servername, printername);
+ W_ERROR_HAVE_NO_MEMORY(*printername_p);
+
+ return WERR_OK;
+}
+
+/********************************************************************
+ ********************************************************************/
+
+static void compose_devicemode_devicename(struct spoolss_DeviceMode *dm,
+ const char *printername)
+{
+ if (dm == NULL) {
+ return;
+ }
+
+ dm->devicename = talloc_strndup(dm, printername,
+ MIN(strlen(printername), 31));
+}
+
/********************************************************************
* construct_printer_info_0
* fill a printer_info_0 struct
const struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx,
struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_PrinterInfo0 *r,
int snum)
{
struct printer_session_counter *session_counter;
struct timeval setuptime;
print_status_struct status;
+ WERROR result;
- r->printername = talloc_strdup(mem_ctx, info2->printername);
- W_ERROR_HAVE_NO_MEMORY(r->printername);
+ result = create_printername(mem_ctx, servername, info2->printername, &r->printername);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
- r->servername = talloc_strdup(mem_ctx, info2->servername);
- W_ERROR_HAVE_NO_MEMORY(r->servername);
+ if (servername) {
+ r->servername = talloc_strdup(mem_ctx, servername);
+ W_ERROR_HAVE_NO_MEMORY(r->servername);
+ } else {
+ r->servername = NULL;
+ }
count = print_queue_length(msg_ctx, snum, &status);
static WERROR construct_printer_info1(TALLOC_CTX *mem_ctx,
const struct spoolss_PrinterInfo2 *info2,
uint32_t flags,
+ const char *servername,
struct spoolss_PrinterInfo1 *r,
int snum)
{
- r->flags = flags;
+ WERROR result;
- r->description = talloc_asprintf(mem_ctx, "%s,%s,%s",
- info2->printername,
- info2->drivername,
- info2->location);
- W_ERROR_HAVE_NO_MEMORY(r->description);
+ r->flags = flags;
if (info2->comment == NULL || info2->comment[0] == '\0') {
r->comment = talloc_strdup(mem_ctx, lp_comment(snum));
}
W_ERROR_HAVE_NO_MEMORY(r->comment);
- r->name = talloc_strdup(mem_ctx, info2->printername);
- W_ERROR_HAVE_NO_MEMORY(r->name);
+ result = create_printername(mem_ctx, servername, info2->printername, &r->name);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ r->description = talloc_asprintf(mem_ctx, "%s,%s,%s",
+ r->name,
+ info2->drivername,
+ r->comment);
+ W_ERROR_HAVE_NO_MEMORY(r->description);
return WERR_OK;
}
static WERROR construct_printer_info2(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_PrinterInfo2 *r,
int snum)
{
int count;
print_status_struct status;
+ WERROR result;
count = print_queue_length(msg_ctx, snum, &status);
- r->servername = talloc_strdup(mem_ctx, info2->servername);
- W_ERROR_HAVE_NO_MEMORY(r->servername);
- r->printername = talloc_strdup(mem_ctx, info2->printername);
- W_ERROR_HAVE_NO_MEMORY(r->printername);
+ if (servername) {
+ r->servername = talloc_strdup(mem_ctx, servername);
+ W_ERROR_HAVE_NO_MEMORY(r->servername);
+ } else {
+ r->servername = NULL;
+ }
+
+ result = create_printername(mem_ctx, servername, info2->printername, &r->printername);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
r->sharename = talloc_strdup(mem_ctx, lp_servicename(snum));
W_ERROR_HAVE_NO_MEMORY(r->sharename);
r->portname = talloc_strdup(mem_ctx, info2->portname);
DEBUG(8,("Returning NULL Devicemode!\n"));
}
+ compose_devicemode_devicename(r->devmode, r->printername);
+
r->secdesc = NULL;
if (info2->secdesc != NULL) {
static WERROR construct_printer_info3(TALLOC_CTX *mem_ctx,
const struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_PrinterInfo3 *r,
int snum)
{
static WERROR construct_printer_info4(TALLOC_CTX *mem_ctx,
const struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_PrinterInfo4 *r,
int snum)
{
- r->printername = talloc_strdup(mem_ctx, info2->printername);
- W_ERROR_HAVE_NO_MEMORY(r->printername);
- r->servername = talloc_strdup(mem_ctx, info2->servername);
- W_ERROR_HAVE_NO_MEMORY(r->servername);
+ WERROR result;
+
+ result = create_printername(mem_ctx, servername, info2->printername, &r->printername);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
+ if (servername) {
+ r->servername = talloc_strdup(mem_ctx, servername);
+ W_ERROR_HAVE_NO_MEMORY(r->servername);
+ } else {
+ r->servername = NULL;
+ }
r->attributes = info2->attributes;
static WERROR construct_printer_info5(TALLOC_CTX *mem_ctx,
const struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_PrinterInfo5 *r,
int snum)
{
- r->printername = talloc_strdup(mem_ctx, info2->printername);
- W_ERROR_HAVE_NO_MEMORY(r->printername);
+ WERROR result;
+
+ result = create_printername(mem_ctx, servername, info2->printername, &r->printername);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
r->portname = talloc_strdup(mem_ctx, info2->portname);
W_ERROR_HAVE_NO_MEMORY(r->portname);
static WERROR construct_printer_info6(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
const struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_PrinterInfo6 *r,
int snum)
{
static WERROR construct_printer_info7(TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx,
- struct printer_handle *print_hnd,
+ const char *servername,
struct spoolss_PrinterInfo7 *r,
int snum)
{
}
if (is_printer_published(mem_ctx, server_info, msg_ctx,
- print_hnd->servername,
+ servername,
lp_servicename(snum), &guid, NULL)) {
r->guid = talloc_strdup_upper(mem_ctx, GUID_string2(mem_ctx, &guid));
r->action = DSPRINT_PUBLISH;
static WERROR construct_printer_info8(TALLOC_CTX *mem_ctx,
const struct spoolss_PrinterInfo2 *info2,
+ const char *servername,
struct spoolss_DeviceModeInfo *r,
int snum)
{
+ WERROR result;
+ const char *printername;
+
+ result = create_printername(mem_ctx, servername, info2->printername, &printername);
+ if (!W_ERROR_IS_OK(result)) {
+ return result;
+ }
+
copy_devicemode(mem_ctx, info2->devmode, &r->devmode);
if (!r->devmode) {
DEBUG(8,("Returning NULL Devicemode!\n"));
}
+ compose_devicemode_devicename(r->devmode, printername);
+
return WERR_OK;
}
static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
const struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx,
+ const char *servername,
uint32_t level,
uint32_t flags,
union spoolss_PrinterInfo **info_p,
result = winreg_create_printer(mem_ctx,
server_info,
msg_ctx,
- NULL,
printer);
if (!W_ERROR_IS_OK(result)) {
goto out;
}
result = winreg_get_printer(mem_ctx, server_info, msg_ctx,
- NULL, printer, &info2);
+ printer, &info2);
if (!W_ERROR_IS_OK(result)) {
goto out;
}
case 0:
result = construct_printer_info0(info, server_info,
msg_ctx, info2,
+ servername,
&info[count].info0, snum);
break;
case 1:
result = construct_printer_info1(info, info2, flags,
+ servername,
&info[count].info1, snum);
break;
case 2:
result = construct_printer_info2(info, msg_ctx, info2,
+ servername,
&info[count].info2, snum);
break;
case 4:
result = construct_printer_info4(info, info2,
+ servername,
&info[count].info4, snum);
break;
case 5:
result = construct_printer_info5(info, info2,
+ servername,
&info[count].info5, snum);
break;
DEBUG(4,("enum_all_printers_info_0\n"));
return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
- 0, flags, info, count);
+ servername, 0, flags, info, count);
}
static WERROR enum_all_printers_info_1(TALLOC_CTX *mem_ctx,
const struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx,
+ const char *servername,
uint32_t flags,
union spoolss_PrinterInfo **info,
uint32_t *count)
DEBUG(4,("enum_all_printers_info_1\n"));
return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
- 1, flags, info, count);
+ servername, 1, flags, info, count);
}
/********************************************************************
static WERROR enum_all_printers_info_1_local(TALLOC_CTX *mem_ctx,
const struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx,
+ const char *servername,
union spoolss_PrinterInfo **info,
uint32_t *count)
{
DEBUG(4,("enum_all_printers_info_1_local\n"));
return enum_all_printers_info_1(mem_ctx, server_info, msg_ctx,
- PRINTER_ENUM_ICON8, info, count);
+ 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,
struct messaging_context *msg_ctx,
- const char *name,
+ const char *servername,
union spoolss_PrinterInfo **info,
uint32_t *count)
{
- const char *s = name;
+ const char *s = servername;
DEBUG(4,("enum_all_printers_info_1_name\n"));
- if ((name[0] == '\\') && (name[1] == '\\')) {
- s = name + 2;
+ if ((servername[0] == '\\') && (servername[1] == '\\')) {
+ s = servername + 2;
}
if (!is_myname_or_ipaddr(s)) {
}
return enum_all_printers_info_1(mem_ctx, server_info, msg_ctx,
- PRINTER_ENUM_ICON8, info, count);
+ 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,
struct messaging_context *msg_ctx,
- const char *name,
+ const char *servername,
union spoolss_PrinterInfo **info,
uint32_t *count)
{
- const char *s = name;
+ const char *s = servername;
DEBUG(4,("enum_all_printers_info_1_network\n"));
listed. Windows responds to this call with a
WERR_CAN_NOT_COMPLETE so we should do the same. */
- if (name[0] == '\\' && name[1] == '\\') {
- s = name + 2;
+ if (servername[0] == '\\' && servername[1] == '\\') {
+ s = servername + 2;
}
if (is_myname_or_ipaddr(s)) {
}
return enum_all_printers_info_1(mem_ctx, server_info, msg_ctx,
- PRINTER_ENUM_NAME, info, count);
+ servername, PRINTER_ENUM_NAME, info, count);
}
/********************************************************************
static WERROR enum_all_printers_info_2(TALLOC_CTX *mem_ctx,
const struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx,
+ const char *servername,
union spoolss_PrinterInfo **info,
uint32_t *count)
{
DEBUG(4,("enum_all_printers_info_2\n"));
return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
- 2, 0, info, count);
+ servername, 2, 0, info, count);
}
/********************************************************************
const struct auth_serversupplied_info *server_info,
struct messaging_context *msg_ctx,
uint32_t flags,
- const char *name,
+ const char *servername,
union spoolss_PrinterInfo **info,
uint32_t *count)
{
if (flags & PRINTER_ENUM_LOCAL) {
return enum_all_printers_info_1_local(mem_ctx, server_info,
- msg_ctx, info, count);
+ msg_ctx, servername, info, count);
}
if (flags & PRINTER_ENUM_NAME) {
return enum_all_printers_info_1_name(mem_ctx, server_info,
- msg_ctx, name, info,
+ msg_ctx, servername, info,
count);
}
if (flags & PRINTER_ENUM_NETWORK) {
return enum_all_printers_info_1_network(mem_ctx, server_info,
- msg_ctx, name, info,
+ msg_ctx, servername, info,
count);
}
uint32_t *count)
{
if (flags & PRINTER_ENUM_LOCAL) {
+
return enum_all_printers_info_2(mem_ctx, server_info, msg_ctx,
+ servername,
info, count);
}
if (flags & PRINTER_ENUM_NAME) {
- if (!is_myname_or_ipaddr(canon_servername(servername))) {
+ if (servername && !is_myname_or_ipaddr(canon_servername(servername))) {
return WERR_INVALID_NAME;
}
return enum_all_printers_info_2(mem_ctx, server_info, msg_ctx,
+ servername,
info, count);
}
DEBUG(4,("enum_all_printers_info_4\n"));
return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
- 4, flags, info, count);
+ servername, 4, flags, info, count);
}
DEBUG(4,("enum_all_printers_info_5\n"));
return enum_all_printers_info_level(mem_ctx, server_info, msg_ctx,
- 5, flags, info, count);
+ servername, 5, flags, info, count);
}
/****************************************************************
struct spoolss_EnumPrinters *r)
{
const struct auth_serversupplied_info *server_info = get_server_info_system();
- const char *name = NULL;
WERROR result;
/* that's an [in out] buffer */
* Level 5: same as Level 2
*/
- if (r->in.server) {
- name = talloc_strdup_upper(p->mem_ctx, r->in.server);
- W_ERROR_HAVE_NO_MEMORY(name);
+ if (r->in.server && r->in.server[0] == '\0') {
+ r->in.server = NULL;
}
switch (r->in.level) {
case 0:
result = enumprinters_level0(p->mem_ctx, server_info,
- p->msg_ctx, r->in.flags, name,
+ 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,
- p->msg_ctx, r->in.flags, name,
+ 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,
- p->msg_ctx, r->in.flags, name,
+ 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,
- p->msg_ctx, r->in.flags, name,
+ 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,
- p->msg_ctx, r->in.flags, name,
+ p->msg_ctx, r->in.flags,
+ r->in.server,
r->out.info, r->out.count);
break;
default:
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
struct spoolss_PrinterInfo2 *info2 = NULL;
WERROR result = WERR_OK;
- const char *servername = NULL;
int snum;
/* that's an [in out] buffer */
*r->out.needed = 0;
- if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
+ if (Printer == NULL) {
return WERR_BADFID;
}
- if (Printer != NULL || Printer->servername != NULL) {
- servername = Printer->servername;
+ if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
+ return WERR_BADFID;
}
result = winreg_get_printer(p->mem_ctx,
get_server_info_system(),
p->msg_ctx,
- servername,
lp_const_servicename(snum),
&info2);
if (!W_ERROR_IS_OK(result)) {
- return result;
+ goto out;
}
switch (r->in.level) {
get_server_info_system(),
p->msg_ctx,
info2,
+ Printer->servername,
&r->out.info->info0,
snum);
break;
case 1:
result = construct_printer_info1(p->mem_ctx, info2,
PRINTER_ENUM_ICON8,
+ Printer->servername,
&r->out.info->info1, snum);
break;
case 2:
result = construct_printer_info2(p->mem_ctx, p->msg_ctx, info2,
+ Printer->servername,
&r->out.info->info2, snum);
break;
case 3:
result = construct_printer_info3(p->mem_ctx, info2,
+ Printer->servername,
&r->out.info->info3, snum);
break;
case 4:
result = construct_printer_info4(p->mem_ctx, info2,
+ Printer->servername,
&r->out.info->info4, snum);
break;
case 5:
result = construct_printer_info5(p->mem_ctx, info2,
+ Printer->servername,
&r->out.info->info5, snum);
break;
case 6:
result = construct_printer_info6(p->mem_ctx, p->msg_ctx, info2,
+ Printer->servername,
&r->out.info->info6, snum);
break;
case 7:
result = construct_printer_info7(p->mem_ctx, p->msg_ctx,
- Printer,
+ Printer->servername,
&r->out.info->info7, snum);
break;
case 8:
result = construct_printer_info8(p->mem_ctx, info2,
+ Printer->servername,
&r->out.info->info8, snum);
break;
default:
break;
}
+ out:
if (!W_ERROR_IS_OK(result)) {
DEBUG(0, ("_spoolss_GetPrinter: failed to construct printer info level %d - %s\n",
r->in.level, win_errstr(result)));
struct spoolss_DriverInfo8 *driver;
WERROR result;
+ if (level == 101) {
+ return WERR_UNKNOWN_LEVEL;
+ }
+
result = winreg_get_printer(mem_ctx,
server_info,
msg_ctx,
- servername,
lp_const_servicename(snum),
&pinfo2);
return WERR_BADFID;
}
- werr = print_job_start(get_server_info_system(),
+ werr = print_job_start(p->server_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 = get_server_info_system();
+ const struct auth_serversupplied_info *server_info = p->server_info;
int snum;
WERROR errcode = WERR_BADFUNC;
struct printer_handle *Printer = find_printer_index_by_hnd(p, handle);
return WERR_SPL_NO_STARTDOC;
}
- errcode = print_job_delete(get_server_info_system(),
+ errcode = print_job_delete(p->server_info,
p->msg_ctx,
snum,
Printer->jobid);
/****************************************************************************
****************************************************************************/
-static WERROR add_port_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token, const char *portname, const char *uri)
+static WERROR add_port_hook(TALLOC_CTX *ctx, struct security_token *token, const char *portname, const char *uri)
{
char *cmd = lp_addport_cmd();
char *command = NULL;
int ret;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
bool is_print_op = false;
if ( !*cmd ) {
}
if ( token )
- is_print_op = user_has_privileges( token, &se_printop );
+ is_print_op = security_token_has_privilege(token, SEC_PRIV_PRINT_OPERATOR);
DEBUG(10,("Running [%s]\n", command));
/****************************************************************************
****************************************************************************/
-static bool add_printer_hook(TALLOC_CTX *ctx, NT_USER_TOKEN *token,
+static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
struct spoolss_SetPrinterInfo2 *info2,
const char *remote_machine,
struct messaging_context *msg_ctx)
int numlines;
int ret;
int fd;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
bool is_print_op = false;
if (!remote_machine) {
}
if ( token )
- is_print_op = user_has_privileges( token, &se_printop );
+ is_print_op = security_token_has_privilege(token, SEC_PRIV_PRINT_OPERATOR);
DEBUG(10,("Running [%s]\n", command));
printer->drivername));
notify_printer_driver(server_event_context(), msg_ctx,
- snum, printer->drivername);
+ snum, printer->drivername ?
+ printer->drivername : "");
}
}
if (!force_update) {
notify_printer_comment(server_event_context(), msg_ctx,
- snum, printer->comment);
+ snum, printer->comment ?
+ printer->comment : "");
}
}
if (!force_update) {
notify_printer_sharename(server_event_context(),
msg_ctx,
- snum, printer->sharename);
+ snum, printer->sharename ?
+ printer->sharename : "");
}
}
if (!force_update) {
notify_printer_printername(server_event_context(),
- msg_ctx, snum, p);
+ msg_ctx, snum, p ? p : "");
}
}
if (!force_update) {
notify_printer_port(server_event_context(),
- msg_ctx, snum, printer->portname);
+ msg_ctx, snum, printer->portname ?
+ printer->portname : "");
}
}
if (!force_update) {
notify_printer_location(server_event_context(),
msg_ctx, snum,
- printer->location);
+ printer->location ?
+ printer->location : "");
}
}
buffer.length);
if (!force_update) {
- notify_printer_location(server_event_context(),
- msg_ctx, snum,
- printer->location);
+ notify_printer_sepfile(server_event_context(),
+ msg_ctx, snum,
+ printer->sepfile ?
+ printer->sepfile : "");
}
}
struct spoolss_SetPrinterInfo2 *printer = info_ctr->info.info2;
struct spoolss_PrinterInfo2 *old_printer;
struct printer_handle *Printer = find_printer_index_by_hnd(p, handle);
- const char *servername = NULL;
int snum;
WERROR result = WERR_OK;
TALLOC_CTX *tmp_ctx;
goto done;
}
- if (Printer != NULL || Printer->servername != NULL) {
- servername = Printer->servername;
- }
-
result = winreg_get_printer(tmp_ctx,
get_server_info_system(),
p->msg_ctx,
- servername,
lp_const_servicename(snum),
&old_printer);
if (!W_ERROR_IS_OK(result)) {
result = winreg_get_printer(p->mem_ctx,
get_server_info_system(),
p->msg_ctx,
- Printer->servername,
lp_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
result = winreg_get_printer(p->mem_ctx,
get_server_info_system(),
p->msg_ctx,
- NULL,
lp_const_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
WERROR _spoolss_SetJob(struct pipes_struct *p,
struct spoolss_SetJob *r)
{
- const struct auth_serversupplied_info *server_info = get_server_info_system();
+ const struct auth_serversupplied_info *server_info = p->server_info;
int snum;
WERROR errcode = WERR_BADFUNC;
}
/* you must be a printer admin to add a new printer */
- if (!print_access_check(get_server_info_system(),
+ if (!print_access_check(p->server_info,
p->msg_ctx,
snum,
PRINTER_ACCESS_ADMINISTER)) {
struct spoolss_AddFormInfo1 *form = r->in.info.info1;
int snum = -1;
WERROR status = WERR_OK;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
and not a printer admin, then fail */
if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !user_has_privileges(p->server_info->ptok, &se_printop) &&
- !token_contains_name_in_list(uidtoname(p->server_info->utok.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,
NULL,
p->server_info->ptok,
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
int snum = -1;
WERROR status = WERR_OK;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
DEBUG(5,("_spoolss_DeleteForm\n"));
}
if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !user_has_privileges(p->server_info->ptok, &se_printop) &&
- !token_contains_name_in_list(uidtoname(p->server_info->utok.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,
NULL,
p->server_info->ptok,
const char *form_name = r->in.form_name;
int snum = -1;
WERROR status = WERR_OK;
- SE_PRIV se_printop = SE_PRINT_OPERATOR;
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
and not a printer admin, then fail */
if ((p->server_info->utok.uid != sec_initial_uid()) &&
- !user_has_privileges(p->server_info->ptok, &se_printop) &&
+ !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,
NULL,
*r->out.needed = 0;
*r->out.info = NULL;
+ if (!get_short_archi(r->in.environment)) {
+ return WERR_INVALID_ENVIRONMENT;
+ }
+
switch (r->in.level) {
case 1:
result = enumprintprocessors_level_1(p->mem_ctx, r->out.info,
*r->out.needed = 0;
*r->out.info = NULL;
+ if (r->in.print_processor_name == NULL ||
+ !strequal(r->in.print_processor_name, "winprint")) {
+ return WERR_UNKNOWN_PRINTPROCESSOR;
+ }
+
switch (r->in.level) {
case 1:
result = enumprintprocdatatypes_level_1(p->mem_ctx, r->out.info,
result = winreg_get_printer(p->mem_ctx,
get_server_info_system(),
p->msg_ctx,
- NULL,
lp_const_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
result = winreg_get_printer(Printer,
get_server_info_system(),
p->msg_ctx,
- Printer->servername,
lp_servicename(snum),
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
struct spoolss_GetPrintProcessorDirectory *r)
{
WERROR result;
+ fstring prnproc_share;
+ bool prnproc_share_exists = false;
+ int snum;
/* that's an [in out] buffer */
/* We always should reply with a local print processor directory so that
* users are not forced to have a [prnproc$] share on the Samba spoolss
- * server - Guenther */
+ * server, if users decide to do so, lets announce it though - Guenther */
+
+ fstrcpy(prnproc_share, "prnproc$");
+
+ snum = find_service(prnproc_share);
+ if (snum != -1) {
+ prnproc_share_exists = true;
+ }
result = getprintprocessordirectory_level_1(p->mem_ctx,
- NULL, /* r->in.server */
+ prnproc_share_exists ? r->in.server : NULL,
r->in.environment,
&r->out.info->info1);
if (!W_ERROR_IS_OK(result)) {
*******************************************************************/
static WERROR xcvtcp_monitorui(TALLOC_CTX *mem_ctx,
- NT_USER_TOKEN *token, DATA_BLOB *in,
+ struct security_token *token, DATA_BLOB *in,
DATA_BLOB *out, uint32_t *needed)
{
const char *dllname = "tcpmonui.dll";
*******************************************************************/
static WERROR xcvtcp_addport(TALLOC_CTX *mem_ctx,
- NT_USER_TOKEN *token, DATA_BLOB *in,
+ struct security_token *token, DATA_BLOB *in,
DATA_BLOB *out, uint32_t *needed)
{
struct spoolss_PortData1 port1;
};
static WERROR process_xcvtcp_command(TALLOC_CTX *mem_ctx,
- NT_USER_TOKEN *token, const char *command,
+ struct security_token *token, const char *command,
DATA_BLOB *inbuf,
DATA_BLOB *outbuf,
uint32_t *needed )
#if 0 /* don't support management using the "Local Port" monitor */
static WERROR xcvlocal_monitorui(TALLOC_CTX *mem_ctx,
- NT_USER_TOKEN *token, DATA_BLOB *in,
+ struct security_token *token, DATA_BLOB *in,
DATA_BLOB *out, uint32_t *needed)
{
const char *dllname = "localui.dll";
*******************************************************************/
static WERROR process_xcvlocal_command(TALLOC_CTX *mem_ctx,
- NT_USER_TOKEN *token, const char *command,
+ struct security_token *token, const char *command,
DATA_BLOB *inbuf, DATA_BLOB *outbuf,
uint32_t *needed)
{
}
/****************************************************************
- _spoolss_47
+ _spoolss_SetPort
****************************************************************/
-WERROR _spoolss_47(struct pipes_struct *p,
- struct spoolss_47 *r)
+WERROR _spoolss_SetPort(struct pipes_struct *p,
+ struct spoolss_SetPort *r)
{
p->rng_fault_state = true;
return WERR_NOT_SUPPORTED;