From 5473b5f1fe216a061793dcbd66e35361a48ddc76 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Thu, 15 Sep 2005 23:12:56 +0000 Subject: [PATCH] * amd/nfs_subr.c (nfsproc_getattr_2_svc): initialize 'retry', just in case. (fh_to_mp3): increment amd_stats.d_stale counter only if we are actually returning ESTALE. * amd/info_exec.c (exec_parse_qanswer), amd/info_file.c (file_search_or_reload), amd/info_hesiod.c (hesiod_search), amd/info_ldap.c (amu_ldap_search), amd/info_ndbm.c (search_ndbm), amd/info_nis.c (nis_search), amd/info_nisplus.c (nisplus_search, nisplus_search): don't dereference mnt_map->cfm which may be null if we're not using an amd.conf file. * libamu/xutil.c (unregister_amq): if failed to de-register Amd from portmapper, report it under dlog (debugging), not as an annoying plog that always shows up. --- ChangeLog | 20 ++++++++++++++++++++ amd/amfs_generic.c | 2 +- amd/info_exec.c | 2 +- amd/info_file.c | 3 ++- amd/info_hesiod.c | 2 +- amd/info_ldap.c | 2 +- amd/info_ndbm.c | 2 +- amd/info_nis.c | 2 +- amd/info_nisplus.c | 2 +- amd/nfs_subr.c | 23 ++++++++++++----------- libamu/xutil.c | 2 +- 11 files changed, 42 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4f89771..0cdbc26c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2005-09-15 Erez Zadok + + * amd/nfs_subr.c (nfsproc_getattr_2_svc): initialize 'retry', just + in case. + (fh_to_mp3): increment amd_stats.d_stale counter only if we are + actually returning ESTALE. + + * amd/info_exec.c (exec_parse_qanswer), amd/info_file.c + (file_search_or_reload), amd/info_hesiod.c (hesiod_search), + amd/info_ldap.c (amu_ldap_search), amd/info_ndbm.c (search_ndbm), + amd/info_nis.c (nis_search), amd/info_nisplus.c (nisplus_search, + nisplus_search): don't dereference mnt_map->cfm which may be null + if we're not using an amd.conf file. + +2005-09-14 Erez Zadok + + * libamu/xutil.c (unregister_amq): if failed to de-register Amd + from portmapper, report it under dlog (debugging), not as an + annoying plog that always shows up. + 2005-09-13 Erez Zadok * mk-amd-map/mk-amd-map.c (read_file_file), libamu/util.c diff --git a/amd/amfs_generic.c b/amd/amfs_generic.c index 09e8d4ec..8aa47a38 100644 --- a/amd/amfs_generic.c +++ b/amd/amfs_generic.c @@ -240,7 +240,7 @@ amfs_lookup_node(am_node *mp, char *fname, int *error_return) */ new_mp = get_ap_child(mp, expanded_fname); XFREE(expanded_fname); - if (new_mp == 0) + if (new_mp == NULL) ereturn(ENOSPC); *error_return = -1; diff --git a/amd/info_exec.c b/amd/info_exec.c index 9e089436..cebd91d9 100644 --- a/amd/info_exec.c +++ b/amd/info_exec.c @@ -207,7 +207,7 @@ exec_parse_qanswer(mnt_map *m, int fd, char *map, char *key, char **pval, time_t /* * Return a copy of the data */ - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) dc = sun_entry2amd(key, cp); else dc = strdup(cp); diff --git a/amd/info_file.c b/amd/info_file.c index 1af24156..db019240 100644 --- a/amd/info_file.c +++ b/amd/info_file.c @@ -160,7 +160,8 @@ file_search_or_reload(mnt_map *m, * Return a copy of the data */ char *dc; - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + /* if m->cfm == NULL, not using amd.conf file */ + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) dc = sun_entry2amd(kp, cp); else dc = strdup(cp); diff --git a/amd/info_hesiod.c b/amd/info_hesiod.c index 73ea04bf..50c470d3 100644 --- a/amd/info_hesiod.c +++ b/amd/info_hesiod.c @@ -128,7 +128,7 @@ hesiod_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) * it (and free subsequent replies) */ if (rvec && *rvec) { - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) { + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) { *pval = sun_entry2amd(key, *rvec); XFREE(*rvec); } else diff --git a/amd/info_ldap.c b/amd/info_ldap.c index 71fcfe42..376a0462 100644 --- a/amd/info_ldap.c +++ b/amd/info_ldap.c @@ -528,7 +528,7 @@ amu_ldap_search(mnt_map *m, char *map, char *key, char **pval, time_t *ts) } dlog("Map %s, %s => %s\n", map, key, vals[0]); if (vals[0]) { - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) *pval = sun_entry2amd(key, vals[0]); else *pval = strdup(vals[0]); diff --git a/amd/info_ndbm.c b/amd/info_ndbm.c index ebd0b951..5eac3c89 100644 --- a/amd/info_ndbm.c +++ b/amd/info_ndbm.c @@ -67,7 +67,7 @@ search_ndbm(mnt_map *m, DBM *db, char *key, char **val) k.dsize = strlen(key) + 1; v = dbm_fetch(db, k); if (v.dptr) { - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) *val = sun_entry2amd(key, v.dptr); else *val = strdup(v.dptr); diff --git a/amd/info_nis.c b/amd/info_nis.c index 131ca67e..af17bab7 100644 --- a/amd/info_nis.c +++ b/amd/info_nis.c @@ -303,7 +303,7 @@ nis_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) * Lookup key */ res = yp_match(gopt.nis_domain, map, key, strlen(key), pval, &outlen); - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) { + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) { char *oldval = *pval; *pval = sun_entry2amd(key, oldval); XFREE(*pval); /* yp_match malloc's *pval above */ diff --git a/amd/info_nisplus.c b/amd/info_nisplus.c index 107109f0..4241f9a6 100644 --- a/amd/info_nisplus.c +++ b/amd/info_nisplus.c @@ -220,7 +220,7 @@ nisplus_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) data.value = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1)); } - if (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) { + if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) { *val = sun_entry2amd(key, data.value); XFREE(data.value); /* strnsave malloc'ed it above */ } else diff --git a/amd/nfs_subr.c b/amd/nfs_subr.c index b03173e4..099e0b94 100644 --- a/amd/nfs_subr.c +++ b/amd/nfs_subr.c @@ -99,7 +99,7 @@ do_readlink(am_node *mp, int *error_return) if (mp->am_mnt->mf_ops->readlink) { int retry = 0; mp = (*mp->am_mnt->mf_ops->readlink) (mp, &retry); - if (mp == 0) { + if (mp == NULL) { *error_return = retry; return 0; } @@ -130,14 +130,14 @@ nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsattrstat res; am_node *mp; - int retry; + int retry = 0; time_t now = clocktime(); if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "getattr:"); mp = fh_to_mp3(argp, &retry, VLOOK_CREATE); - if (mp == 0) { + if (mp == NULL) { if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tretry=%d", retry); @@ -208,7 +208,7 @@ nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) sprintf(opt_gid, "%d", (int) gid); mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_CREATE); - if (mp == 0) { + if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; @@ -300,7 +300,7 @@ nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) plog(XLOG_DEBUG, "readlink:"); mp = fh_to_mp3(argp, &retry, VLOOK_CREATE); - if (mp == 0) { + if (mp == NULL) { readlink_retry: if (retry < 0) { amd_stats.d_drops++; @@ -378,7 +378,7 @@ unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp) int retry; am_node *mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_DELETE); - if (mp == 0) { + if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; @@ -396,7 +396,7 @@ unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp) plog(XLOG_DEBUG, "\tremove(%s, %s)", mp->am_path, argp->da_name); mp = mp->am_mnt->mf_ops->lookup_child(mp, argp->da_name, &retry, VLOOK_DELETE); - if (mp == 0) { + if (mp == NULL) { /* * Ignore retries... */ @@ -509,7 +509,7 @@ nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp) plog(XLOG_DEBUG, "readdir:"); mp = fh_to_mp3(&argp->rda_fhandle, &retry, VLOOK_CREATE); - if (mp == 0) { + if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; @@ -540,7 +540,7 @@ nfsproc_statfs_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) plog(XLOG_DEBUG, "statfs:"); mp = fh_to_mp3(argp, &retry, VLOOK_CREATE); - if (mp == 0) { + if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; @@ -760,9 +760,10 @@ drop: */ if (amd_state == Finishing) *rp = ENOENT; - else + else { *rp = ESTALE; - amd_stats.d_stale++; + amd_stats.d_stale++; + } } return ap; diff --git a/libamu/xutil.c b/libamu/xutil.c index 524fe6bb..eab3be44 100644 --- a/libamu/xutil.c +++ b/libamu/xutil.c @@ -861,7 +861,7 @@ unregister_amq(void) u_long amd_prognum = get_amd_program_number(); if (pmap_unset(amd_prognum, AMQ_VERSION) == 1) - plog(XLOG_ERROR, "failed to de-register Amd program %lu, version %lu", + dlog("failed to de-register Amd program %lu, version %lu", amd_prognum, AMQ_VERSION); } } -- 2.43.0