summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in6
-rw-r--r--quotaio_rpc.c15
-rw-r--r--quotaio_v1.c5
-rw-r--r--quotaops.c6
-rw-r--r--rquota_client.c37
-rw-r--r--rquota_client.h4
-rw-r--r--rquota_server.c5
-rw-r--r--rquota_svc.c5
8 files changed, 52 insertions, 31 deletions
diff --git a/Makefile.in b/Makefile.in
index 20049e8..9307e1c 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -7,13 +7,9 @@ RPCSRC = rquota.h rquota_xdr.c rquota_clnt.c
LIBS = @LIBS@
LDFLAGS = @LDFLAGS@
-# Uncomment the two lines below to add tcp_wrapper support for rpc.rquotad
-# Then add lines to /etc/hosts.allow and /etc/hosts.deny
+# Add lines to /etc/hosts.allow and /etc/hosts.deny
# like: "rquotad: ALL@ALL except my.host.i.want.com" in hosts.deny means
# only the host designated can get info from rquotad
-# NOTE: I used gethostbyaddr(), so you may need FQDN or merely host name
-# depending on how your resolver returns first. IP Addresses will work as well.
-#
CFLAGS += @HOSTS_ACCESS@
INSTALL = @INSTALL@
diff --git a/quotaio_rpc.c b/quotaio_rpc.c
index 3482de8..f02727d 100644
--- a/quotaio_rpc.c
+++ b/quotaio_rpc.c
@@ -4,6 +4,7 @@
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
#include <sys/types.h>
#include "common.h"
@@ -32,10 +33,15 @@ static struct dquot *rpc_read_dquot(struct quota_handle *h, qid_t id)
{
#ifdef RPC
struct dquot *dquot = get_empty_dquot();
+ int ret;
dquot->dq_id = id;
dquot->dq_h = h;
- rpc_rquota_get(dquot);
+ if ((ret = rpc_rquota_get(dquot)) < 0) {
+ errno = -ret;
+ free(dquot);
+ return NULL;
+ }
return dquot;
#else
errno = ENOTSUP;
@@ -49,12 +55,17 @@ static struct dquot *rpc_read_dquot(struct quota_handle *h, qid_t id)
static int rpc_commit_dquot(struct dquot *dquot)
{
#ifdef RPC
+ int ret;
+
if (QIO_RO(dquot->dq_h)) {
errstr(_("Trying to write quota to readonly quotafile on %s\n"), dquot->dq_h->qh_quotadev);
errno = EPERM;
return -1;
}
- rpc_rquota_set(QCMD(Q_RPC_SETQUOTA, dquot->dq_h->qh_type), dquot);
+ if ((ret = rpc_rquota_set(QCMD(Q_RPC_SETQUOTA, dquot->dq_h->qh_type), dquot)) < 0) {
+ errno = -ret;
+ return -1;
+ }
return 0;
#else
errno = ENOTSUP;
diff --git a/quotaio_v1.c b/quotaio_v1.c
index 93b77b8..db09199 100644
--- a/quotaio_v1.c
+++ b/quotaio_v1.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaio_v1.c,v 1.7 2001/08/15 20:13:42 jkar8572 Exp $"
+#ident "$Id: quotaio_v1.c,v 1.8 2001/08/22 21:17:56 jkar8572 Exp $"
#include <unistd.h>
#include <errno.h>
@@ -220,8 +220,7 @@ static struct dquot *v1_read_dquot(struct quota_handle *h, qid_t id)
if (QIO_ENABLED(h)) { /* Does kernel use the file? */
struct v1_kern_dqblk kdqblk;
- if (quotactl(QCMD(Q_V1_GETQUOTA, h->qh_type), h->qh_quotadev, id, (void *)&kdqblk) <
- 0) {
+ if (quotactl(QCMD(Q_V1_GETQUOTA, h->qh_type), h->qh_quotadev, id, (void *)&kdqblk) < 0) {
free(dquot);
return NULL;
}
diff --git a/quotaops.c b/quotaops.c
index 2168354..338cdf3 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: quotaops.c,v 1.5 2001/07/16 03:24:49 jkar8572 Exp $"
+#ident "$Id: quotaops.c,v 1.6 2001/08/22 21:17:56 jkar8572 Exp $"
#include <rpc/rpc.h>
#include <sys/types.h>
@@ -127,7 +127,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles)
euid = geteuid();
if (euid != id && euid != 0) {
uid2user(id, name);
- die(1, _("%s (uid %d): permission denied\n"), name, id);
+ die(1, _("%s (uid %d): Permission denied\n"), name, id);
}
break;
case GRPQUOTA:
@@ -143,7 +143,7 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles)
if (j >= ngroups && geteuid() != 0) {
gid2group(id, name);
- errstr(_("%s (gid %d): permission denied\n"),
+ errstr(_("%s (gid %d): Permission denied\n"),
name, id);
return (struct dquot *)NULL;
}
diff --git a/rquota_client.c b/rquota_client.c
index 553bc10..4b5a582 100644
--- a/rquota_client.c
+++ b/rquota_client.c
@@ -9,7 +9,7 @@
*
* This part does the rpc-communication with the rquotad.
*
- * Version: $Id: rquota_client.c,v 1.4 2001/08/15 20:13:42 jkar8572 Exp $
+ * Version: $Id: rquota_client.c,v 1.5 2001/08/22 21:17:56 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -100,10 +100,28 @@ static inline void cliutil2netdqblk(struct sq_dqblk *n, struct util_dqblk *u)
n->rq_ftimeleft = 0;
}
+/* Write appropriate error message */
+int rquota_err(int stat)
+{
+ switch (stat) {
+ case -1:
+ return -ECONNREFUSED;
+ case 0:
+ return -ENOSYS;
+ case Q_NOQUOTA:
+ case Q_OK:
+ return 0;
+ case Q_EPERM:
+ return -EPERM;
+ default:
+ return -EINVAL;
+ }
+}
+
/*
* Collect the requested quota information from a remote host.
*/
-void rpc_rquota_get(struct dquot *dquot)
+int rpc_rquota_get(struct dquot *dquot)
{
CLIENT *clnt;
getquota_rslt *result;
@@ -131,7 +149,7 @@ void rpc_rquota_get(struct dquot *dquot)
* automounter.
*/
if ((pathname = strchr(fsname_tmp, ':')) == (char *)0 || *(pathname + 1) == '(')
- return;
+ return -ENOENT;
*pathname++ = '\0';
@@ -168,12 +186,10 @@ void rpc_rquota_get(struct dquot *dquot)
*/
auth_destroy(clnt->cl_auth);
clnt_destroy(clnt);
- puts("get2");
}
- else {
+ else
result = NULL;
- }
- printf("result: %p, status: %d\n", result, result?result->status:0);
+
if (result == NULL || !result->status) {
if (dquot->dq_h->qh_type == USRQUOTA) {
/*
@@ -212,14 +228,14 @@ void rpc_rquota_get(struct dquot *dquot)
}
}
}
-
free(fsname_tmp);
+ return rquota_err(result?result->status:-1);
}
/*
* Set the requested quota information on a remote host.
*/
-void rpc_rquota_set(int qcmd, struct dquot *dquot)
+int rpc_rquota_set(int qcmd, struct dquot *dquot)
{
#if defined(RPC_SETQUOTA)
CLIENT *clnt;
@@ -243,7 +259,7 @@ void rpc_rquota_set(int qcmd, struct dquot *dquot)
* automounter.
*/
if ((pathname = strchr(fsname_tmp, ':')) == (char *)0 || *(pathname + 1) == '(')
- return;
+ return -ENOENT;
*pathname++ = '\0';
@@ -324,6 +340,7 @@ void rpc_rquota_set(int qcmd, struct dquot *dquot)
}
}
free(fsname_tmp);
+ return rquota_err(result?result->status:-1);
#endif
}
#endif
diff --git a/rquota_client.h b/rquota_client.h
index 7bf92b5..5753585 100644
--- a/rquota_client.h
+++ b/rquota_client.h
@@ -10,9 +10,9 @@
#include "quotaio.h"
/* Collect the requested quota information from a remote host. */
-void rpc_rquota_get(struct dquot *dquot);
+int rpc_rquota_get(struct dquot *dquot);
/* Set the requested quota information on a remote host. */
-void rpc_rquota_set(int qcmd, struct dquot *dquot);
+int rpc_rquota_set(int qcmd, struct dquot *dquot);
#endif
diff --git a/rquota_server.c b/rquota_server.c
index d044049..8956a1d 100644
--- a/rquota_server.c
+++ b/rquota_server.c
@@ -9,7 +9,7 @@
*
* This part does the lookup of the info.
*
- * Version: $Id: rquota_server.c,v 1.7 2001/08/21 15:34:31 jkar8572 Exp $
+ * Version: $Id: rquota_server.c,v 1.8 2001/08/22 21:17:56 jkar8572 Exp $
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
@@ -248,12 +248,10 @@ getquota_rslt *getquotainfo(int flags, caddr_t * argp, struct svc_req * rqstp)
end_mounts_scan();
goto out;
}
- printf("dev: %s dir: %s\n", mnt->mnt_fsname, mnt->mnt_dir);
if (!(handles[0] = init_io(mnt, type, -1, IOI_READONLY))) {
end_mounts_scan();
goto out;
}
- printf("Returned: %p\n", handles[0]);
end_mounts_scan();
if (!(flags & ACTIVE) || QIO_ENABLED(handles[0]))
dquot = handles[0]->qh_ops->read_dquot(handles[0], id);
@@ -265,7 +263,6 @@ getquota_rslt *getquotainfo(int flags, caddr_t * argp, struct svc_req * rqstp)
}
out:
dispose_handle_list(handles);
- printf("state: %d\n", result.status);
return (&result);
}
diff --git a/rquota_svc.c b/rquota_svc.c
index 591a9ef..ec37909 100644
--- a/rquota_svc.c
+++ b/rquota_svc.c
@@ -10,7 +10,7 @@
*
* Author: Marco van Wieringen <mvw@planets.elm.net>
*
- * Version: $Id: rquota_svc.c,v 1.4 2001/08/21 15:34:32 jkar8572 Exp $
+ * Version: $Id: rquota_svc.c,v 1.5 2001/08/22 21:17:56 jkar8572 Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -30,6 +30,7 @@
#ifdef HOSTS_ACCESS
#include <tcpd.h>
#include <netdb.h>
+#include <arpa/inet.h>
#endif
#ifdef __STDC__
@@ -61,7 +62,7 @@ int good_client(struct sockaddr_in *addr)
if (hosts_ctl("rquotad", "", inet_ntoa(addr->sin_addr), ""))
return 1;
/* Get address */
- if (!(h = gethostbyaddr(&(addr->sin_addr), sizeof(addr->sin_addr), AF_INET)))
+ if (!(h = gethostbyaddr((const char *)&(addr->sin_addr), sizeof(addr->sin_addr), AF_INET)))
return 0;
if (!(name = alloca(strlen(h->h_name)+1)))
return 0;