parameter to amu_get_myaddress().
* conf/transp/transp_tli.c (amu_get_myaddress): resolve value of
localhost_address amd.conf parameter, if defined (else default to
HOST_SELF_CONNECT).
Removed htonl() around socket address copying (I think it was
wrong) since plog("My IP address is...") in amd.c was printing
addresses wrong on Solaris x86..
* conf/transp/transp_sockets.c (amu_get_myaddress): comment out
old DEBUG code that warns if 127.0.0.1 isn't the same as what
get_myaddress() reports. Add code to resolve value of
localhost_address amd.conf parameter, if defined (else default to
127.0.0.1).
* amd/conf.c (gopt_localhost_address): new function to parse
amd.conf parameter localhost_address.
* amd/amd.h: global field to store amd.conf localhost_address
parameter.
* amd/amd.c (main): call amu_get_myaddress with global option,
which could have been set in amd.conf.
* NEWS, doc/am-utils.texi, scripts/amd.conf-sample,
scripts/amd.conf.5: document new option localhost_address.
+2004-01-21 Erez Zadok <ezk@cs.sunysb.edu>
+
+ * wire-test/wire-test.c, hlfsd/hlfsd.c (main): pass NULL as second
+ parameter to amu_get_myaddress().
+
+ * conf/transp/transp_tli.c (amu_get_myaddress): resolve value of
+ localhost_address amd.conf parameter, if defined (else default to
+ HOST_SELF_CONNECT).
+ Removed htonl() around socket address copying (I think it was
+ wrong) since plog("My IP address is...") in amd.c was printing
+ addresses wrong on Solaris x86..
+
+ * conf/transp/transp_sockets.c (amu_get_myaddress): comment out
+ old DEBUG code that warns if 127.0.0.1 isn't the same as what
+ get_myaddress() reports. Add code to resolve value of
+ localhost_address amd.conf parameter, if defined (else default to
+ 127.0.0.1).
+
+ * amd/conf.c (gopt_localhost_address): new function to parse
+ amd.conf parameter localhost_address.
+
+ * amd/amd.h: global field to store amd.conf localhost_address
+ parameter.
+
+ * amd/amd.c (main): call amu_get_myaddress with global option,
+ which could have been set in amd.conf.
+
+ * NEWS, doc/am-utils.texi, scripts/amd.conf-sample,
+ scripts/amd.conf.5: document new option localhost_address.
+
2004-01-20 Ion Badulescu <ionut@moisil.badula.org>
* amd/conf.c (gopt_nfs_allow_insecure_port): support function for
- minor new ports:
i386-pc-solaris2.10
- i386-unknown-freebsd4.8
+ i386-unknown-freebsd4.8
i386-unknown-freebsd4.9
i386-unknown-freebsd5.1 (5.1-RELEASE)
i386-unknown-freebsd5.2 (5.2-RELEASE)
sparc-sun-solaris2.10
x86_64-unknown-linux-rh2.9.5AS
+- new amd.conf parameter: localhost_address. Used to override the localhost
+ (often 127.0.0.1) address Amd uses to connect to for the local NFS server
+ and RPC server.
+
- fully support WebNFS as per RFC 2054. It now tries v3/TCP first, falling
back to v2/UDP if this doesn't work. The "webnfs" pseudo-mount options
has been renamed (again) to "public" to match Solaris 2.
* SUCH DAMAGE.
*
*
- * $Id: amd.c,v 1.25 2004/01/06 03:56:19 ezk Exp $
+ * $Id: amd.c,v 1.26 2004/01/22 05:01:06 ezk Exp $
*
*/
}
/*
- * Get our own IP address so that we
- * can mount the automounter.
+ * Get our own IP address so that we can mount the automounter. We pass
+ * localhost_address which could be used as the default localhost
+ * name/address in amu_get_myaddress().
*/
- amu_get_myaddress(&myipaddr);
+ amu_get_myaddress(&myipaddr, gopt.localhost_address);
plog(XLOG_INFO, "My ip addr is %s", inet_ntoa(myipaddr));
/* avoid hanging on other NFS servers if started elsewhere */
* SUCH DAMAGE.
*
*
- * $Id: amd.h,v 1.51 2004/01/21 03:42:12 ib42 Exp $
+ * $Id: amd.h,v 1.52 2004/01/22 05:01:06 ezk Exp $
*
*/
char *op_sys_vendor; /* name of OS vendor ${vendor} */
char *pid_file; /* PID file */
char *sub_domain; /* local domain */
+ char *localhost_address; /* localhost address (NULL means use 127.0.0.1) */
char *map_defaults; /* global map /default options */
char *map_options; /* global map options */
int map_reload_interval; /* map reload interval */
* SUCH DAMAGE.
*
*
- * $Id: conf.c,v 1.22 2004/01/21 03:42:12 ib42 Exp $
+ * $Id: conf.c,v 1.23 2004/01/22 05:01:06 ezk Exp $
*
*/
static int gopt_ldap_hostports(const char *val);
static int gopt_ldap_proto_version(const char *val);
static int gopt_local_domain(const char *val);
+static int gopt_localhost_address(const char *val);
static int gopt_log_file(const char *val);
static int gopt_log_options(const char *val);
static int gopt_map_defaults(const char *val);
{"ldap_hostports", gopt_ldap_hostports},
{"ldap_proto_version", gopt_ldap_proto_version},
{"local_domain", gopt_local_domain},
+ {"localhost_address", gopt_localhost_address},
{"log_file", gopt_log_file},
{"log_options", gopt_log_options},
{"map_defaults", gopt_map_defaults},
}
+static int
+gopt_localhost_address(const char *val)
+{
+ gopt.localhost_address = strdup((char *)val);
+ return 0;
+}
+
+
static int
gopt_ldap_base(const char *val)
{
* SUCH DAMAGE.
*
*
- * $Id: transp_sockets.c,v 1.27 2004/01/06 03:56:20 ezk Exp $
+ * $Id: transp_sockets.c,v 1.28 2004/01/22 05:01:06 ezk Exp $
*
* Socket specific utilities.
* -Erez Zadok <ezk@cs.columbia.edu>
* find the IP address that can be used to connect to the local host
*/
void
-amu_get_myaddress(struct in_addr *iap)
+amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost)
{
+ struct hostent *hp;
-#ifdef DEBUG
+#ifdef DEBUG_off
+#error this code is old and probably not useful any longer.
+#error Erez, Jan 21, 2004.
struct sockaddr_in sin;
/*
if (sin.sin_addr.s_addr != htonl(INADDR_LOOPBACK))
dlog("amu_get_myaddress: myaddress conflict (0x%x vs. 0x%lx)",
sin.sin_addr.s_addr, (u_long) htonl(INADDR_LOOPBACK));
-#endif /* DEBUG */
+#endif /* DEBUG_off */
+
+ if (preferred_localhost == NULL)
+ goto out;
+
+ /* if specified preferred locahost, then try to use it */
+ hp = gethostbyname(preferred_localhost);
+ if (hp == NULL) {
+ /* XXX: if hstrerror()/h_errno aren't portable, then need to port the next statement */
+ plog(XLOG_ERROR, "Unable to resolve localhost_address \"%s\" (%s): using default",
+ preferred_localhost, hstrerror(h_errno));
+ goto out;
+ }
+ if (hp->h_addr_list == NULL) {
+ plog(XLOG_ERROR, "localhost_address \"%s\" has no IP addresses: using default",
+ preferred_localhost);
+ goto out;
+ }
+ if (hp->h_addr_list[1] != NULL) {
+ plog(XLOG_ERROR, "localhost_address \"%s\" has more than one IP addresses: using first",
+ preferred_localhost);
+ goto out;
+ }
+ memmove((voidp) &iap->s_addr, (voidp) hp->h_addr_list[0], sizeof(iap->s_addr));
+ plog(XLOG_INFO, "localhost_address \"%s\" requested", preferred_localhost);
+ return;
+ out:
iap->s_addr = htonl(INADDR_LOOPBACK);
}
* SUCH DAMAGE.
*
*
- * $Id: transp_tli.c,v 1.20 2004/01/06 03:56:20 ezk Exp $
+ * $Id: transp_tli.c,v 1.21 2004/01/22 05:01:06 ezk Exp $
*
* TLI specific utilities.
* -Erez Zadok <ezk@cs.columbia.edu>
* find the IP address that can be used to connect to the local host
*/
void
-amu_get_myaddress(struct in_addr *iap)
+amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost)
{
int ret;
voidp handlep;
handlep = setnetconfig();
ncp = getnetconfig(handlep);
- service.h_host = HOST_SELF_CONNECT;
+ service.h_host = (preferred_localhost ? (char *) preferred_localhost : HOST_SELF_CONNECT);
service.h_serv = (char *) NULL;
ret = netdir_getbyname(ncp, &service, &addrs);
* host. Maybe something can be done with those.
*/
struct sockaddr_in *sinp = (struct sockaddr_in *) addrs->n_addrs[0].buf;
- iap->s_addr = htonl(sinp->sin_addr.s_addr);
+ if (preferred_localhost)
+ plog(XLOG_INFO, "localhost_address \"%s\" requested", preferred_localhost);
+ iap->s_addr = sinp->sin_addr.s_addr; /* XXX: used to be htonl() */
}
endnetconfig(handlep); /* free's up internal resources too */
@c
@c %W% (Berkeley) %G%
@c
-@c $Id: am-utils.texi,v 1.82 2004/01/21 03:42:12 ib42 Exp $
+@c $Id: am-utils.texi,v 1.83 2004/01/22 05:01:06 ezk Exp $
@c
@setfilename am-utils.info
* ldap_hostports Parameter::
* ldap_proto_version Parameter::
* local_domain Parameter::
+* localhost_address Parameter::
* log_file Parameter::
* log_options Parameter::
* map_reload_interval Parameter::
With a value of 3 will use LDAPv3 protocol.
@c ----------------------------------------------------------------
-@node local_domain Parameter, log_file Parameter, ldap_proto_version Parameter, Global Parameters
+@node local_domain Parameter, localhost_address Parameter, ldap_proto_version Parameter, Global Parameters
@comment node-name, next, previous, up
@subsection @t{local_domain} Parameter
@cindex local_domain Parameter
component of the fully-qualified host name.
@c ----------------------------------------------------------------
-@node log_file Parameter, log_options Parameter, local_domain Parameter, Global Parameters
+@node localhost_address Parameter, log_file Parameter, local_domain Parameter, Global Parameters
+@comment node-name, next, previous, up
+@subsection @t{localhost_address} Parameter
+@cindex localhost_address Parameter
+
+(type=string, default to localhost or 127.0.0.1). Specify the name or
+IP address for @i{Amd} to use when connecting the sockets for the
+local NFS server and the RPC server. This defaults to 127.0.0.1 or
+whatever the host reports as its local address. This parameter is
+useful on hosts with multiple addresses where you want to force
+@i{Amd} to connect to a specific address.
+
+@c ----------------------------------------------------------------
+@node log_file Parameter, log_options Parameter, localhost_address Parameter, Global Parameters
@comment node-name, next, previous, up
@subsection @t{log_file} Parameter
@cindex log_file Parameter
* SUCH DAMAGE.
*
*
- * $Id: hlfsd.c,v 1.26 2004/01/06 03:56:20 ezk Exp $
+ * $Id: hlfsd.c,v 1.27 2004/01/22 05:01:06 ezk Exp $
*
* HLFSD was written at Columbia University Computer Science Department, by
* Erez Zadok <ezk@cs.columbia.edu> and Alexander Dupuy <dupuy@cs.columbia.edu>
/* some systems don't have a mount type, but a mount flag */
#ifndef HAVE_TRANSPORT_TYPE_TLI
- amu_get_myaddress(&localsocket.sin_addr);
+ amu_get_myaddress(&localsocket.sin_addr, NULL);
localsocket.sin_family = AF_INET;
localsocket.sin_port = htons(nfsxprt->xp_port);
#endif /* not HAVE_TRANSPORT_TYPE_TLI */
* SUCH DAMAGE.
*
*
- * $Id: am_utils.h,v 1.56 2004/01/06 03:56:20 ezk Exp $
+ * $Id: am_utils.h,v 1.57 2004/01/22 05:01:06 ezk Exp $
*
*/
extern mntlist *read_mtab(char *, const char *);
extern struct sockaddr_in *amu_svc_getcaller(SVCXPRT *xprt);
extern time_t time(time_t *);
-extern void amu_get_myaddress(struct in_addr *iap);
+extern void amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost);
extern void amu_release_controlling_tty(void);
extern void compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp);
extern void discard_mntlist(mntlist *mp);
use_tcpwrappers = yes | no
# allow NFS requests from insecure (>=1024) ports
nfs_allow_insecure_port = yes | no
+# address used for local NFS mount and RPC server (default to localhost)
+localhost_address = foo.example.com | 192.168.1.2
##############################################################################
# DEFINE AN AMD MOUNT POINT
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: amd.conf.5,v 1.26 2004/01/21 03:42:12 ib42 Exp $
+.\" $Id: amd.conf.5,v 1.27 2004/01/22 05:01:06 ezk Exp $
.\"
.TH AMD.CONF 5 "7 August 1997"
.SH NAME
the domain name is determined from the hostname, by removing the first
component of the fully-qualified host name.
+.TP
+.BR localhost_address " (string, default to localhost or 127.0.0.1)"
+Specify the name or IP address for amd to use when connecting the sockets
+for the local NFS server and the RPC server. This defaults to 127.0.0.1 or
+whatever the host reports as its local address. This parameter is useful on
+hosts with multiple addresses where you want to force amd to connect to a
+specific address.
+
.TP
.BR log_file " (string, default=/dev/stderr)"
Same as the
* SUCH DAMAGE.
*
*
- * $Id: wire-test.c,v 1.10 2004/01/06 03:56:21 ezk Exp $
+ * $Id: wire-test.c,v 1.11 2004/01/22 05:01:06 ezk Exp $
*
*/
}
/* also print my IP address */
- amu_get_myaddress(&myipaddr);
+ amu_get_myaddress(&myipaddr, NULL);
fprintf(stderr, "My IP address is 0x%x.\n", (unsigned int) htonl(myipaddr.s_addr));
/*