#include "../libcli/security/security.h"
#include "passdb/machine_sid.h"
#include "smbd/smbd.h"
+#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
#include "rpc_server/spoolss/srv_spoolss_nt.h"
}
/* Skip OEM header (if any) and the DOS stub to start of Windows header */
- if (SMB_VFS_LSEEK(fsp, SVAL(buf,DOS_HEADER_LFANEW_OFFSET), SEEK_SET) == (SMB_OFF_T)-1) {
+ if (SMB_VFS_LSEEK(fsp, SVAL(buf,DOS_HEADER_LFANEW_OFFSET), SEEK_SET) == (off_t)-1) {
DEBUG(3,("get_file_version: File [%s] too short, errno = %d\n",
fname, errno));
/* Assume this isn't an error... the file just looks sort of like a PE/NE file */
/* Just skip over optional header to get to section table */
if (SMB_VFS_LSEEK(fsp,
SVAL(buf,PE_HEADER_OPTIONAL_HEADER_SIZE)-(NE_HEADER_SIZE-PE_HEADER_SIZE),
- SEEK_CUR) == (SMB_OFF_T)-1) {
+ SEEK_CUR) == (off_t)-1) {
DEBUG(3,("get_file_version: File [%s] Windows optional header too short, errno = %d\n",
fname, errno));
goto error_exit;
}
/* Seek to the start of the .rsrc section info */
- if (SMB_VFS_LSEEK(fsp, section_pos, SEEK_SET) == (SMB_OFF_T)-1) {
+ if (SMB_VFS_LSEEK(fsp, section_pos, SEEK_SET) == (off_t)-1) {
DEBUG(3,("get_file_version: PE file [%s] too short for section info, errno = %d\n",
fname, errno));
goto error_exit;
/****************************************************************************
Determine the correct cVersion associated with an architecture and driver
****************************************************************************/
-static uint32 get_correct_cversion(struct auth3_session_info *session_info,
+static uint32 get_correct_cversion(struct auth_session_info *session_info,
const char *architecture,
const char *driverpath_in,
WERROR *perr)
return -1;
}
- nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
+ nt_status = create_conn_struct(talloc_tos(),
+ server_event_context(),
+ server_messaging_context(),
+ &conn,
+ printdollar_snum,
lp_pathname(printdollar_snum),
session_info, &oldcwd);
if (!NT_STATUS_IS_OK(nt_status)) {
SMB_VFS_DISCONNECT(conn);
conn_free(conn);
}
- if (!NT_STATUS_IS_OK(*perr)) {
+ if (!W_ERROR_IS_OK(*perr)) {
cversion = -1;
}
} while (0);
static WERROR clean_up_driver_struct_level(TALLOC_CTX *mem_ctx,
- struct auth3_session_info *session_info,
+ struct auth_session_info *session_info,
const char *architecture,
const char **driver_path,
const char **data_file,
****************************************************************************/
WERROR clean_up_driver_struct(TALLOC_CTX *mem_ctx,
- struct auth3_session_info *session_info,
+ struct auth_session_info *session_info,
struct spoolss_AddDriverInfoCtr *r)
{
switch (r->level) {
return ret;
}
-WERROR move_driver_to_download_area(struct auth3_session_info *session_info,
+WERROR move_driver_to_download_area(struct auth_session_info *session_info,
struct spoolss_AddDriverInfoCtr *r)
{
struct spoolss_AddDriverInfo3 *driver;
return WERR_NO_SUCH_SHARE;
}
- nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
+ nt_status = create_conn_struct(talloc_tos(),
+ server_event_context(),
+ server_messaging_context(),
+ &conn,
+ printdollar_snum,
lp_pathname(printdollar_snum),
session_info, &oldcwd);
if (!NT_STATUS_IS_OK(nt_status)) {
****************************************************************************/
bool printer_driver_in_use(TALLOC_CTX *mem_ctx,
- const struct auth3_session_info *session_info,
- struct messaging_context *msg_ctx,
- const struct spoolss_DriverInfo8 *r)
+ struct dcerpc_binding_handle *b,
+ const struct spoolss_DriverInfo8 *r)
{
int snum;
int n_services = lp_numservices();
bool in_use = False;
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
WERROR result;
- struct dcerpc_binding_handle *b = NULL;
if (!r) {
return false;
continue;
}
- if (b == NULL) {
- result = winreg_printer_binding_handle(mem_ctx,
- session_info,
- msg_ctx,
- &b);
- if (!W_ERROR_IS_OK(result)) {
- return false;
- }
- }
-
result = winreg_get_printer(mem_ctx, b,
lp_servicename(snum),
&pinfo2);
****************************************************************************/
bool printer_driver_files_in_use(TALLOC_CTX *mem_ctx,
- const struct auth3_session_info *session_info,
- struct messaging_context *msg_ctx,
+ struct dcerpc_binding_handle *b,
struct spoolss_DriverInfo8 *info)
{
int i;
uint32_t num_drivers;
const char **drivers;
WERROR result;
- struct dcerpc_binding_handle *b;
if ( !info )
return False;
/* get the list of drivers */
- result = winreg_printer_binding_handle(mem_ctx,
- session_info,
- msg_ctx,
- &b);
- if (!W_ERROR_IS_OK(result)) {
- return false;
- }
-
result = winreg_get_driver_list(mem_ctx, b,
info->architecture, version,
&num_drivers, &drivers);
}
static NTSTATUS driver_unlink_internals(connection_struct *conn,
- const char *name)
+ const char *short_arch,
+ int vers,
+ const char *fname)
{
+ TALLOC_CTX *tmp_ctx = talloc_new(conn);
struct smb_filename *smb_fname = NULL;
- NTSTATUS status;
+ char *print_dlr_path;
+ NTSTATUS status = NT_STATUS_NO_MEMORY;
+
+ print_dlr_path = talloc_asprintf(tmp_ctx, "%s/%d/%s",
+ short_arch, vers, fname);
+ if (print_dlr_path == NULL) {
+ goto err_out;
+ }
- status = create_synthetic_smb_fname(talloc_tos(), name, NULL, NULL,
- &smb_fname);
+ status = create_synthetic_smb_fname(tmp_ctx, print_dlr_path,
+ NULL, NULL, &smb_fname);
if (!NT_STATUS_IS_OK(status)) {
- return status;
+ goto err_out;
}
status = unlink_internals(conn, NULL, 0, smb_fname, false);
-
- TALLOC_FREE(smb_fname);
+err_out:
+ talloc_free(tmp_ctx);
return status;
}
this.
****************************************************************************/
-bool delete_driver_files(const struct auth3_session_info *session_info,
+bool delete_driver_files(const struct auth_session_info *session_info,
const struct spoolss_DriverInfo8 *r)
{
- int i = 0;
- char *s;
- const char *file;
+ const char *short_arch;
connection_struct *conn;
NTSTATUS nt_status;
char *oldcwd;
return false;
}
- nt_status = create_conn_struct(talloc_tos(), &conn, printdollar_snum,
+ nt_status = create_conn_struct(talloc_tos(),
+ server_event_context(),
+ server_messaging_context(),
+ &conn,
+ printdollar_snum,
lp_pathname(printdollar_snum),
session_info, &oldcwd);
if (!NT_STATUS_IS_OK(nt_status)) {
goto err_out;
}
- /* now delete the files; must strip the '\print$' string from
- fron of path */
+ short_arch = get_short_archi(r->architecture);
+ if (short_arch == NULL) {
+ DEBUG(0, ("bad architecture %s\n", r->architecture));
+ ret = false;
+ goto err_out;
+ }
+
+ /* now delete the files */
if (r->driver_path && r->driver_path[0]) {
- if ((s = strchr(&r->driver_path[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting driverfile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting driverfile [%s]\n", r->driver_path));
+ driver_unlink_internals(conn, short_arch, r->version, r->driver_path);
}
if (r->config_file && r->config_file[0]) {
- if ((s = strchr(&r->config_file[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting configfile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting configfile [%s]\n", r->config_file));
+ driver_unlink_internals(conn, short_arch, r->version, r->config_file);
}
if (r->data_file && r->data_file[0]) {
- if ((s = strchr(&r->data_file[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting datafile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting datafile [%s]\n", r->data_file));
+ driver_unlink_internals(conn, short_arch, r->version, r->data_file);
}
if (r->help_file && r->help_file[0]) {
- if ((s = strchr(&r->help_file[1], '\\')) != NULL) {
- file = s;
- DEBUG(10,("deleting helpfile [%s]\n", s));
- driver_unlink_internals(conn, file);
- }
+ DEBUG(10,("deleting helpfile [%s]\n", r->help_file));
+ driver_unlink_internals(conn, short_arch, r->version, r->help_file);
}
- /* check if we are done removing files */
-
if (r->dependent_files) {
+ int i = 0;
while (r->dependent_files[i] && r->dependent_files[i][0]) {
- char *p;
-
- /* bypass the "\print$" portion of the path */
-
- if ((p = strchr(r->dependent_files[i]+1, '\\')) != NULL) {
- file = p;
- DEBUG(10,("deleting dependent file [%s]\n", file));
- driver_unlink_internals(conn, file);
- }
-
+ DEBUG(10,("deleting dependent file [%s]\n", r->dependent_files[i]));
+ driver_unlink_internals(conn, short_arch, r->version, r->dependent_files[i]);
i++;
}
}
2: file doesn't exist
3: can't allocate memory
4: can't free memory
- 5: non existant struct
+ 5: non existent struct
*/
/*
3) "printer admins" (may result in numerous calls to winbind)
****************************************************************************/
-bool print_access_check(const struct auth3_session_info *session_info,
+bool print_access_check(const struct auth_session_info *session_info,
struct messaging_context *msg_ctx, int snum,
int access_type)
{
/* Always allow root or SE_PRINT_OPERATROR to do anything */
- if (session_info->utok.uid == sec_initial_uid()
+ if (session_info->unix_token->uid == sec_initial_uid()
|| security_token_has_privilege(session_info->security_token, SEC_PRIV_PRINT_OPERATOR)) {
return True;
}
/* see if we need to try the printer admin list */
if (!NT_STATUS_IS_OK(status) &&
- (token_contains_name_in_list(uidtoname(session_info->utok.uid),
- session_info->info3->base.domain.string,
+ (token_contains_name_in_list(uidtoname(session_info->unix_token->uid),
+ session_info->info->domain_name,
NULL, session_info->security_token,
lp_printer_admin(snum)))) {
talloc_destroy(mem_ctx);
Check the time parameters allow a print operation.
*****************************************************************************/
-bool print_time_access_check(const struct auth3_session_info *session_info,
+bool print_time_access_check(const struct auth_session_info *session_info,
struct messaging_context *msg_ctx,
const char *servicename)
{
}
void nt_printer_remove(TALLOC_CTX *mem_ctx,
- const struct auth3_session_info *session_info,
+ const struct auth_session_info *session_info,
struct messaging_context *msg_ctx,
const char *printer)
{
result = winreg_delete_printer_key_internal(mem_ctx, session_info, msg_ctx,
printer, "");
if (!W_ERROR_IS_OK(result)) {
- DEBUG(0, ("nt_printer_remove: failed to remove rpinter %s",
- printer));
+ DEBUG(0, ("nt_printer_remove: failed to remove printer %s: "
+ "%s\n", printer, win_errstr(result)));
+ }
+}
+
+void nt_printer_add(TALLOC_CTX *mem_ctx,
+ const struct auth_session_info *session_info,
+ struct messaging_context *msg_ctx,
+ const char *printer)
+{
+ WERROR result;
+
+ result = winreg_create_printer_internal(mem_ctx, session_info, msg_ctx,
+ printer);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("nt_printer_add: failed to add printer %s: %s\n",
+ printer, win_errstr(result)));
}
}