[SCM] Samba Shared Repository - branch v3-2-test updated

Jeremy Allison jra at samba.org
Thu Oct 11 23:20:06 GMT 2007


The branch, v3-2-test has been updated
       via  baf1f52e34ae2465a7a34be1065da29ed97e7bea (commit)
      from  142b80bf1542f212dff66a3661c13f3f6845067f (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit baf1f52e34ae2465a7a34be1065da29ed97e7bea
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Oct 11 15:36:13 2007 -0700

    Add const to the get_peer_addr() and get_socket_addr()
    calls. Use the IPv6 varient for get_peer_addr().
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source/lib/util_sock.c         |   31 ++++++++++++++++---------------
 source/printing/print_cups.c   |    2 +-
 source/printing/print_iprint.c |    4 ++--
 source/smbd/session.c          |    2 +-
 source/smbd/sesssetup.c        |    3 ++-
 source/web/cgi.c               |    4 ++--
 6 files changed, 24 insertions(+), 22 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c
index 7a1a05e..5a96bb7 100644
--- a/source/lib/util_sock.c
+++ b/source/lib/util_sock.c
@@ -388,7 +388,7 @@ void client_setfd(int fd)
  Return a static string of an IP address (IPv4 or IPv6).
 ****************************************************************************/
 
-static char *get_socket_addr(int fd)
+static const char *get_socket_addr(int fd)
 {
 	struct sockaddr_storage sa;
 	socklen_t length = sizeof(sa);
@@ -444,17 +444,17 @@ static int get_socket_port(int fd)
 	return -1;
 }
 
-char *client_name(void)
+const char *client_name(void)
 {
 	return get_peer_name(client_fd,false);
 }
 
-char *client_addr(void)
+const char *client_addr(void)
 {
 	return get_peer_addr(client_fd);
 }
 
-char *client_socket_addr(void)
+const char *client_socket_addr(void)
 {
 	return get_socket_addr(client_fd);
 }
@@ -1598,14 +1598,14 @@ static bool matchname(char *remotehost,struct in_addr  addr)
  Return the DNS name of the remote end of a socket.
 ******************************************************************/
 
-char *get_peer_name(int fd, bool force_lookup)
+const char *get_peer_name(int fd, bool force_lookup)
 {
 	static pstring name_buf;
 	pstring tmp_name;
 	static fstring addr_buf;
 	struct hostent *hp;
 	struct in_addr addr;
-	char *p;
+	const char *p;
 
 	/* reverse lookups can be *very* expensive, and in many
 	   situations won't work because many networks don't link dhcp
@@ -1659,27 +1659,28 @@ char *get_peer_name(int fd, bool force_lookup)
  Return the IP addr of the remote end of a socket as a string.
  ******************************************************************/
 
-char *get_peer_addr(int fd)
+const char *get_peer_addr(int fd)
 {
-	struct sockaddr sa;
-	struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
-	socklen_t length = sizeof(sa);
-	static fstring addr_buf;
+	struct sockaddr_storage ss;
+	socklen_t length = sizeof(ss);
+	static char addr_buf[INET6_ADDRSTRLEN];
 
-	fstrcpy(addr_buf,"0.0.0.0");
+	safe_strcpy(addr_buf,"0.0.0.0",sizeof(addr_buf)-1);
 
 	if (fd == -1) {
 		return addr_buf;
 	}
 
-	if (getpeername(fd, &sa, &length) < 0) {
+	if (getpeername(fd, (struct sockaddr *)&ss, &length) < 0) {
 		DEBUG(0,("getpeername failed. Error was %s\n",
 					strerror(errno) ));
 		return addr_buf;
 	}
 
-	fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
-
+	print_sockaddr(addr_buf,
+			sizeof(addr_buf),
+			&ss,
+			length);
 	return addr_buf;
 }
 
diff --git a/source/printing/print_cups.c b/source/printing/print_cups.c
index 8f1f06e..d95b08c 100644
--- a/source/printing/print_cups.c
+++ b/source/printing/print_cups.c
@@ -563,7 +563,7 @@ static int cups_job_submit(int snum, struct printjob *pjob)
 			*response = NULL;	/* IPP Response */
 	cups_lang_t	*language = NULL;	/* Default language */
 	char		uri[HTTP_MAX_URI]; /* printer-uri attribute */
-	char 		*clientname = NULL; 	/* hostname of client for job-originating-host attribute */
+	const char 	*clientname = NULL; 	/* hostname of client for job-originating-host attribute */
 	pstring		new_jobname;
 	int		num_options = 0; 
 	cups_option_t 	*options = NULL;
diff --git a/source/printing/print_iprint.c b/source/printing/print_iprint.c
index f2b2746..8209592 100644
--- a/source/printing/print_iprint.c
+++ b/source/printing/print_iprint.c
@@ -726,7 +726,7 @@ static int iprint_job_submit(int snum, struct printjob *pjob)
 	ipp_attribute_t	*attr;		/* Current attribute */
 	cups_lang_t	*language = NULL;	/* Default language */
 	char		uri[HTTP_MAX_URI]; /* printer-uri attribute */
-	char 		*clientname = NULL; 	/* hostname of client for job-originating-host attribute */
+	const char	*clientname = NULL; 	/* hostname of client for job-originating-host attribute */
 
 	DEBUG(5,("iprint_job_submit(%d, %p (%d))\n", snum, pjob, pjob->sysjob));
 
@@ -782,7 +782,7 @@ static int iprint_job_submit(int snum, struct printjob *pjob)
 	if (strcmp(clientname, "UNKNOWN") == 0) {
 		clientname = client_addr();
 	}
-
+	
 	ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
 	             "job-originating-host-name", NULL,
 	             clientname);
diff --git a/source/smbd/session.c b/source/smbd/session.c
index 8dd321f..54d2ddf 100644
--- a/source/smbd/session.c
+++ b/source/smbd/session.c
@@ -65,7 +65,7 @@ BOOL session_claim(user_struct *vuser)
 	struct sessionid sessionid;
 	struct server_id pid = procid_self();
 	fstring keystr;
-	char * hostname;
+	const char * hostname;
 	struct db_context *ctx;
 	struct db_record *rec;
 	NTSTATUS status;
diff --git a/source/smbd/sesssetup.c b/source/smbd/sesssetup.c
index 20021ec..a2f24c6 100644
--- a/source/smbd/sesssetup.c
+++ b/source/smbd/sesssetup.c
@@ -1314,7 +1314,8 @@ static void setup_new_vc_session(void)
 	invalidate_all_vuids();
 #endif
 	if (lp_reset_on_zero_vc()) {
-		connections_forall(shutdown_other_smbds, client_addr());
+		connections_forall(shutdown_other_smbds,
+				CONST_DISCARD(void *,client_addr()));
 	}
 }
 
diff --git a/source/web/cgi.c b/source/web/cgi.c
index 9af4337..0e362ea 100644
--- a/source/web/cgi.c
+++ b/source/web/cgi.c
@@ -633,7 +633,7 @@ const char *cgi_pathinfo(void)
 /***************************************************************************
 return the hostname of the client
   ***************************************************************************/
-char *cgi_remote_host(void)
+const char *cgi_remote_host(void)
 {
 	if (inetd_server) {
 		return get_peer_name(1,False);
@@ -644,7 +644,7 @@ char *cgi_remote_host(void)
 /***************************************************************************
 return the hostname of the client
   ***************************************************************************/
-char *cgi_remote_addr(void)
+const char *cgi_remote_addr(void)
 {
 	if (inetd_server) {
 		return get_peer_addr(1);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list