summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2002-11-21 21:15:26 +0000
committerjkar8572 <jkar8572>2002-11-21 21:15:26 +0000
commitedd700c9902a76af807794e00a121dd64d12efde (patch)
treeef58d18a03cb14e96d1b6bf97fa436a3df808f41
parentad868a7b3e1c2cdaeddcf93b8ccf55434b0d1c21 (diff)
downloadlinuxquota-edd700c9902a76af807794e00a121dd64d12efde.tar.gz
Made quota tools aware of /etc/services (unknown)
-rw-r--r--Changelog1
-rw-r--r--Makefile.in3
-rw-r--r--edquota.c6
-rw-r--r--rquota_svc.c28
-rw-r--r--svc_socket.c110
5 files changed, 141 insertions, 7 deletions
diff --git a/Changelog b/Changelog
index 4bcac48..86174cf 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
Changes in quota-tools from 3.07 to 3.08
+* Made quota tools aware of /etc/services (?)
* Updated edquota(8) and setquota(8) to allow setting of individual grace time (Jan Kara)
* Fixed bug in convertquota(8) when quota was turned on during converting (Jan Kara)
* Add support for XFS filesystems without root special casing (Christoph Hellwig)
diff --git a/Makefile.in b/Makefile.in
index 99373cf..1a3c399 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,5 +1,5 @@
PROGS = quotacheck quotaon quota quot repquota warnquota quotastats xqmstats edquota setquota convertquota rpc.rquotad
-SOURCES = bylabel.c common.c convertquota.c edquota.c pot.c quot.c quota.c quotacheck.c quotacheck_v1.c quotacheck_v2.c quotaio.c quotaio_rpc.c quotaio_v1.c quotaio_v2.c quotaio_xfs.c quotaio_generic.c quotaon.c quotaon_xfs.c quotaops.c quotastats.c quotasys.c repquota.c rquota_client.c rquota_server.c rquota_svc.c setquota.c warnquota.c xqmstats.c
+SOURCES = bylabel.c common.c convertquota.c edquota.c pot.c quot.c quota.c quotacheck.c quotacheck_v1.c quotacheck_v2.c quotaio.c quotaio_rpc.c quotaio_v1.c quotaio_v2.c quotaio_xfs.c quotaio_generic.c quotaon.c quotaon_xfs.c quotaops.c quotastats.c quotasys.c repquota.c rquota_client.c rquota_server.c rquota_svc.c setquota.c warnquota.c xqmstats.c svc_socket.c
VERSIONDEF = -DQUOTA_VERSION=\"3.07\"
CFLAGS = @CFLAGS@ @EXT2_DIRECT@ -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(VERSIONDEF)
EXT2LIBS = @EXT2LIBS@
@@ -36,6 +36,7 @@ sysconfdir = @sysconfdir@
RPCCLNTOBJS = rquota_xdr.o rquota_client.o rquota_clnt.o
IOOBJS = quotaio.o quotaio_v1.o quotaio_v2.o quotaio_rpc.o quotaio_xfs.o quotaio_generic.o
IOOBJS += $(RPCCLNTOBJS)
+IOOBJS += svc_socket.o
LIBOBJS = bylabel.o common.o quotasys.o pot.o $(IOOBJS)
LIBOBJS += @LIBMALLOC@
diff --git a/edquota.c b/edquota.c
index 82833fc..399a7cb 100644
--- a/edquota.c
+++ b/edquota.c
@@ -34,7 +34,7 @@
#ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $"
#ident "$Copyright: All rights reserved. $"
-#ident "$Id: edquota.c,v 1.10 2002/11/21 18:37:58 jkar8572 Exp $"
+#ident "$Id: edquota.c,v 1.11 2002/11/21 21:15:26 jkar8572 Exp $"
/*
* Disk quota editor.
@@ -176,7 +176,7 @@ int main(int argc, char **argv)
update_grace_times(cprivs);
}
}
- putprivs(curprivs);
+ putprivs(curprivs, COMMIT_LIMITS);
freeprivs(curprivs);
}
dispose_handle_list(handles);
@@ -244,7 +244,7 @@ int main(int argc, char **argv)
errstr(_("Can't read quotas from file.\n"));
continue;
}
- putprivs(curprivs);
+ putprivs(curprivs, COMMIT_LIMITS);
freeprivs(curprivs);
}
}
diff --git a/rquota_svc.c b/rquota_svc.c
index fbece01..86a8f51 100644
--- a/rquota_svc.c
+++ b/rquota_svc.c
@@ -12,7 +12,7 @@
* changes for new utilities by Jan Kara <jack@suse.cz>
* patches by Jani Jaakkola <jjaakkol@cs.helsinki.fi>
*
- * Version: $Id: rquota_svc.c,v 1.11 2002/06/27 08:14:09 jkar8572 Exp $
+ * Version: $Id: rquota_svc.c,v 1.12 2002/11/21 21:15:26 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
@@ -31,6 +31,7 @@
#include <memory.h>
#include <unistd.h>
#include <getopt.h>
+#include <signal.h>
#ifdef HOSTS_ACCESS
#include <tcpd.h>
#include <netdb.h>
@@ -40,6 +41,9 @@
#define SIG_PF void(*)(int)
#endif
+extern int svctcp_socket (u_long __number, int __reuse);
+extern int svcudp_socket (u_long __number, int __reuse);
+
#include "pot.h"
#include "common.h"
#include "rquota.h"
@@ -350,9 +354,17 @@ static void rquotaprog_2(struct svc_req *rqstp, register SVCXPRT * transp)
return;
}
+static void
+unregister (int sig)
+{
+ (void)pmap_unset(RQUOTAPROG, RQUOTAVERS);
+ (void)pmap_unset(RQUOTAPROG, EXT_RQUOTAVERS);
+}
+
int main(int argc, char **argv)
{
register SVCXPRT *transp;
+ struct sigaction sa;
gettexton();
progname = basename(argv[0]);
@@ -362,7 +374,17 @@ int main(int argc, char **argv)
(void)pmap_unset(RQUOTAPROG, RQUOTAVERS);
(void)pmap_unset(RQUOTAPROG, EXT_RQUOTAVERS);
- transp = svcudp_create(RPC_ANYSOCK);
+ sa.sa_handler = SIG_IGN;
+ sa.sa_flags = 0;
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGCHLD, &sa, NULL);
+
+ sa.sa_handler = unregister;
+ sigaction(SIGHUP, &sa, NULL);
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
+ transp = svcudp_create(svcudp_socket (RQUOTAPROG, 1));
if (transp == NULL) {
errstr(_("cannot create udp service.\n"));
exit(1);
@@ -376,7 +398,7 @@ int main(int argc, char **argv)
exit(1);
}
- transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ transp = svctcp_create(svctcp_socket (RQUOTAPROG, 1), 0, 0);
if (transp == NULL) {
errstr(_("cannot create tcp service.\n"));
exit(1);
diff --git a/svc_socket.c b/svc_socket.c
new file mode 100644
index 0000000..4abb37c
--- /dev/null
+++ b/svc_socket.c
@@ -0,0 +1,110 @@
+/* Copyright (C) 2002 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <netdb.h>
+#include <rpc/rpc.h>
+#include <sys/socket.h>
+#include <errno.h>
+
+#include "pot.h"
+
+static int svc_socket (u_long number, int type, int protocol, int reuse)
+{
+ struct sockaddr_in addr;
+ socklen_t len = sizeof (struct sockaddr_in);
+ char rpcdata [1024], servdata [1024];
+ struct rpcent rpcbuf, *rpcp;
+ struct servent servbuf, *servp;
+ int sock, ret;
+ const char *proto = protocol == IPPROTO_TCP ? "tcp" : "udp";
+
+ if ((sock = socket (AF_INET, type, protocol)) < 0) {
+ perror (_("svc_socket: socket creation problem"));
+ return sock;
+ }
+
+ if (reuse) {
+ ret = 1;
+ ret = setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &ret, sizeof(ret));
+ if (ret < 0) {
+ perror (_("svc_socket: socket reuse problem"));
+ return ret;
+ }
+ }
+
+ memset(&addr, sizeof (addr), 0);
+ addr.sin_family = AF_INET;
+
+ ret = getrpcbynumber_r (number, &rpcbuf, rpcdata, sizeof(rpcdata), &rpcp);
+ if (ret == 0 && rpcp != NULL) {
+ /* First try name. */
+ ret = getservbyname_r(rpcp->r_name, proto, &servbuf, servdata,
+ sizeof servdata, &servp);
+ if ((ret != 0 || servp == NULL) && rpcp->r_aliases) {
+ const char **a;
+
+ /* Then we try aliases. */
+ for (a = (const char **) rpcp->r_aliases; *a != NULL; a++) {
+ ret = getservbyname_r (*a, proto, &servbuf, servdata,
+ sizeof servdata, &servp);
+ if (ret == 0 && servp != NULL)
+ break;
+ }
+ }
+ }
+
+ if (ret == 0 && servp != NULL) {
+ addr.sin_port = servp->s_port;
+ if (bind (sock, (struct sockaddr *) &addr, len) < 0) {
+ perror (_("svc_socket: bind problem"));
+ close (sock);
+ sock = -1;
+ }
+ }
+ else {
+ if (bindresvport (sock, &addr)) {
+ addr.sin_port = 0;
+ if (bind (sock, (struct sockaddr *) &addr, len) < 0) {
+ perror (_("svc_socket: bind problem"));
+ close (sock);
+ sock = -1;
+ }
+ }
+ }
+
+ return sock;
+}
+
+/*
+ * Create and bind a TCP socket based on program number
+ */
+int svctcp_socket (u_long number, int reuse)
+{
+ return svc_socket (number, SOCK_STREAM, IPPROTO_TCP, reuse);
+}
+
+/*
+ * Create and bind a UDP socket based on program number
+ */
+int svcudp_socket (u_long number, int reuse)
+{
+ return svc_socket (number, SOCK_DGRAM, IPPROTO_UDP, reuse);
+}