summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2001-08-02 21:46:21 +0000
committeriedowse <iedowse@FreeBSD.org>2001-08-02 21:46:21 +0000
commit9e402fc673a4a5ca4c028ecc7b367b90734ddb2b (patch)
tree5820219ef408d8a58e26e08c801ca601f759dd51
parent064d84b2521ca869363580e56d314e48668cb3ab (diff)
downloadFreeBSD-src-9e402fc673a4a5ca4c028ecc7b367b90734ddb2b.zip
FreeBSD-src-9e402fc673a4a5ca4c028ecc7b367b90734ddb2b.tar.gz
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.
-rw-r--r--usr.sbin/rpc.umntall/mounttab.c2
-rw-r--r--usr.sbin/rpc.umntall/rpc.umntall.c22
2 files changed, 11 insertions, 13 deletions
diff --git a/usr.sbin/rpc.umntall/mounttab.c b/usr.sbin/rpc.umntall/mounttab.c
index d4b1865..01ce78c 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 f4395a8..fd13850 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);
}
/*
OpenPOWER on IntegriCloud