Commit 3373f208 3373f208e659bfaf01956ec4b953b555cf1cafad by Sergey Poznyakoff

Removed virtual.c

1 parent 69cc8155
...@@ -7,7 +7,7 @@ EXTRA_PROGRAMS = popauth ...@@ -7,7 +7,7 @@ EXTRA_PROGRAMS = popauth
7 7
8 pop3d_SOURCES = apop.c auth.c capa.c dele.c extra.c pop3d.c pop3d.h \ 8 pop3d_SOURCES = apop.c auth.c capa.c dele.c extra.c pop3d.c pop3d.h \
9 list.c lock.c noop.c quit.c retr.c rset.c stat.c signal.c top.c uidl.c \ 9 list.c lock.c noop.c quit.c retr.c rset.c stat.c signal.c top.c uidl.c \
10 user.c virtual.c 10 user.c
11 11
12 pop3d_LDADD = ../mailbox/libmailbox.la @AUTHLIBS@ ../lib/libmailutils.la 12 pop3d_LDADD = ../mailbox/libmailbox.la @AUTHLIBS@ ../lib/libmailutils.la
13 13
......
1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
17
18
19 #include "pop3d.h"
20
21 #ifdef USE_VIRTUAL_DOMAINS
22
23 struct passwd *
24 getpwnam_ip_virtual (const char *u)
25 {
26 struct sockaddr_in addr;
27 struct passwd *pw = NULL;
28 int len = sizeof (addr);
29 if (getsockname (fileno (ifile), (struct sockaddr *)&addr, &len) == 0)
30 {
31 char *ip;
32 char *user;
33 ip = inet_ntoa (addr.sin_addr);
34 user = malloc (strlen (ip) + strlen (u) + 2);
35 if (user)
36 {
37 sprintf (user, "%s!%s", u, ip);
38 pw = getpwnam_virtual (user);
39 free (user);
40 }
41 }
42 return pw;
43 }
44
45 struct passwd *
46 getpwnam_host_virtual (const char *u)
47 {
48 struct sockaddr_in addr;
49 struct passwd *pw = NULL;
50 int len = sizeof (addr);
51 if (getsockname (fileno (ifile), (struct sockaddr *)&addr, &len) == 0)
52 {
53 struct hostent *info = gethostbyaddr ((char *)&addr.sin_addr,
54 4, AF_INET);
55 if (info)
56 {
57 char *user = malloc (strlen (info->h_name) + strlen (u) + 2);
58 if (user)
59 {
60 sprintf (user, "%s!%s", u, info->h_name);
61 pw = getpwnam_virtual (user);
62 free (user);
63 }
64 }
65 }
66 return pw;
67 }
68
69 #endif