summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-15 13:37:44 +0200
committerSimo Sorce <idra@samba.org>2010-07-27 10:27:15 -0400
commitb95d5563ddff7aec15f4138be731578785dca7ec (patch)
tree9ea8eff8950269b12fbd22e712a00b2ef35454d7 /source3/printing
parent924cc43d1b8f8358f7c7aaef16b06437e39cd05b (diff)
downloadsamba-b95d5563ddff7aec15f4138be731578785dca7ec.tar.gz
samba-b95d5563ddff7aec15f4138be731578785dca7ec.tar.bz2
samba-b95d5563ddff7aec15f4138be731578785dca7ec.zip
s3-printing: Added automatic migration of printing tdbs.
Signed-off-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/nt_printing.c85
-rw-r--r--source3/printing/nt_printing_migrate.c1
-rw-r--r--source3/printing/printing.c83
3 files changed, 83 insertions, 86 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 8a06ef11c6..1186c6710c 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -82,10 +82,6 @@ bool nt_printing_init(struct messaging_context *msg_ctx)
return false;
}
- if (!nt_printing_tdb_migrate()) {
- return false;
- }
-
/*
* register callback to handle updating printers as new
* drivers are installed
@@ -1145,87 +1141,6 @@ WERROR move_driver_to_download_area(struct pipes_struct *p,
}
/****************************************************************************
-****************************************************************************/
-int pack_devicemode(struct spoolss_DeviceMode *devmode, uint8 *buf, int buflen)
-{
- enum ndr_err_code ndr_err;
- DATA_BLOB blob;
- int len = 0;
-
- if (devmode) {
- ndr_err = ndr_push_struct_blob(&blob, talloc_tos(),
- devmode,
- (ndr_push_flags_fn_t)
- ndr_push_spoolss_DeviceMode);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(10, ("pack_devicemode: "
- "error encoding spoolss_DeviceMode\n"));
- goto done;
- }
- } else {
- ZERO_STRUCT(blob);
- }
-
- len = tdb_pack(buf, buflen, "B", blob.length, blob.data);
-
- if (devmode) {
- DEBUG(8, ("Packed devicemode [%s]\n", devmode->formname));
- }
-
-done:
- return len;
-}
-
-/****************************************************************************
-****************************************************************************/
-int unpack_devicemode(TALLOC_CTX *mem_ctx,
- const uint8 *buf, int buflen,
- struct spoolss_DeviceMode **devmode)
-{
- struct spoolss_DeviceMode *dm;
- enum ndr_err_code ndr_err;
- char *data = NULL;
- int data_len = 0;
- DATA_BLOB blob;
- int len = 0;
-
- *devmode = NULL;
-
- len = tdb_unpack(buf, buflen, "B", &data_len, &data);
- if (!data) {
- return len;
- }
-
- dm = talloc_zero(mem_ctx, struct spoolss_DeviceMode);
- if (!dm) {
- goto done;
- }
-
- blob = data_blob_const(data, data_len);
-
- ndr_err = ndr_pull_struct_blob(&blob, dm, dm,
- (ndr_pull_flags_fn_t)ndr_pull_spoolss_DeviceMode);
- if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
- DEBUG(10, ("unpack_devicemode: "
- "error parsing spoolss_DeviceMode\n"));
- goto done;
- }
-
- DEBUG(8, ("Unpacked devicemode [%s](%s)\n",
- dm->devicename, dm->formname));
- if (dm->driverextra_data.data) {
- DEBUG(8, ("with a private section of %d bytes\n",
- dm->__driverextra_length));
- }
-
- *devmode = dm;
-
-done:
- SAFE_FREE(data);
- return len;
-}
-
-/****************************************************************************
Create and allocate a default devicemode.
****************************************************************************/
diff --git a/source3/printing/nt_printing_migrate.c b/source3/printing/nt_printing_migrate.c
index 94f8d87397..624d24539d 100644
--- a/source3/printing/nt_printing_migrate.c
+++ b/source3/printing/nt_printing_migrate.c
@@ -602,7 +602,6 @@ bool nt_printing_tdb_migrate(void)
status = rpc_pipe_open_internal(tmp_ctx,
&ndr_table_spoolss.syntax_id,
- rpc_spoolss_dispatch,
server_info,
&spoolss_pipe);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index b620db03d5..3635e59c34 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -275,6 +275,89 @@ static TDB_DATA print_key(uint32 jobid, uint32 *tmp)
return ret;
}
+/****************************************************************************
+ Pack the devicemode to store it in a tdb.
+****************************************************************************/
+static int pack_devicemode(struct spoolss_DeviceMode *devmode, uint8 *buf, int buflen)
+{
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
+ int len = 0;
+
+ if (devmode) {
+ ndr_err = ndr_push_struct_blob(&blob, talloc_tos(),
+ devmode,
+ (ndr_push_flags_fn_t)
+ ndr_push_spoolss_DeviceMode);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(10, ("pack_devicemode: "
+ "error encoding spoolss_DeviceMode\n"));
+ goto done;
+ }
+ } else {
+ ZERO_STRUCT(blob);
+ }
+
+ len = tdb_pack(buf, buflen, "B", blob.length, blob.data);
+
+ if (devmode) {
+ DEBUG(8, ("Packed devicemode [%s]\n", devmode->formname));
+ }
+
+done:
+ return len;
+}
+
+/****************************************************************************
+ Unpack the devicemode to store it in a tdb.
+****************************************************************************/
+static int unpack_devicemode(TALLOC_CTX *mem_ctx,
+ const uint8 *buf, int buflen,
+ struct spoolss_DeviceMode **devmode)
+{
+ struct spoolss_DeviceMode *dm;
+ enum ndr_err_code ndr_err;
+ char *data = NULL;
+ int data_len = 0;
+ DATA_BLOB blob;
+ int len = 0;
+
+ *devmode = NULL;
+
+ len = tdb_unpack(buf, buflen, "B", &data_len, &data);
+ if (!data) {
+ return len;
+ }
+
+ dm = talloc_zero(mem_ctx, struct spoolss_DeviceMode);
+ if (!dm) {
+ goto done;
+ }
+
+ blob = data_blob_const(data, data_len);
+
+ ndr_err = ndr_pull_struct_blob(&blob, dm, dm,
+ (ndr_pull_flags_fn_t)ndr_pull_spoolss_DeviceMode);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(10, ("unpack_devicemode: "
+ "error parsing spoolss_DeviceMode\n"));
+ goto done;
+ }
+
+ DEBUG(8, ("Unpacked devicemode [%s](%s)\n",
+ dm->devicename, dm->formname));
+ if (dm->driverextra_data.data) {
+ DEBUG(8, ("with a private section of %d bytes\n",
+ dm->__driverextra_length));
+ }
+
+ *devmode = dm;
+
+done:
+ SAFE_FREE(data);
+ return len;
+}
+
/***********************************************************************
unpack a pjob from a tdb buffer
***********************************************************************/