summaryrefslogtreecommitdiffstats
path: root/contrib/amd/amq
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2007-12-05 15:48:03 +0000
committerobrien <obrien@FreeBSD.org>2007-12-05 15:48:03 +0000
commitea691ecd980d2860f0b39e9e504de4da404806fd (patch)
treefa83b3bb0660890a21b550fa1f334b151bf098f9 /contrib/amd/amq
parentc06a2e613662fc6ce10145b41762be8f8ab22ba4 (diff)
downloadFreeBSD-src-ea691ecd980d2860f0b39e9e504de4da404806fd.zip
FreeBSD-src-ea691ecd980d2860f0b39e9e504de4da404806fd.tar.gz
Virgin import of AMD (am-utils) v6.1.5
Sponsored by: Juniper Networks
Diffstat (limited to 'contrib/amd/amq')
-rw-r--r--contrib/amd/amq/amq.856
-rw-r--r--contrib/amd/amq/amq.c55
-rw-r--r--contrib/amd/amq/amq.h6
-rw-r--r--contrib/amd/amq/amq_clnt.c37
-rw-r--r--contrib/amd/amq/amq_xdr.c24
-rw-r--r--contrib/amd/amq/pawd.122
-rw-r--r--contrib/amd/amq/pawd.c85
7 files changed, 165 insertions, 120 deletions
diff --git a/contrib/amd/amq/amq.8 b/contrib/amd/amq/amq.8
index 7ccfd7c..203a529 100644
--- a/contrib/amd/amq/amq.8
+++ b/contrib/amd/amq/amq.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-2004 Erez Zadok
+.\" Copyright (c) 1997-2006 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: amq.8,v 1.3.2.8 2004/01/06 03:15:16 ezk Exp $
+.\" $Id: amq.8,v 1.15.2.1 2006/01/02 18:48:24 ezk Exp $
.\"
.TH AMQ 8 "25 April 1989"
.SH NAME
@@ -192,26 +192,70 @@ using UDP (connectionless) transport only. Normally
will try TCP, and if that failed, will try UDP.
.SH FILES
-.PD 0
.TP 20
.B amq.x
.SM RPC
protocol description.
+
.SH CAVEATS
.B Amq
uses a Sun registered
.SM RPC
program number (300019 decimal) which may not
be in the /etc/rpc database.
+.PP
+If the TCP wrappers library is available, and the
+.B use_tcpwrappers
+global
+.B amd.conf
+option is set to ``yes'', then
+.B amd
+will verify that the host running
+.B amq
+is authorized to connect. The
+.I amd
+service name must used in the
+.B /etc/hosts.allow
+and
+.B /etc/hosts.deny
+files. For example, to allow only localhost to connect to
+.B amd,
+add this line to
+.B /etc/hosts.allow:
+.PP
+.RS
+amd: localhost
+.RE
+.PP
+and this line to
+.B /etc/hosts.deny:
+.PP
+.RS
+amd: ALL
+.RE
+
.SH "SEE ALSO"
.BR amd (8),
.BR ctl-amd (8),
-.BR amd.conf (5).
+.BR amd.conf (5),
+.BR hosts_access (5).
+.LP
+``am-utils''
+.BR info (1)
+entry.
+.LP
+.I "Linux NFS and Automounter Administration"
+by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001).
+.LP
+.I http://www.am-utils.org
+.LP
+.I "Amd \- The 4.4 BSD Automounter"
+
.SH AUTHORS
Jan-Simon Pendry <jsp@doc.ic.ac.uk>, Department of Computing, Imperial College, London, UK.
.P
-Erez Zadok <ezk@cs.columbia.edu>, Department of Computer Science, Columbia
-University, New York, USA.
+Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook
+University, Stony Brook, New York, USA.
.P
Other authors and contributors to am-utils are listed in the
.B AUTHORS
diff --git a/contrib/amd/amq/amq.c b/contrib/amd/amq/amq.c
index 06574bf..2379b62 100644
--- a/contrib/amd/amq/amq.c
+++ b/contrib/amd/amq/amq.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: amq.c,v 1.7.2.9 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amq/amq.c
*
*/
@@ -46,19 +45,6 @@
* Automounter query tool
*/
-#ifndef lint
-char copyright[] = "\
-@(#)Copyright (c) 1997-2004 Erez Zadok\n\
-@(#)Copyright (c) 1990 Jan-Simon Pendry\n\
-@(#)Copyright (c) 1990 Imperial College of Science, Technology & Medicine\n\
-@(#)Copyright (c) 1990 The Regents of the University of California.\n\
-@(#)All rights reserved.\n";
-#if __GNUC__ < 2
-static char rcsid[] = "$Id: amq.c,v 1.7.2.9 2004/01/06 03:15:16 ezk Exp $";
-static char sccsid[] = "%W% (Berkeley) %G%";
-#endif /* __GNUC__ < 2 */
-#endif /* not lint */
-
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
@@ -115,8 +101,8 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid)
case Full:
{
- struct tm *tp = localtime((time_t *) &mt->mt_mounttime);
- printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%02d\n",
+ struct tm *tp = localtime((time_t *) ((voidp) &mt->mt_mounttime));
+ printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%04d %02d:%02d:%02d\n",
*dwid, *dwid,
*mt->mt_directory ? mt->mt_directory : "/", /* XXX */
*twid, *twid,
@@ -132,16 +118,16 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid)
mt->mt_readlink,
mt->mt_statfs,
- tp->tm_year > 99 ? tp->tm_year - 100 : tp->tm_year,
tp->tm_mon + 1, tp->tm_mday,
+ tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year,
tp->tm_hour, tp->tm_min, tp->tm_sec);
}
break;
case Stats:
{
- struct tm *tp = localtime((time_t *) &mt->mt_mounttime);
- printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%02d\n",
+ struct tm *tp = localtime((time_t *) ((voidp) &mt->mt_mounttime));
+ printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%04d\n",
*dwid, *dwid,
*mt->mt_directory ? mt->mt_directory : "/", /* XXX */
@@ -152,8 +138,8 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid)
mt->mt_readlink,
mt->mt_statfs,
- tp->tm_year > 99 ? tp->tm_year - 100 : tp->tm_year,
tp->tm_mon + 1, tp->tm_mday,
+ tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year,
tp->tm_hour, tp->tm_min, tp->tm_sec);
}
break;
@@ -181,7 +167,7 @@ show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid)
* Display a pwd data
*/
static void
-show_pwd(amq_mount_tree *mt, char *path, int *flag)
+show_pwd(amq_mount_tree *mt, char *path, size_t l, int *flag)
{
int len;
@@ -189,13 +175,13 @@ show_pwd(amq_mount_tree *mt, char *path, int *flag)
len = strlen(mt->mt_mountpoint);
if (NSTREQ(path, mt->mt_mountpoint, len) &&
!STREQ(mt->mt_directory, mt->mt_mountpoint)) {
- char buf[MAXPATHLEN+1];
- strcpy(buf, mt->mt_directory);
- strcat(buf, &path[len]);
- strcpy(path, buf);
+ char buf[MAXPATHLEN+1]; /* must be same size as 'path' */
+ xstrlcpy(buf, mt->mt_directory, sizeof(buf));
+ xstrlcat(buf, &path[len], sizeof(buf));
+ xstrlcpy(path, buf, l);
*flag = 1;
}
- show_pwd(mt->mt_next, path, flag);
+ show_pwd(mt->mt_next, path, l, flag);
mt = mt->mt_child;
}
}
@@ -218,7 +204,7 @@ show_mt(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *pwid)
static void
show_mi(amq_mount_info_list *ml, enum show_opt e, int *mwid, int *dwid, int *twid)
{
- int i;
+ u_int i;
switch (e) {
@@ -448,7 +434,8 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\
am_get_progname(), server);
exit(1);
}
- memset(&server_addr, 0, sizeof server_addr);
+ memset(&server_addr, 0, sizeof(server_addr));
+ /* as per POSIX, sin_len need not be set (used internally by kernel) */
server_addr.sin_family = AF_INET;
if (hp) {
memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr,
@@ -554,7 +541,8 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\
char *wd = getcwd(path, MAXPATHLEN+1);
amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt);
amq_mount_tree_p mt;
- int i, flag;
+ u_int i;
+ int flag;
if (!wd) {
perror("getcwd");
@@ -564,7 +552,7 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\
mt = mlp->amq_mount_tree_list_val[i];
while (1) {
flag = 0;
- show_pwd(mt, path, &flag);
+ show_pwd(mt, path, sizeof(path), &flag);
if (!flag) {
printf("%s\n", path);
break;
@@ -678,8 +666,9 @@ Usage: %s [-fmpsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\
if (mlp) {
enum show_opt e = Calc;
int mwid = 0, dwid = 0, pwid = 0;
+
while (e != ShowDone) {
- int i;
+ u_int i;
for (i = 0; i < mlp->amq_mount_tree_list_len; i++) {
show_mt(mlp->amq_mount_tree_list_val[i],
e, &mwid, &dwid, &pwid);
diff --git a/contrib/amd/amq/amq.h b/contrib/amd/amq/amq.h
index 4e2d785..2f36b81 100644
--- a/contrib/amd/amq/amq.h
+++ b/contrib/amd/amq/amq.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: amq.h,v 1.14.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amq/amq.h
*
*/
@@ -59,5 +58,6 @@ extern amq_mount_info_list *amqproc_getmntfs_1(voidp argp, CLIENT *rqstp);
extern int *amqproc_mount_1(voidp argp, CLIENT *rqstp);
extern amq_string *amqproc_getvers_1(voidp argp, CLIENT *rqstp);
extern int *amqproc_getpid_1(voidp argp, CLIENT *rqstp);
+extern amq_string *amqproc_pawd_1(amq_string *argp, CLIENT *rqstp);
#endif /* not _AMQ_H */
diff --git a/contrib/amd/amq/amq_clnt.c b/contrib/amd/amq/amq_clnt.c
index 37de00a..ddfeb67 100644
--- a/contrib/amd/amq/amq_clnt.c
+++ b/contrib/amd/amq/amq_clnt.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: amq_clnt.c,v 1.3.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amq/amq_clnt.c
*
*/
@@ -76,7 +75,7 @@ amqproc_mnttree_1(amq_string *argp, CLIENT *clnt)
memset((char *) &res, 0, sizeof(res));
if (clnt_call(clnt, AMQPROC_MNTTREE,
(XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) argp,
- (XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (SVC_IN_ARG_TYPE) & res,
+ (XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (SVC_IN_ARG_TYPE) &res,
TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -109,7 +108,7 @@ amqproc_stats_1(voidp argp, CLIENT *clnt)
if (clnt_call(clnt, AMQPROC_STATS,
(XDRPROC_T_TYPE) xdr_void, argp,
(XDRPROC_T_TYPE) xdr_amq_mount_stats,
- (SVC_IN_ARG_TYPE) & res,
+ (SVC_IN_ARG_TYPE) &res,
TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -126,7 +125,7 @@ amqproc_export_1(voidp argp, CLIENT *clnt)
if (clnt_call(clnt, AMQPROC_EXPORT,
(XDRPROC_T_TYPE) xdr_void, argp,
(XDRPROC_T_TYPE) xdr_amq_mount_tree_list,
- (SVC_IN_ARG_TYPE) & res, TIMEOUT) != RPC_SUCCESS) {
+ (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
return (&res);
@@ -141,7 +140,7 @@ amqproc_setopt_1(amq_setopt *argp, CLIENT *clnt)
memset((char *) &res, 0, sizeof(res));
if (clnt_call(clnt, AMQPROC_SETOPT, (XDRPROC_T_TYPE) xdr_amq_setopt,
(SVC_IN_ARG_TYPE) argp, (XDRPROC_T_TYPE) xdr_int,
- (SVC_IN_ARG_TYPE) & res, TIMEOUT) != RPC_SUCCESS) {
+ (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
return (&res);
@@ -156,7 +155,7 @@ amqproc_getmntfs_1(voidp argp, CLIENT *clnt)
memset((char *) &res, 0, sizeof(res));
if (clnt_call(clnt, AMQPROC_GETMNTFS, (XDRPROC_T_TYPE) xdr_void, argp,
(XDRPROC_T_TYPE) xdr_amq_mount_info_list,
- (SVC_IN_ARG_TYPE) & res, TIMEOUT) != RPC_SUCCESS) {
+ (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
return (&res);
@@ -170,7 +169,7 @@ amqproc_mount_1(voidp argp, CLIENT *clnt)
memset((char *) &res, 0, sizeof(res));
if (clnt_call(clnt, AMQPROC_MOUNT, (XDRPROC_T_TYPE) xdr_amq_string, argp,
- (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) & res,
+ (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) &res,
TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -185,7 +184,7 @@ amqproc_getvers_1(voidp argp, CLIENT *clnt)
memset((char *) &res, 0, sizeof(res));
if (clnt_call(clnt, AMQPROC_GETVERS, (XDRPROC_T_TYPE) xdr_void, argp,
- (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) & res,
+ (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) &res,
TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
@@ -200,7 +199,23 @@ amqproc_getpid_1(voidp argp, CLIENT *clnt)
memset((char *) &res, 0, sizeof(res));
if (clnt_call(clnt, AMQPROC_GETPID, (XDRPROC_T_TYPE) xdr_void, argp,
- (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) & res,
+ (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) &res,
+ TIMEOUT) != RPC_SUCCESS) {
+ return (NULL);
+ }
+ return (&res);
+}
+
+
+amq_string *
+amqproc_pawd_1(amq_string *argp, CLIENT *clnt)
+{
+ static amq_string res;
+
+ memset((char *) &res, 0, sizeof(res));
+ if (clnt_call(clnt, AMQPROC_PAWD,
+ (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) argp,
+ (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) &res,
TIMEOUT) != RPC_SUCCESS) {
return (NULL);
}
diff --git a/contrib/amd/amq/amq_xdr.c b/contrib/amd/amq/amq_xdr.c
index 835b98d..692a0a4 100644
--- a/contrib/amd/amq/amq_xdr.c
+++ b/contrib/amd/amq/amq_xdr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: amq_xdr.c,v 1.3.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amq/amq_xdr.c
*
*/
@@ -107,11 +106,17 @@ xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp)
return (FALSE);
}
- if (!xdr_pointer(xdrs, (char **) &objp->mt_next, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
+ if (!xdr_pointer(xdrs,
+ (char **) ((voidp) &objp->mt_next),
+ sizeof(amq_mount_tree),
+ (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
return (FALSE);
}
- if (!xdr_pointer(xdrs, (char **) &objp->mt_child, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
+ if (!xdr_pointer(xdrs,
+ (char **) ((voidp) &objp->mt_child),
+ sizeof(amq_mount_tree),
+ (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
return (FALSE);
}
@@ -122,7 +127,10 @@ xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp)
bool_t
xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp)
{
- if (!xdr_pointer(xdrs, (char **) objp, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
+ if (!xdr_pointer(xdrs,
+ (char **) objp,
+ sizeof(amq_mount_tree),
+ (XDRPROC_T_TYPE) xdr_amq_mount_tree)) {
return (FALSE);
}
return (TRUE);
@@ -169,7 +177,7 @@ bool_t
xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp)
{
if (!xdr_array(xdrs,
- (char **) &objp->amq_mount_info_list_val,
+ (char **) ((voidp) &objp->amq_mount_info_list_val),
(u_int *) &objp->amq_mount_info_list_len,
~0,
sizeof(amq_mount_info),
@@ -184,7 +192,7 @@ bool_t
xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp)
{
if (!xdr_array(xdrs,
- (char **) &objp->amq_mount_tree_list_val,
+ (char **) ((voidp) &objp->amq_mount_tree_list_val),
(u_int *) &objp->amq_mount_tree_list_len,
~0,
sizeof(amq_mount_tree_p),
diff --git a/contrib/amd/amq/pawd.1 b/contrib/amd/amq/pawd.1
index d7ddebd..73a16b5 100644
--- a/contrib/amd/amq/pawd.1
+++ b/contrib/amd/amq/pawd.1
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997-2004 Erez Zadok
+.\" Copyright (c) 1997-2006 Erez Zadok
.\" Copyright (c) 1990 Jan-Simon Pendry
.\" Copyright (c) 1990 Imperial College of Science, Technology & Medicine
.\" Copyright (c) 1990 The Regents of the University of California.
@@ -38,7 +38,7 @@
.\"
.\" %W% (Berkeley) %G%
.\"
-.\" $Id: pawd.1,v 1.3.2.4 2004/01/06 03:15:16 ezk Exp $
+.\" $Id: pawd.1,v 1.9.2.1 2006/01/02 18:48:24 ezk Exp $
.\"
.TH PAWD 1 "6 Jan 1998"
.SH NAME
@@ -70,3 +70,21 @@ arguments.
.BR amd (8),
.BR amq (8),
.BR pwd (1).
+.LP
+``am-utils''
+.BR info (1)
+entry.
+.LP
+.I "Linux NFS and Automounter Administration"
+by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001).
+.LP
+.I http://www.am-utils.org
+.LP
+.I "Amd \- The 4.4 BSD Automounter"
+.SH AUTHORS
+Erez Zadok <ezk@cs.sunysb.edu>, Computer Science Department, Stony Brook
+University, Stony Brook, New York, USA.
+.P
+Other authors and contributors to am-utils are listed in the
+.B AUTHORS
+file distributed with am-utils.
diff --git a/contrib/amd/amq/pawd.c b/contrib/amd/amq/pawd.c
index 2d655d0..c9a32b1 100644
--- a/contrib/amd/amq/pawd.c
+++ b/contrib/amd/amq/pawd.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997-2004 Erez Zadok
+ * Copyright (c) 1997-2006 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,9 +36,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * %W% (Berkeley) %G%
*
- * $Id: pawd.c,v 1.6.2.4 2004/01/06 03:15:16 ezk Exp $
+ * File: am-utils/amq/pawd.c
*
*/
@@ -58,48 +57,11 @@
#include <am_defs.h>
#include <amq.h>
+
/* statics */
-static char *localhost="localhost";
-static char newdir[MAXPATHLEN];
+static char *localhost = "localhost";
static char transform[MAXPATHLEN];
-static int
-find_mt(amq_mount_tree *mt, char *dir)
-{
- while (mt) {
- if (STREQ(mt->mt_type, "link") ||
- STREQ(mt->mt_type, "nfs") ||
- STREQ(mt->mt_type, "nfsl")) {
- int len = strlen(mt->mt_mountpoint);
- if (NSTREQ(mt->mt_mountpoint, dir, len) &&
- ((dir[len] == '\0') || (dir[len] == '/'))) {
- char tmp_buf[MAXPATHLEN];
- strcpy(tmp_buf, mt->mt_directory);
- strcat(tmp_buf, &dir[len]);
- strcpy(newdir, tmp_buf);
- return 1;
- }
- }
- if (find_mt(mt->mt_next,dir))
- return 1;
- mt = mt->mt_child;
- }
- return 0;
-}
-
-
-static int
-find_mlp(amq_mount_tree_list *mlp, char *dir)
-{
- int i;
-
- for (i = 0; i < mlp->amq_mount_tree_list_len; i++) {
- if (find_mt(mlp->amq_mount_tree_list_val[i], dir))
- return 1;
- }
- return 0;
-}
-
#ifdef HAVE_CNODEID
static char *
@@ -160,7 +122,8 @@ hack_name(char *dir)
fprintf(stderr, "partition %s, username %s\n", partition, username);
#endif /* DEBUG */
- sprintf(hesiod_lookup, "%s.homes-remote", username);
+ xsnprintf(hesiod_lookup, sizeof(hesiod_lookup),
+ "%s.homes-remote", username);
hes = hes_resolve(hesiod_lookup, "amd");
if (!hes)
return NULL;
@@ -184,9 +147,10 @@ hack_name(char *dir)
#ifdef DEBUG
fprintf(stderr, "A match, munging....\n");
#endif /* DEBUG */
- strcpy(transform, "/home/");
- strcat(transform, username);
- if (*ch) strcat(transform, ch);
+ xstrlcpy(transform, "/home/", sizeof(transform));
+ xstrlcat(transform, username, sizeof(transform));
+ if (*ch)
+ xstrlcat(transform, ch, sizeof(transform));
#ifdef DEBUG
fprintf(stderr, "Munged to <%s>\n", transform);
#endif /* DEBUG */
@@ -216,8 +180,9 @@ transform_dir(char *dir)
int s = RPC_ANYSOCK;
CLIENT *clnt;
struct hostent *hp;
- amq_mount_tree_list *mlp;
struct timeval tmo = {10, 0};
+ char *dummystr;
+ amq_string *spp;
#ifdef DISK_HOME_HACK
if (ch = hack_name(dir))
@@ -230,31 +195,37 @@ transform_dir(char *dir)
server = localhost;
#endif /* not HAVE_CNODEID */
- if ((hp = gethostbyname(server)) == 0)
+ if ((hp = gethostbyname(server)) == NULL)
return dir;
memset(&server_addr, 0, sizeof(server_addr));
+ /* as per POSIX, sin_len need not be set (used internally by kernel) */
server_addr.sin_family = AF_INET;
server_addr.sin_addr = *(struct in_addr *) hp->h_addr;
clnt = clntudp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, tmo, &s);
- if (clnt == 0)
+ if (clnt == NULL)
+ clnt = clnttcp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, &s, 0, 0);
+ if (clnt == NULL)
return dir;
- strcpy(transform,dir);
- while ( (mlp = amqproc_export_1((voidp)0, clnt)) &&
- find_mlp(mlp,transform) ) {
- strcpy(transform,newdir);
+ xstrlcpy(transform, dir, sizeof(transform));
+ dummystr = transform;
+ spp = amqproc_pawd_1((amq_string *) &dummystr, clnt);
+ if (spp && *spp && **spp) {
+ xstrlcpy(transform, *spp, sizeof(transform));
+ XFREE(*spp);
}
+ clnt_destroy(clnt);
return transform;
}
/* getawd() is a substitute for getwd() which transforms the path */
static char *
-getawd(char *path)
+getawd(char *path, size_t l)
{
#ifdef HAVE_GETCWD
- char *wd = getcwd(path, MAXPATHLEN+1);
+ char *wd = getcwd(path, MAXPATHLEN);
#else /* not HAVE_GETCWD */
char *wd = getwd(path);
#endif /* not HAVE_GETCWD */
@@ -262,7 +233,7 @@ getawd(char *path)
if (wd == NULL) {
return NULL;
}
- strcpy(path, transform_dir(wd));
+ xstrlcpy(path, transform_dir(wd), l);
return path;
}
@@ -273,7 +244,7 @@ main(int argc, char *argv[])
char tmp_buf[MAXPATHLEN], *wd;
if (argc == 1) {
- wd = getawd(tmp_buf);
+ wd = getawd(tmp_buf, sizeof(tmp_buf));
if (wd == NULL) {
fprintf(stderr, "pawd: %s\n", tmp_buf);
exit(1);
OpenPOWER on IntegriCloud