summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjkar8572 <jkar8572>2002-11-28 22:02:04 +0000
committerjkar8572 <jkar8572>2002-11-28 22:02:04 +0000
commit227feaf313ae6e10cdfb9d4d79c7f9896c773fe5 (patch)
treefe122c51be60c57291a998dafbb6dbe8076e341f
parentc243c5801fe4f8be02c8f716ca2897b083e27c74 (diff)
Optimized linking with svc_socket.o; fixed error reporting in svc_socket.c (Jan Kara)
-rw-r--r--Changelog1
-rw-r--r--Makefile.in5
-rw-r--r--quotacheck.c6
-rw-r--r--rquota_svc.c9
-rw-r--r--svc_socket.c52
5 files changed, 35 insertions, 38 deletions
diff --git a/Changelog b/Changelog
index 9f588b9..e298b79 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,5 @@
Changes in quota-tools from 3.07 to 3.08
+* Fixed infinite loop in quotacheck under RH7.1 (?)
* Made quota tools aware of /etc/services (H. J. Lu)
* 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)
diff --git a/Makefile.in b/Makefile.in
index 1a3c399..55725d2 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,6 +1,6 @@
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 svc_socket.c
-VERSIONDEF = -DQUOTA_VERSION=\"3.07\"
+VERSIONDEF = -DQUOTA_VERSION=\"3.08\"
CFLAGS = @CFLAGS@ @EXT2_DIRECT@ -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $(VERSIONDEF)
EXT2LIBS = @EXT2LIBS@
RPCSRC = rquota.h rquota_xdr.c rquota_clnt.c
@@ -36,7 +36,6 @@ 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@
@@ -124,7 +123,7 @@ setquota: setquota.o quotaops.o $(LIBOBJS)
convertquota: convertquota.o $(LIBOBJS)
-rpc.rquotad: rquota_server.o rquota_svc.o $(LIBOBJS)
+rpc.rquotad: rquota_server.o rquota_svc.o svc_socket.o $(LIBOBJS)
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
pot.o: pot.c pot.h
diff --git a/quotacheck.c b/quotacheck.c
index 9ee10d9..ccdc3d0 100644
--- a/quotacheck.c
+++ b/quotacheck.c
@@ -8,7 +8,7 @@
* New quota format implementation - Jan Kara <jack@suse.cz> - Sponsored by SuSE CR
*/
-#ident "$Id: quotacheck.c,v 1.32 2002/08/27 18:13:41 jkar8572 Exp $"
+#ident "$Id: quotacheck.c,v 1.33 2002/11/28 22:02:04 jkar8572 Exp $"
#include <dirent.h>
#include <stdio.h>
@@ -400,9 +400,9 @@ static int ext2_direct_scan(char *device)
return -1;
}
- while (i_num) {
+ while ((long)i_num) {
if (inode.i_links_count) {
- debug(FL_DEBUG, _("Found i_num %ld\n"), i_num);
+ debug(FL_DEBUG, _("Found i_num %ld\n"), (long)i_num);
if (flags & FL_VERBOSE)
blit();
uid = inode.i_uid | (inode.i_uid_high << 16);
diff --git a/rquota_svc.c b/rquota_svc.c
index 86a8f51..d37d591 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.12 2002/11/21 21:15:26 jkar8572 Exp $
+ * Version: $Id: rquota_svc.c,v 1.13 2002/11/28 22:02:04 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
@@ -365,6 +365,7 @@ int main(int argc, char **argv)
{
register SVCXPRT *transp;
struct sigaction sa;
+ int sock;
gettexton();
progname = basename(argv[0]);
@@ -384,7 +385,8 @@ int main(int argc, char **argv)
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
- transp = svcudp_create(svcudp_socket (RQUOTAPROG, 1));
+ sock = svcudp_socket(RQUOTAPROG, 1);
+ transp = svcudp_create(sock == -1 ? RPC_ANYSOCK : sock);
if (transp == NULL) {
errstr(_("cannot create udp service.\n"));
exit(1);
@@ -398,7 +400,8 @@ int main(int argc, char **argv)
exit(1);
}
- transp = svctcp_create(svctcp_socket (RQUOTAPROG, 1), 0, 0);
+ sock = svctcp_socket(RQUOTAPROG, 1);
+ transp = svctcp_create(sock == -1 ? RPC_ANYSOCK : sock, 0, 0);
if (transp == NULL) {
errstr(_("cannot create tcp service.\n"));
exit(1);
diff --git a/svc_socket.c b/svc_socket.c
index 4abb37c..27cbfb7 100644
--- a/svc_socket.c
+++ b/svc_socket.c
@@ -20,42 +20,41 @@
#include <string.h>
#include <unistd.h>
#include <netdb.h>
+#include <errno.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
-#include <errno.h>
+#include "common.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;
+ struct rpcent rpcbuf, *rpcp = NULL;
+ struct servent servbuf, *servp = NULL;
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;
+ errstr(_("Cannot create socket: %s\n"), strerror(errno));
+ return -1;
}
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;
+ if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &ret, sizeof(ret)) < 0) {
+ errstr(_("Cannot set socket options: %s\n"), strerror(errno));
+ return -1;
}
}
- memset(&addr, sizeof (addr), 0);
+ memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
- ret = getrpcbynumber_r (number, &rpcbuf, rpcdata, sizeof(rpcdata), &rpcp);
+ ret = getrpcbynumber_r(number, &rpcbuf, rpcdata, sizeof(rpcdata), &rpcp);
if (ret == 0 && rpcp != NULL) {
- /* First try name. */
+ /* First try name */
ret = getservbyname_r(rpcp->r_name, proto, &servbuf, servdata,
sizeof servdata, &servp);
if ((ret != 0 || servp == NULL) && rpcp->r_aliases) {
@@ -63,7 +62,7 @@ static int svc_socket (u_long number, int type, int protocol, int reuse)
/* Then we try aliases. */
for (a = (const char **) rpcp->r_aliases; *a != NULL; a++) {
- ret = getservbyname_r (*a, proto, &servbuf, servdata,
+ ret = getservbyname_r(*a, proto, &servbuf, servdata,
sizeof servdata, &servp);
if (ret == 0 && servp != NULL)
break;
@@ -73,21 +72,16 @@ static int svc_socket (u_long number, int type, int protocol, int reuse)
if (ret == 0 && servp != NULL) {
addr.sin_port = servp->s_port;
- if (bind (sock, (struct sockaddr *) &addr, len) < 0) {
- perror (_("svc_socket: bind problem"));
+ if (bind(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) < 0) {
+ errstr(_("Cannot bind to given address: %s\n"), strerror(errno));
close (sock);
- sock = -1;
+ return -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;
- }
- }
+ /* Service not found? */
+ close(sock);
+ return -1;
}
return sock;
@@ -96,15 +90,15 @@ static int svc_socket (u_long number, int type, int protocol, int reuse)
/*
* Create and bind a TCP socket based on program number
*/
-int svctcp_socket (u_long number, int reuse)
+int svctcp_socket(u_long number, int reuse)
{
- return svc_socket (number, SOCK_STREAM, IPPROTO_TCP, 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)
+int svcudp_socket(u_long number, int reuse)
{
- return svc_socket (number, SOCK_DGRAM, IPPROTO_UDP, reuse);
+ return svc_socket(number, SOCK_DGRAM, IPPROTO_UDP, reuse);
}