int version;
};
-#define SPL_ARCH_WIN40 "WIN40"
-#define SPL_ARCH_W32X86 "W32X86"
-#define SPL_ARCH_W32MIPS "W32MIPS"
-#define SPL_ARCH_W32ALPHA "W32ALPHA"
-#define SPL_ARCH_W32PPC "W32PPC"
-#define SPL_ARCH_IA64 "IA64"
-#define SPL_ARCH_X64 "x64"
-
static const struct table_node archi_table[]= {
{"Windows 4.0", SPL_ARCH_WIN40, 0 },
/****************************************************************************
****************************************************************************/
+
+static WERROR move_driver_file_to_download_area(TALLOC_CTX *mem_ctx,
+ connection_struct *conn,
+ const char *driver_file,
+ const char *short_architecture,
+ uint32_t driver_version,
+ uint32_t version)
+{
+ char *old_name = NULL;
+ char *new_name = NULL;
+ SMB_STRUCT_STAT st;
+ NTSTATUS status;
+
+ old_name = talloc_asprintf(mem_ctx, "%s/%s",
+ short_architecture, driver_file);
+ W_ERROR_HAVE_NO_MEMORY(old_name);
+
+ new_name = talloc_asprintf(mem_ctx, "%s/%d/%s",
+ short_architecture, driver_version, driver_file);
+ W_ERROR_HAVE_NO_MEMORY(new_name);
+
+ if (version != -1 && (version = file_version_is_newer(conn, old_name, new_name)) > 0) {
+
+ old_name = driver_unix_convert(conn, old_name, &st);
+ W_ERROR_HAVE_NO_MEMORY(old_name);
+
+ DEBUG(10,("move_driver_file_to_download_area: copying '%s' to '%s'\n",
+ old_name, new_name));
+
+ status = copy_file(mem_ctx, conn, old_name, new_name,
+ OPENX_FILE_EXISTS_TRUNCATE |
+ OPENX_FILE_CREATE_IF_NOT_EXIST,
+ 0, false);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("move_driver_file_to_download_area: Unable to rename [%s] to [%s]: %s\n",
+ old_name, new_name, nt_errstr(status)));
+ return WERR_ACCESS_DENIED;
+ }
+ }
+
+ return WERR_OK;
+}
+
WERROR move_driver_to_download_area(struct pipes_struct *p,
NT_PRINTER_DRIVER_INFO_LEVEL driver_abstract,
uint32 level, WERROR *perr)
{
NT_PRINTER_DRIVER_INFO_LEVEL_3 *driver;
NT_PRINTER_DRIVER_INFO_LEVEL_3 converted_driver;
- const char *architecture;
+ const char *short_architecture;
char *new_dir = NULL;
- char *old_name = NULL;
- char *new_name = NULL;
connection_struct *conn = NULL;
NTSTATUS nt_status;
SMB_STRUCT_STAT st;
*perr = WERR_OK;
- if (level==3)
- driver=driver_abstract.info_3;
- else if (level==6) {
+ switch (level) {
+ case 3:
+ driver = driver_abstract.info_3;
+ break;
+ case 6:
convert_level_6_to_level3(&converted_driver, driver_abstract.info_6);
driver = &converted_driver;
- } else {
+ break;
+ default:
DEBUG(0,("move_driver_to_download_area: Unknown info level (%u)\n", (unsigned int)level ));
return WERR_UNKNOWN_LEVEL;
}
- architecture = get_short_archi(driver->environment);
- if (!architecture) {
+ short_architecture = get_short_archi(driver->environment);
+ if (!short_architecture) {
return WERR_UNKNOWN_PRINTER_DRIVER;
}
return *perr;
}
- DEBUG(5,("Creating first directory\n"));
new_dir = talloc_asprintf(ctx,
"%s/%d",
- architecture,
+ short_architecture,
driver->cversion);
if (!new_dir) {
*perr = WERR_NOMEM;
goto err_exit;
}
+ DEBUG(5,("Creating first directory: %s\n", new_dir));
+
create_directory(conn, NULL, new_dir);
/* For each driver file, archi\filexxx.yyy, if there is a duplicate file
DEBUG(5,("Moving files now !\n"));
if (driver->driverpath && strlen(driver->driverpath)) {
- new_name = talloc_asprintf(ctx,
- "%s/%s",
- architecture,
- driver->driverpath);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- old_name = talloc_asprintf(ctx,
- "%s/%s",
- new_dir,
- driver->driverpath);
- if (!old_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
- new_name = driver_unix_convert(conn,new_name,&st);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
- DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
- new_name, old_name));
- *perr = WERR_ACCESS_DENIED;
+ *perr = move_driver_file_to_download_area(ctx,
+ conn,
+ driver->driverpath,
+ short_architecture,
+ driver->cversion,
+ ver);
+ if (!W_ERROR_IS_OK(*perr)) {
+ if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
ver = -1;
}
+ goto err_exit;
}
}
if (driver->datafile && strlen(driver->datafile)) {
if (!strequal(driver->datafile, driver->driverpath)) {
- new_name = talloc_asprintf(ctx,
- "%s/%s",
- architecture,
- driver->datafile);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- old_name = talloc_asprintf(ctx,
- "%s/%s",
- new_dir,
- driver->datafile);
- if (!old_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
- new_name = driver_unix_convert(conn,new_name,&st);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
- DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
- new_name, old_name));
- *perr = WERR_ACCESS_DENIED;
+
+ *perr = move_driver_file_to_download_area(ctx,
+ conn,
+ driver->datafile,
+ short_architecture,
+ driver->cversion,
+ ver);
+ if (!W_ERROR_IS_OK(*perr)) {
+ if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
ver = -1;
}
+ goto err_exit;
}
}
}
if (driver->configfile && strlen(driver->configfile)) {
if (!strequal(driver->configfile, driver->driverpath) &&
- !strequal(driver->configfile, driver->datafile)) {
- new_name = talloc_asprintf(ctx,
- "%s/%s",
- architecture,
- driver->configfile);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- old_name = talloc_asprintf(ctx,
- "%s/%s",
- new_dir,
- driver->configfile);
- if (!old_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
- new_name = driver_unix_convert(conn,new_name,&st);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
- DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
- new_name, old_name));
- *perr = WERR_ACCESS_DENIED;
+ !strequal(driver->configfile, driver->datafile)) {
+
+ *perr = move_driver_file_to_download_area(ctx,
+ conn,
+ driver->configfile,
+ short_architecture,
+ driver->cversion,
+ ver);
+ if (!W_ERROR_IS_OK(*perr)) {
+ if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
ver = -1;
}
+ goto err_exit;
}
}
}
if (driver->helpfile && strlen(driver->helpfile)) {
if (!strequal(driver->helpfile, driver->driverpath) &&
- !strequal(driver->helpfile, driver->datafile) &&
- !strequal(driver->helpfile, driver->configfile)) {
- new_name = talloc_asprintf(ctx,
- "%s/%s",
- architecture,
- driver->helpfile);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- old_name = talloc_asprintf(ctx,
- "%s/%s",
- new_dir,
- driver->helpfile);
- if (!old_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
- new_name = driver_unix_convert(conn,new_name,&st);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
- DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
- new_name, old_name));
- *perr = WERR_ACCESS_DENIED;
+ !strequal(driver->helpfile, driver->datafile) &&
+ !strequal(driver->helpfile, driver->configfile)) {
+
+ *perr = move_driver_file_to_download_area(ctx,
+ conn,
+ driver->helpfile,
+ short_architecture,
+ driver->cversion,
+ ver);
+ if (!W_ERROR_IS_OK(*perr)) {
+ if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
ver = -1;
}
+ goto err_exit;
}
}
}
if (driver->dependentfiles) {
for (i=0; *driver->dependentfiles[i]; i++) {
if (!strequal(driver->dependentfiles[i], driver->driverpath) &&
- !strequal(driver->dependentfiles[i], driver->datafile) &&
- !strequal(driver->dependentfiles[i], driver->configfile) &&
- !strequal(driver->dependentfiles[i], driver->helpfile)) {
+ !strequal(driver->dependentfiles[i], driver->datafile) &&
+ !strequal(driver->dependentfiles[i], driver->configfile) &&
+ !strequal(driver->dependentfiles[i], driver->helpfile)) {
int j;
for (j=0; j < i; j++) {
if (strequal(driver->dependentfiles[i], driver->dependentfiles[j])) {
}
}
- new_name = talloc_asprintf(ctx,
- "%s/%s",
- architecture,
- driver->dependentfiles[i]);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- old_name = talloc_asprintf(ctx,
- "%s/%s",
- new_dir,
- driver->dependentfiles[i]);
- if (!old_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
- new_name = driver_unix_convert(conn,new_name,&st);
- if (!new_name) {
- *perr = WERR_NOMEM;
- goto err_exit;
- }
- if ( !NT_STATUS_IS_OK(copy_file(ctx,conn, new_name, old_name,
- OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
- DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
- new_name, old_name));
- *perr = WERR_ACCESS_DENIED;
+ *perr = move_driver_file_to_download_area(ctx,
+ conn,
+ driver->dependentfiles[i],
+ short_architecture,
+ driver->cversion,
+ ver);
+ if (!W_ERROR_IS_OK(*perr)) {
+ if (W_ERROR_EQUAL(*perr, WERR_ACCESS_DENIED)) {
ver = -1;
}
+ goto err_exit;
}
}
NextDriver: ;
{
int len = 0;
int i, j;
- REGISTRY_VALUE *val;
+ struct regval_blob *val;
struct regval_ctr *val_ctr;
char *path = NULL;
int num_values;
{
NT_PRINTER_INFO_LEVEL *printer = NULL;
struct regval_ctr *ctr;
- REGISTRY_VALUE *guid_val;
+ struct regval_blob *guid_val;
WERROR win_rc;
int i;
bool ret = False;
/****************************************************************************
***************************************************************************/
-REGISTRY_VALUE* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value )
+struct regval_blob* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value )
{
int key_index;
char *str;
int size;
uint8 *data_p;
- REGISTRY_VALUE *regval_p;
+ struct regval_blob *regval_p;
int key_index;
/* add the "PrinterDriverData" key first for performance reasons */
print_queue_purge
Try access control in the following order (for performance reasons):
- 1) root ans SE_PRINT_OPERATOR can do anything (easy check)
+ 1) root and SE_PRINT_OPERATOR can do anything (easy check)
2) check security descriptor (bit comparisons in memory)
3) "printer admins" (may result in numerous calls to winbind)