From 146e669b8d1452763347a67dd8c5f2c1b3b05ca2 Mon Sep 17 00:00:00 2001 From: Ian Dowse Date: Thu, 2 Aug 2001 21:46:21 +0000 Subject: [PATCH] Fix a few bugs, some of which I introduced in recent commits: - clean_mtab(): Actually use the strdup'd version of the host that we go to the trouble of creating. - do_umntall/do_umount: Don't return success if clnt_create() fails. Don't access a client pointer after it has been destroyed. Remember to destroy the authentication information we created. --- usr.sbin/rpc.umntall/mounttab.c | 2 +- usr.sbin/rpc.umntall/rpc.umntall.c | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/usr.sbin/rpc.umntall/mounttab.c b/usr.sbin/rpc.umntall/mounttab.c index d4b1865b7979..01ce78c97086 100644 --- a/usr.sbin/rpc.umntall/mounttab.c +++ b/usr.sbin/rpc.umntall/mounttab.c @@ -189,7 +189,7 @@ clean_mtab(char *hostp, char *dirp, int verbose) { /* Copy hostp in case it points to an entry that we are zeroing out. */ host = strdup(hostp); for (mtabp = mtabhead; mtabp != NULL; mtabp = mtabp->mtab_next) { - if (strcmp(mtabp->mtab_host, hostp) != 0) + if (strcmp(mtabp->mtab_host, host) != 0) continue; if (dirp != NULL && strcmp(mtabp->mtab_dirp, dirp) != 0) continue; diff --git a/usr.sbin/rpc.umntall/rpc.umntall.c b/usr.sbin/rpc.umntall/rpc.umntall.c index f4395a8ee947..fd1385016c03 100644 --- a/usr.sbin/rpc.umntall/rpc.umntall.c +++ b/usr.sbin/rpc.umntall/rpc.umntall.c @@ -180,19 +180,18 @@ do_umntall(char *hostname) { clp = clnt_create(hostname, RPCPROG_MNT, RPCMNT_VER1, "udp"); if (clp == NULL) { warnx("%s: %s", hostname, clnt_spcreateerror("RPCPROG_MNT")); - return (1); + return (0); } clp->cl_auth = authunix_create_default(); try.tv_sec = 3; try.tv_usec = 0; clnt_stat = clnt_call(clp, RPCMNT_UMNTALL, xdr_void, (caddr_t)0, xdr_void, (caddr_t)0, try); - clnt_destroy(clp); - if (clnt_stat != RPC_SUCCESS) { + if (clnt_stat != RPC_SUCCESS) warnx("%s: %s", hostname, clnt_sperror(clp, "RPCMNT_UMNTALL")); - return (0); - } else - return (1); + auth_destroy(clp->cl_auth); + clnt_destroy(clp); + return (clnt_stat == RPC_SUCCESS); } /* @@ -207,19 +206,18 @@ do_umount(char *hostname, char *dirp) { clp = clnt_create(hostname, RPCPROG_MNT, RPCMNT_VER1, "udp"); if (clp == NULL) { warnx("%s: %s", hostname, clnt_spcreateerror("RPCPROG_MNT")); - return (1); + return (0); } clp->cl_auth = authsys_create_default(); try.tv_sec = 3; try.tv_usec = 0; clnt_stat = clnt_call(clp, RPCMNT_UMOUNT, xdr_dir, dirp, xdr_void, (caddr_t)0, try); - clnt_destroy(clp); - if (clnt_stat != RPC_SUCCESS) { + if (clnt_stat != RPC_SUCCESS) warnx("%s: %s", hostname, clnt_sperror(clp, "RPCMNT_UMOUNT")); - return (0); - } - return (1); + auth_destroy(clp->cl_auth); + clnt_destroy(clp); + return (clnt_stat == RPC_SUCCESS); } /*