summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/lib/util_sock.c31
-rw-r--r--source3/printing/print_cups.c2
-rw-r--r--source3/printing/print_iprint.c4
-rw-r--r--source3/smbd/session.c2
-rw-r--r--source3/smbd/sesssetup.c3
-rw-r--r--source3/web/cgi.c4
6 files changed, 24 insertions, 22 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 7a1a05ec29..5a96bb79d6 100644
--- a/source3/lib/util_sock.c
+++ b/source3/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/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 8f1f06e7ef..d95b08c3c6 100644
--- a/source3/printing/print_cups.c
+++ b/source3/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/source3/printing/print_iprint.c b/source3/printing/print_iprint.c
index f2b27460be..82095925b8 100644
--- a/source3/printing/print_iprint.c
+++ b/source3/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/source3/smbd/session.c b/source3/smbd/session.c
index 8dd321fad7..54d2ddf721 100644
--- a/source3/smbd/session.c
+++ b/source3/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/source3/smbd/sesssetup.c b/source3/smbd/sesssetup.c
index 20021ec7f7..a2f24c66d2 100644
--- a/source3/smbd/sesssetup.c
+++ b/source3/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/source3/web/cgi.c b/source3/web/cgi.c
index 9af4337a21..0e362ea245 100644
--- a/source3/web/cgi.c
+++ b/source3/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);