diff options
author | obrien <obrien@FreeBSD.org> | 1998-11-14 03:11:37 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 1998-11-14 03:11:37 +0000 |
commit | c6e3533e1e31cbf25e04688d244a8fc2af2e1972 (patch) | |
tree | a4eb3d7f17ca252572bc28a3ec00f1e8ebd00f5d /contrib/amd/amd | |
parent | 663d5a0f32ed8dfc091ffb6153161591ac6ba563 (diff) | |
download | FreeBSD-src-c6e3533e1e31cbf25e04688d244a8fc2af2e1972.zip FreeBSD-src-c6e3533e1e31cbf25e04688d244a8fc2af2e1972.tar.gz |
Virgin import of AMD (am-utils) v6.0b1
Diffstat (limited to 'contrib/amd/amd')
-rw-r--r-- | contrib/amd/amd/amd.c | 5 | ||||
-rw-r--r-- | contrib/amd/amd/amfs_auto.c | 1 | ||||
-rw-r--r-- | contrib/amd/amd/amfs_host.c | 6 | ||||
-rw-r--r-- | contrib/amd/amd/conf.c | 10 | ||||
-rw-r--r-- | contrib/amd/amd/info_nis.c | 30 | ||||
-rw-r--r-- | contrib/amd/amd/mapc.c | 24 | ||||
-rw-r--r-- | contrib/amd/amd/ops_autofs.c | 3 |
7 files changed, 59 insertions, 20 deletions
diff --git a/contrib/amd/amd/amd.c b/contrib/amd/amd/amd.c index 7ef2ce7..bc750e5 100644 --- a/contrib/amd/amd/amd.c +++ b/contrib/amd/amd/amd.c @@ -57,8 +57,8 @@ struct amu_global_options gopt; /* where global options are stored */ char pid_fsname[16 + MAXHOSTNAMELEN]; /* "kiska.southseas.nz:(pid%d)" */ char *progname; /* "amd" */ char *hostdomain = "unknown.domain"; -char hostname[MAXHOSTNAMELEN] = "localhost"; /* Hostname */ -char hostd[2 * MAXHOSTNAMELEN]; /* Host+domain */ +char hostname[MAXHOSTNAMELEN + 1] = "localhost"; /* Hostname */ +char hostd[2 * MAXHOSTNAMELEN + 1]; /* Host+domain */ char *endian = ARCH_ENDIAN; /* Big or Little endian */ char *cpu = HOST_CPU; /* CPU type */ char *PrimNetName; /* name of primary network */ @@ -349,6 +349,7 @@ main(int argc, char *argv[]) plog(XLOG_FATAL, "gethostname: %m"); going_down(1); } + hostname[sizeof(hostname) - 1] = '\0'; /* * Check it makes sense diff --git a/contrib/amd/amd/amfs_auto.c b/contrib/amd/amd/amfs_auto.c index 0530142..e7f8589 100644 --- a/contrib/amd/amd/amfs_auto.c +++ b/contrib/amd/amd/amfs_auto.c @@ -1128,6 +1128,7 @@ amfs_auto_lookuppn(am_node *mp, char *fname, int *error_return, int op) memset((char *) &ap, 0, sizeof(am_opts)); pt = ops_match(&ap, *sp, "", mp->am_path, "/defaults", mp->am_parent->am_mnt->mf_info); + free_opts(&ap); /* don't leak */ if (pt == &amfs_error_ops) { plog(XLOG_MAP, "failed to match defaults for \"%s\"", *sp); } else { diff --git a/contrib/amd/amd/amfs_host.c b/contrib/amd/amd/amfs_host.c index 6be259d..731c661 100644 --- a/contrib/amd/amd/amfs_host.c +++ b/contrib/amd/amd/amfs_host.c @@ -256,7 +256,7 @@ fetch_fhandle(CLIENT * client, char *dir, am_nfs_handle_t *fhp, u_long nfs_versi (SVC_IN_ARG_TYPE) &fhp->v2, tv); if (clnt_stat != RPC_SUCCESS) { - char *msg = clnt_sperrno(clnt_stat); + const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "mountd rpc failed: %s", msg); return EIO; } @@ -392,7 +392,7 @@ amfs_host_fmount(mntfs *mf) (SVC_IN_ARG_TYPE) & exlist, tv2); if (clnt_stat != RPC_SUCCESS) { - char *msg = clnt_sperrno(clnt_stat); + const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "host_fmount rpc failed: %s", msg); /* clnt_perror(client, "rpc"); */ error = EIO; @@ -673,7 +673,7 @@ amfs_host_umounted(am_node *mp) tv); if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_SYSTEMERROR) { /* RPC_SYSTEMERROR seems to be returned for no good reason ... */ - char *msg = clnt_sperrno(clnt_stat); + const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "unmount all from %s rpc failed: %s", host, msg, clnt_stat); goto out; } diff --git a/contrib/amd/amd/conf.c b/contrib/amd/amd/conf.c index a97b1b1..0ec3259 100644 --- a/contrib/amd/amd/conf.c +++ b/contrib/amd/amd/conf.c @@ -534,6 +534,11 @@ gopt_map_options(const char *val) static int gopt_map_type(const char *val) { + /* check if map type exist */ + if (!mapc_type_exists(val)) { + fprintf(stderr, "conf: no such map type \"%s\"\n", val); + return 1; + } gopt.map_type = strdup((char *)val); return 0; } @@ -846,6 +851,11 @@ ropt_map_options(const char *val, cf_map_t *cfm) static int ropt_map_type(const char *val, cf_map_t *cfm) { + /* check if map type exist */ + if (!mapc_type_exists(val)) { + fprintf(stderr, "conf: no such map type \"%s\"\n", val); + return 1; + } cfm->cfm_type = strdup((char *)val); return 0; } diff --git a/contrib/amd/amd/info_nis.c b/contrib/amd/amd/info_nis.c index eceb73a..237f6f5 100644 --- a/contrib/amd/amd/info_nis.c +++ b/contrib/amd/amd/info_nis.c @@ -52,6 +52,7 @@ #include <am_defs.h> #include <amd.h> + /* * NIS+ servers in NIS compat mode don't have yp_order() */ @@ -61,6 +62,7 @@ static int has_yp_order = FALSE; int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp); int nis_init(mnt_map *m, char *map, time_t *tp); +int nis_isup(mnt_map *m, char *map); int nis_mtime(mnt_map *m, char *map, time_t *tp); /* typedefs */ @@ -120,27 +122,20 @@ callback(int status, char *key, int kl, char *val, int vl, char *data) if (status == YP_TRUE) { - /* - * Add to list of maps - */ + /* add to list of maps */ char *kp = strnsave(key, kl); char *vp = strnsave(val, vl); + (*ncdp->ncd_fn) (ncdp->ncd_m, kp, vp); - /* - * We want more ... - */ + /* we want more ... */ return FALSE; } else { - /* - * NOMORE means end of map - otherwise log error - */ + /* NOMORE means end of map - otherwise log error */ if (status != YP_NOMORE) { - /* - * Check what went wrong - */ + /* check what went wrong */ int e = ypprot_err(status); #ifdef DEBUG @@ -378,16 +373,25 @@ am_yp_all(char *indomain, char *inmap, struct ypall_callback *incallback) incallback->data); if (j != FALSE) /* terminate loop */ break; + + /* + * We have to manually free all char ** arguments to yp_first/yp_next + * outval must be freed *before* calling yp_next again, outkey can be + * freed as outkey_old *after* the call (this saves one call to + * strnsave). + */ + XFREE(outval); outkey_old = outkey; outkeylen_old = outkeylen; i = yp_next(indomain, inmap, outkey_old, outkeylen_old, - &outkey, + &outkey, &outkeylen, &outval, &outvallen); + XFREE(outkey_old); } while (!i); #ifdef DEBUG if (i) { diff --git a/contrib/amd/amd/mapc.c b/contrib/amd/amd/mapc.c index de95e13..51ec7e1 100644 --- a/contrib/amd/amd/mapc.c +++ b/contrib/amd/amd/mapc.c @@ -350,10 +350,32 @@ mapc_showtypes(char *buf) /* + * Check if a map of a certain type exists. + * Return 1 (true) if exists, 0 (false) if not. + */ +int +mapc_type_exists(const char *type) +{ + map_type *mt; + + if (!type) + return 0; + for (mt = maptypes; + mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]); + mt++) { + if (STREQ(type, mt->name)) + return 1; + } + return 0; /* not found anywhere */ +} + + +/* * Add key and val to the map m. * key and val are assumed to be safe copies */ -void mapc_add_kv(mnt_map *m, char *key, char *val) +void +mapc_add_kv(mnt_map *m, char *key, char *val) { kv **h; kv *n; diff --git a/contrib/amd/amd/ops_autofs.c b/contrib/amd/amd/ops_autofs.c index a566fc4..14ab415 100644 --- a/contrib/amd/amd/ops_autofs.c +++ b/contrib/amd/amd/ops_autofs.c @@ -284,7 +284,7 @@ mount_autofs(char *dir, char *opts) /* * Make a ``hostname'' string for the kernel */ - sprintf(fs_hostname, "pid%ld@%s:%s", foreground ? mypid : getppid(), + sprintf(fs_hostname, "pid%ld@%s:%s", (long) (foreground ? mypid : getppid()), hostname, dir); /* @@ -1131,6 +1131,7 @@ autofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) memset((char *) &ap, 0, sizeof(am_opts)); pt = ops_match(&ap, *sp, "", mp->am_path, "/defaults", mp->am_parent->am_mnt->mf_info); + free_opts(&ap); /* don't leak */ if (pt == &amfs_error_ops) { plog(XLOG_MAP, "failed to match defaults for \"%s\"", *sp); } else { |