summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2003-11-07 10:11:48 +0000
committerVolker Lendecke <vlendec@samba.org>2003-11-07 10:11:48 +0000
commit88b0120e5668bc2092563bbaa35928e5cabe29d9 (patch)
treecbcb88def10526a862e9c67cf1805e7d8222a297 /source3
parentd5573ccde3b5c39eb9a4637d5a9d7a95b66d86e3 (diff)
downloadsamba-88b0120e5668bc2092563bbaa35928e5cabe29d9.tar.gz
samba-88b0120e5668bc2092563bbaa35928e5cabe29d9.tar.bz2
samba-88b0120e5668bc2092563bbaa35928e5cabe29d9.zip
Implement %i-Macro for the locally used IP address. With this you can again
have virtual hosts with different configurations on a single smbd even on port 445. Volker (This used to be commit 3a7c8c4f0e7fcfc2e20e1ad5e4b8e3c215ef1f0d)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/substitute.c3
-rw-r--r--source3/lib/util_sock.c28
2 files changed, 31 insertions, 0 deletions
diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c
index 923afd989f..ee342964d0 100644
--- a/source3/lib/substitute.c
+++ b/source3/lib/substitute.c
@@ -363,6 +363,9 @@ void standard_sub_basic(const char *smb_name, char *str,size_t len)
case 'I' :
string_sub(p,"%I", client_addr(),l);
break;
+ case 'i' :
+ string_sub(p,"%i", client_socket_addr(),l);
+ break;
case 'L' :
if (local_machine_name && *local_machine_name)
string_sub(p,"%L", local_machine_name,l);
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index bdd167b04d..1d62da53c5 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -802,6 +802,11 @@ char *client_addr(void)
return get_peer_addr(client_fd);
}
+char *client_socket_addr(void)
+{
+ return get_socket_addr(client_fd);
+}
+
struct in_addr *client_inaddr(struct sockaddr *sa)
{
struct sockaddr_in *sockin = (struct sockaddr_in *) (sa);
@@ -941,6 +946,29 @@ char *get_peer_addr(int fd)
return addr_buf;
}
+char *get_socket_addr(int fd)
+{
+ struct sockaddr sa;
+ struct sockaddr_in *sockin = (struct sockaddr_in *) (&sa);
+ int length = sizeof(sa);
+ static fstring addr_buf;
+
+ fstrcpy(addr_buf,"0.0.0.0");
+
+ if (fd == -1) {
+ return addr_buf;
+ }
+
+ if (getsockname(fd, &sa, &length) < 0) {
+ DEBUG(0,("getpeername failed. Error was %s\n", strerror(errno) ));
+ return addr_buf;
+ }
+
+ fstrcpy(addr_buf,(char *)inet_ntoa(sockin->sin_addr));
+
+ return addr_buf;
+}
+
/*******************************************************************
Create protected unix domain socket.