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.
This commit is contained in:
Ian Dowse 2001-08-02 21:46:21 +00:00
parent e73bb7f1e2
commit 146e669b8d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=81070
2 changed files with 11 additions and 13 deletions

View File

@ -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;

View File

@ -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);
}
/*