[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha6-849-gc6f82b5
Volker Lendecke
vlendec at samba.org
Fri Feb 13 11:15:41 GMT 2009
The branch, master has been updated
via c6f82b525913856c9b483c8df43e5eecd896203b (commit)
via 5b6c4287638eb556270cec170e33004af24d7691 (commit)
via 0844cca1d5e4579b54af7d03509f3f97fac43bdc (commit)
from e7f7ed8bf6281ef01aca53ea44acdd4af4c51aa7 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit c6f82b525913856c9b483c8df43e5eecd896203b
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 13 11:49:17 2009 +0100
Remove the s4 version of smbspool.c
commit 5b6c4287638eb556270cec170e33004af24d7691
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 13 11:17:42 2009 +0100
Fix an uninitialized variable, introdued with 4d100f2f
commit 0844cca1d5e4579b54af7d03509f3f97fac43bdc
Author: Volker Lendecke <vl at samba.org>
Date: Fri Feb 13 10:56:34 2009 +0100
Replace get_myname() with the talloc version from v3-3-test
-----------------------------------------------------------------------
Summary of changes:
lib/util/util.c | 26 ++--
lib/util/util.h | 4 +-
source3/client/smbspool.c | 2 +-
source3/include/proto.h | 2 +-
source3/lib/util.c | 31 +----
source3/nmbd/nmbd_processlogon.c | 2 +-
source3/rpc_client/cli_pipe.c | 2 +-
source3/torture/torture.c | 2 +-
source3/utils/ntlm_auth.c | 2 +-
source4/client/smbspool.c | 353 --------------------------------------
source4/param/loadparm.c | 4 +-
11 files changed, 22 insertions(+), 408 deletions(-)
delete mode 100644 source4/client/smbspool.c
Changeset truncated at 500 lines:
diff --git a/lib/util/util.c b/lib/util/util.c
index 40ac7f7..988d8f9 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -192,34 +192,30 @@ _PUBLIC_ void msleep(unsigned int t)
}
/**
- Get my own name, return in malloc'ed storage.
+ Get my own name, return in talloc'ed storage.
**/
-_PUBLIC_ char *get_myname(void)
+_PUBLIC_ char *get_myname(TALLOC_CTX *ctx)
{
- char *hostname;
char *p;
-
- hostname = (char *)malloc(MAXHOSTNAMELEN+1);
- *hostname = 0;
+ char hostname[HOST_NAME_MAX];
/* get my host name */
- if (gethostname(hostname, MAXHOSTNAMELEN+1) == -1) {
+ if (gethostname(hostname, sizeof(hostname)) == -1) {
DEBUG(0,("gethostname failed\n"));
- free(hostname);
return NULL;
- }
+ }
/* Ensure null termination. */
- hostname[MAXHOSTNAMELEN] = '\0';
+ hostname[sizeof(hostname)-1] = '\0';
/* split off any parts after an initial . */
- p = strchr(hostname, '.');
-
- if (p != NULL)
+ p = strchr_m(hostname, '.');
+ if (p) {
*p = 0;
-
- return hostname;
+ }
+
+ return talloc_strdup(ctx, hostname);
}
/**
diff --git a/lib/util/util.h b/lib/util/util.h
index dced557..7873f0e 100644
--- a/lib/util/util.h
+++ b/lib/util/util.h
@@ -536,9 +536,9 @@ _PUBLIC_ int set_blocking(int fd, bool set);
_PUBLIC_ void msleep(unsigned int t);
/**
- Get my own name, return in malloc'ed storage.
+ Get my own name, return in talloc'ed storage.
**/
-_PUBLIC_ char* get_myname(void);
+_PUBLIC_ char* get_myname(TALLOC_CTX *mem_ctx);
/**
Return true if a string could be a pure IP address.
diff --git a/source3/client/smbspool.c b/source3/client/smbspool.c
index 7943cf5..a276353 100644
--- a/source3/client/smbspool.c
+++ b/source3/client/smbspool.c
@@ -485,7 +485,7 @@ smb_connect(const char *workgroup, /* I - Workgroup */
/*
* Get the names and addresses of the client and server...
*/
- myname = talloc_get_myname(talloc_tos());
+ myname = get_myname(talloc_tos());
if (!myname) {
return NULL;
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 7ad063e..3410472 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1154,7 +1154,7 @@ void *Realloc(void *p, size_t size, bool free_old_on_error);
void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
void *element, void *_array, uint32 *num_elements,
ssize_t *array_size);
-char *talloc_get_myname(TALLOC_CTX *ctx);
+char *get_myname(TALLOC_CTX *ctx);
char *get_mydnsdomname(TALLOC_CTX *ctx);
int interpret_protocol(const char *str,int def);
char *automount_lookup(TALLOC_CTX *ctx, const char *user_name);
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 68d3322..6079e71 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1209,35 +1209,6 @@ void add_to_large_array(TALLOC_CTX *mem_ctx, size_t element_size,
}
/****************************************************************************
- Get my own name and IP.
-****************************************************************************/
-
-char *talloc_get_myname(TALLOC_CTX *ctx)
-{
- char *p;
- char hostname[HOST_NAME_MAX];
-
- *hostname = 0;
-
- /* get my host name */
- if (gethostname(hostname, sizeof(hostname)) == -1) {
- DEBUG(0,("gethostname failed\n"));
- return False;
- }
-
- /* Ensure null termination. */
- hostname[sizeof(hostname)-1] = '\0';
-
- /* split off any parts after an initial . */
- p = strchr_m(hostname,'.');
- if (p) {
- *p = 0;
- }
-
- return talloc_strdup(ctx, hostname);
-}
-
-/****************************************************************************
Get my own domain name, or "" if we have none.
****************************************************************************/
@@ -2237,7 +2208,7 @@ char *myhostname(void)
if (ret == NULL) {
/* This is cached forever so
* use talloc_autofree_context() ctx. */
- ret = talloc_get_myname(talloc_autofree_context());
+ ret = get_myname(talloc_autofree_context());
}
return ret;
}
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index a4ef528..59a2ca4 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -442,7 +442,7 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
("get_mydnsdomname failed.\n"));
return;
}
- hostname = talloc_get_myname(talloc_tos());
+ hostname = get_myname(talloc_tos());
if (!hostname) {
DEBUG(2,
("get_myname failed.\n"));
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 2841ff0..24dbcb0 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -3417,7 +3417,7 @@ NTSTATUS rpc_pipe_open_ncalrpc(TALLOC_CTX *mem_ctx, const char *socket_path,
result->transfer_syntax = ndr_transfer_syntax;
result->dispatch = cli_do_rpc_ndr;
- result->desthost = talloc_get_myname(result);
+ result->desthost = get_myname(result);
result->srv_name_slash = talloc_asprintf_strupper_m(
result, "\\\\%s", result->desthost);
if ((result->desthost == NULL) || (result->srv_name_slash == NULL)) {
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 9cf41d8..db89b05 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -5862,7 +5862,7 @@ static void usage(void)
*p = 0;
fstrcpy(share, p+1);
- fstrcpy(myname, talloc_get_myname(talloc_tos()));
+ fstrcpy(myname, get_myname(talloc_tos()));
if (!*myname) {
fprintf(stderr, "Failed to get my hostname.\n");
return 1;
diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c
index ab5a743..9bc0c60 100644
--- a/source3/utils/ntlm_auth.c
+++ b/source3/utils/ntlm_auth.c
@@ -523,7 +523,7 @@ static NTSTATUS winbind_pw_check(struct ntlmssp_state *ntlmssp_state, DATA_BLOB
{
static const char zeros[16] = { 0, };
NTSTATUS nt_status;
- char *error_string;
+ char *error_string = NULL;
uint8 lm_key[8];
uint8 user_sess_key[16];
char *unix_name = NULL;
diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c
deleted file mode 100644
index df867d5..0000000
--- a/source4/client/smbspool.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- SMB backend for the Common UNIX Printing System ("CUPS")
- Copyright 1999 by Easy Software Products
- Copyright Andrew Tridgell 1994-1998
- Copyright Andrew Bartlett 2002
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.h"
-
-/*
- * Local functions...
- */
-
-static void list_devices(void);
-static struct smbcli_state *smb_connect(const char *, const char *, const char **, const char *, const char *, const char *);
-static int smb_print(struct smbcli_state *, char *, FILE *);
-
-
-/*
- * 'main()' - Main entry for SMB backend.
- */
-
- int /* O - Exit status */
- main(int argc, /* I - Number of command-line arguments */
- char *argv[]) /* I - Command-line arguments */
-{
- int i; /* Looping var */
- int copies; /* Number of copies */
- char uri[1024], /* URI */
- *sep, /* Pointer to separator */
- *password; /* Password */
- const char *username, /* Username */
- *server, /* Server name */
- *printer; /* Printer name */
- const char *workgroup; /* Workgroup */
- FILE *fp; /* File to print */
- int status=0; /* Status of LPD job */
- struct smbcli_state *cli; /* SMB interface */
- struct loadparm_context *lp_ctx;
-
- /* we expect the URI in argv[0]. Detect the case where it is in argv[1] and cope */
- if (argc > 2 && strncmp(argv[0],"smb://", 6) && !strncmp(argv[1],"smb://", 6)) {
- argv++;
- argc--;
- }
-
- if (argc == 1)
- {
- /*
- * NEW! In CUPS 1.1 the backends are run with no arguments to list the
- * available devices. These can be devices served by this backend
- * or any other backends (i.e. you can have an SNMP backend that
- * is only used to enumerate the available network printers... :)
- */
-
- list_devices();
- return (0);
- }
-
- if (argc < 6 || argc > 7)
- {
- fprintf(stderr, "Usage: %s [DEVICE_URI] job-id user title copies options [file]\n",
- argv[0]);
- fputs(" The DEVICE_URI environment variable can also contain the\n", stderr);
- fputs(" destination printer:\n", stderr);
- fputs("\n", stderr);
- fputs(" smb://[username:password@][workgroup/]server/printer\n", stderr);
- return (1);
- }
-
- /*
- * If we have 7 arguments, print the file named on the command-line.
- * Otherwise, print data from stdin...
- */
-
- if (argc == 6)
- {
- /*
- * Print from Copy stdin to a temporary file...
- */
-
- fp = stdin;
- copies = 1;
- }
- else if ((fp = fopen(argv[6], "rb")) == NULL)
- {
- perror("ERROR: Unable to open print file");
- return (1);
- }
- else
- copies = atoi(argv[4]);
-
- /*
- * Find the URI...
- */
-
- if (strncmp(argv[0], "smb://", 6) == 0)
- strncpy(uri, argv[0], sizeof(uri) - 1);
- else if (getenv("DEVICE_URI") != NULL)
- strncpy(uri, getenv("DEVICE_URI"), sizeof(uri) - 1);
- else
- {
- fputs("ERROR: No device URI found in argv[0] or DEVICE_URI environment variable!\n", stderr);
- return (1);
- }
-
- uri[sizeof(uri) - 1] = '\0';
-
- /*
- * Extract the destination from the URI...
- */
-
- if ((sep = strrchr_m(uri, '@')) != NULL)
- {
- username = uri + 6;
- *sep++ = '\0';
-
- server = sep;
-
- /*
- * Extract password as needed...
- */
-
- if ((password = strchr_m(username, ':')) != NULL)
- *password++ = '\0';
- else
- password = "";
- }
- else
- {
- username = "";
- password = "";
- server = uri + 6;
- }
-
- if ((sep = strchr_m(server, '/')) == NULL)
- {
- fputs("ERROR: Bad URI - need printer name!\n", stderr);
- return (1);
- }
-
- *sep++ = '\0';
- printer = sep;
-
- if ((sep = strchr_m(printer, '/')) != NULL)
- {
- /*
- * Convert to smb://[username:password@]workgroup/server/printer...
- */
-
- *sep++ = '\0';
-
- workgroup = server;
- server = printer;
- printer = sep;
- }
- else
- workgroup = NULL;
-
- /*
- * Setup the SAMBA server state...
- */
-
- setup_logging(argv[0], DEBUG_STDOUT);
-
- lp_ctx = loadparm_init(talloc_autofree_context());
-
- if (!lp_load(lp_ctx, dyn_CONFIGFILE)) {
- fprintf(stderr, "ERROR: Can't load %s - run testparm to debug it\n", lp_config_file());
- return (1);
- }
-
- if (workgroup == NULL)
- workgroup = lp_workgroup(lp_ctx);
-
- do
- {
- if ((cli = smb_connect(workgroup, server, lp_smb_ports(lp_ctx), printer, username, password)) == NULL)
- {
- if (getenv("CLASS") == NULL)
- {
- fprintf(stderr, "ERROR: Unable to connect to SAMBA host, will retry in 60 seconds...");
- sleep (60);
- }
- else
- {
- fprintf(stderr, "ERROR: Unable to connect to SAMBA host, trying next printer...");
- return (1);
- }
- }
- }
- while (cli == NULL);
-
- /*
- * Now that we are connected to the server, ignore SIGTERM so that we
- * can finish out any page data the driver sends (e.g. to eject the
- * current page... Only ignore SIGTERM if we are printing data from
- * stdin (otherwise you can't cancel raw jobs...)
- */
-
- if (argc < 7)
- CatchSignal(SIGTERM, SIG_IGN);
-
- /*
- * Queue the job...
- */
-
- for (i = 0; i < copies; i ++)
- if ((status = smb_print(cli, argv[3] /* title */, fp)) != 0)
- break;
-
- talloc_free(cli);
-
- /*
- * Return the queue status...
- */
-
- return (status);
-}
-
-
-/*
- * 'list_devices()' - List the available printers seen on the network...
- */
-
-static void
-list_devices(void)
-{
- /*
- * Eventually, search the local workgroup for available hosts and printers.
- */
-
- puts("network smb \"Unknown\" \"Windows Printer via SAMBA\"");
-}
-
-
-/*
- * 'smb_connect()' - Return a connection to a server.
- */
-
-static struct smbcli_state * /* O - SMB connection */
-smb_connect(const char *workgroup, /* I - Workgroup */
- const char *server, /* I - Server */
- const char **ports, /* I - Ports */
- const char *share, /* I - Printer */
- const char *username, /* I - Username */
- const char *password) /* I - Password */
-{
- struct smbcli_state *c; /* New connection */
- char *myname; /* Client name */
- NTSTATUS nt_status;
-
- /*
- * Get the names and addresses of the client and server...
- */
-
- myname = get_myname();
-
- nt_status = smbcli_full_connection(NULL, &c, myname, server, ports, share,
- NULL, username, workgroup, password, NULL);
-
- free(myname);
- if (!NT_STATUS_IS_OK(nt_status)) {
- fprintf(stderr, "ERROR: Connection failed with error %s\n", nt_errstr(nt_status));
- return NULL;
- }
-
- /*
- * Return the new connection...
- */
-
- return (c);
-}
-
-
-/*
- * 'smb_print()' - Queue a job for printing using the SMB protocol.
- */
-
-static int /* O - 0 = success, non-0 = failure */
-smb_print(struct smbcli_state *cli, /* I - SMB connection */
- char *title, /* I - Title/job name */
- FILE *fp) /* I - File to print */
-{
- int fnum; /* File number */
- int nbytes, /* Number of bytes read */
- tbytes; /* Total bytes read */
--
Samba Shared Repository
More information about the samba-cvs
mailing list