diff options
author | jkar8572 <jkar8572> | 2003-12-02 13:04:20 +0000 |
---|---|---|
committer | jkar8572 <jkar8572> | 2003-12-02 13:04:20 +0000 |
commit | 55695372e3d4d56f4ffa7dce973f97981e846ef0 (patch) | |
tree | ad88b360f2602ce8b9836a665e329fabeab36b09 | |
parent | ab3c71ee7d104782ef8576e0622563c35515c619 (diff) |
Implementing alternative port for rpc.rquotad to listen on.
-rw-r--r-- | Changelog | 1 | ||||
-rw-r--r-- | rquota_server.c | 10 | ||||
-rw-r--r-- | rquota_svc.c | 64 | ||||
-rw-r--r-- | rquotad.8 | 8 | ||||
-rw-r--r-- | svc_socket.c | 44 |
5 files changed, 83 insertions, 44 deletions
@@ -1,4 +1,5 @@ Changes in quota-tools from 3.09 to 3.10 +* alternative port can be specified to rpc.rquotad by -p option (Jan Kara) * Fixed processing of device-backed loop mounts (Jari Ruusu) * Fixed fake error messages from rpc.rquotad (Jan Kara) * quota(1) now does not print info for NFS filesystems without quotas (Jan Kara) diff --git a/rquota_server.c b/rquota_server.c index 6e20d74..3f2a6fd 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.13 2003/10/18 17:32:49 jkar8572 Exp $ + * Version: $Id: rquota_server.c,v 1.14 2003/12/02 13:04:20 jkar8572 Exp $ * * Author: Marco van Wieringen <mvw@planets.elm.net> * @@ -49,7 +49,9 @@ int allow_severity = LOG_INFO; int deny_severity = LOG_WARNING; -extern int enable_autofs; +/* Options from rquota_svc.c */ +#define FL_AUTOFS 4 +extern int flags; /* * Global unix authentication credentials. @@ -160,7 +162,7 @@ setquota_rslt *setquotainfo(int flags, caddr_t * argp, struct svc_req *rqstp) result.status = Q_NOQUOTA; result.setquota_rslt_u.sqr_rquota.rq_bsize = RPC_DQBLK_SIZE; - if (init_mounts_scan(1, &pathname, MS_QUIET | MS_NO_MNTPOINT | (enable_autofs ? 0 : MS_NO_AUTOFS)) < 0) + if (init_mounts_scan(1, &pathname, MS_QUIET | MS_NO_MNTPOINT | ((flags & FL_AUTOFS) ? 0 : MS_NO_AUTOFS)) < 0) goto out; if (!(mnt = get_next_mount())) { end_mounts_scan(); @@ -244,7 +246,7 @@ getquota_rslt *getquotainfo(int flags, caddr_t * argp, struct svc_req * rqstp) result.status = Q_NOQUOTA; result.getquota_rslt_u.gqr_rquota.rq_bsize = RPC_DQBLK_SIZE; - if (init_mounts_scan(1, &pathname, MS_QUIET | MS_NO_MNTPOINT | (enable_autofs ? 0 : MS_NO_AUTOFS)) < 0) + if (init_mounts_scan(1, &pathname, MS_QUIET | MS_NO_MNTPOINT | ((flags & FL_AUTOFS) ? 0 : MS_NO_AUTOFS)) < 0) goto out; if (!(mnt = get_next_mount())) { end_mounts_scan(); diff --git a/rquota_svc.c b/rquota_svc.c index 0398275..191182f 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.15 2003/09/25 14:51:59 jkar8572 Exp $ + * Version: $Id: rquota_svc.c,v 1.16 2003/12/02 13:04:20 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 @@ -41,8 +41,8 @@ #define SIG_PF void(*)(int) #endif -extern int svctcp_socket (u_long __number, int __reuse); -extern int svcudp_socket (u_long __number, int __reuse); +extern int svctcp_socket (u_long __number, int __port, int __reuse); +extern int svcudp_socket (u_long __number, int __port, int __reuse); #include "pot.h" #include "common.h" @@ -56,9 +56,12 @@ char *progname; */ struct authunix_parms *unix_cred; -int disable_setquota=1; /* Disables setquota rpc */ -int disable_daemon=0; /* Disable daemon() call */ -int enable_autofs=0; /* Don't ignore autofs mountpoins */ +#define FL_SETQUOTA 1 /* Enable setquota rpc */ +#define FL_NODAEMON 2 /* Disable daemon() call */ +#define FL_AUTOFS 4 /* Don't ignore autofs mountpoints */ + +int flags; /* Options specified on command line */ +int port; /* Port to use (0 for default one) */ static struct option options[]= { { "version", 0, NULL, 'V' }, @@ -69,6 +72,7 @@ static struct option options[]= { { "setquota", 0, NULL, 'S' }, #endif { "autofs", 0, NULL, 'I'}, + { "port", 1, NULL, 'p' }, { NULL, 0, NULL , 0 } }; @@ -81,20 +85,22 @@ static void show_help(void) -F --foreground starts the quota service in foreground\n\ -s --no-setquota disables remote calls to setquota (default)\n\ -S --setquota enables remote calls to setquota\n\ - -I --autofs do not ignore mountpoints mounted by automounter\n"), progname); + -I --autofs do not ignore mountpoints mounted by automounter\n\ + -p --port <port> listen on given port\n"), progname); #else errstr(_("Usage: %s [options]\nOptions are:\n\ -h --help shows this text\n\ -V --version shows version information\n\ -F --foreground starts the quota service in foreground\n\ - -I --autofs do not ignore mountpoints mounted by automounter\n"), progname); + -I --autofs do not ignore mountpoints mounted by automounter\n\ + -p --port <port> listen on given port\n"), progname); #endif } static void parse_options(int argc, char **argv) { - char ostr[128]=""; + char ostr[128]="", *endptr; int i,opt; int j=0; @@ -104,14 +110,34 @@ static void parse_options(int argc, char **argv) } while ((opt=getopt_long(argc, argv, ostr, options, NULL))>=0) { switch(opt) { - case 'V': version(); exit(0); - case 'h': show_help(); exit(0); - case 'F': disable_daemon = 1; break; + case 'V': + version(); + exit(0); + case 'h': + show_help(); + exit(0); + case 'F': + flags |= FL_NODAEMON; + break; #ifdef RPC_SETQUOTA - case 's': disable_setquota = 1; break; - case 'S': disable_setquota = 0; break; + case 's': + flags &= ~FL_SETQUOTA; + break; + case 'S': + flags |= FL_SETQUOTA; + break; #endif - case 'I': enable_autofs = 1; break; + case 'I': + flags |= FL_AUTOFS; + break; + case 'p': + port = strtol(optarg, &endptr, 0); + if (*endptr || port <= 0) { + errstr(_("Illegal port number: %s\n"), optarg); + show_help(); + exit(1); + } + break; default: errstr(_("Unknown option '%c'.\n"), opt); show_help(); @@ -136,7 +162,7 @@ int good_client(struct sockaddr_in *addr, ulong rq_proc) if (rq_proc==RQUOTAPROC_SETQUOTA || rq_proc==RQUOTAPROC_SETACTIVEQUOTA) { /* If setquota is disabled, fail always */ - if (disable_setquota) { + if (!(flags & FL_SETQUOTA)) { errstr(_("host %s attempted to call setquota when disabled\n"), remote); @@ -392,7 +418,7 @@ int main(int argc, char **argv) sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); - sock = svcudp_socket(RQUOTAPROG, 1); + sock = svcudp_socket(RQUOTAPROG, port, 1); transp = svcudp_create(sock == -1 ? RPC_ANYSOCK : sock); if (transp == NULL) { errstr(_("cannot create udp service.\n")); @@ -407,7 +433,7 @@ int main(int argc, char **argv) exit(1); } - sock = svctcp_socket(RQUOTAPROG, 1); + sock = svctcp_socket(RQUOTAPROG, port, 1); transp = svctcp_create(sock == -1 ? RPC_ANYSOCK : sock, 0, 0); if (transp == NULL) { errstr(_("cannot create tcp service.\n")); @@ -422,7 +448,7 @@ int main(int argc, char **argv) exit(1); } - if (!disable_daemon) { + if (!(flags & FL_NODAEMON)) { use_syslog(); daemon(0, 0); } @@ -4,7 +4,9 @@ rquotad, rpc.rquotad \- remote quota server .SH SYNOPSIS .B rpc.rquotad [ -.B \-sSF +.B \-sSFI +] [ +.B \-p \f2port\f1 ] .SH DESCRIPTION .LP @@ -62,6 +64,10 @@ Run daemon in foreground (may be useful for debugging purposes). .TP .B \-I, \-\-autofs Do not ignore autofs mountpoints. +.TP +.B \-p \f2port\f3, \-\-port \f2port\f1 +Listen on alternate port +.IR port. .SH FILES .PD 0 diff --git a/svc_socket.c b/svc_socket.c index 27cbfb7..bdf8e15 100644 --- a/svc_socket.c +++ b/svc_socket.c @@ -27,7 +27,7 @@ #include "common.h" #include "pot.h" -static int svc_socket (u_long number, int type, int protocol, int reuse) +static int svc_socket (u_long number, int type, int protocol, int port, int reuse) { struct sockaddr_in addr; char rpcdata [1024], servdata [1024]; @@ -52,26 +52,30 @@ static int svc_socket (u_long number, int type, int protocol, int reuse) memset(&addr, 0, sizeof(addr)); 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; + if (!port) { + 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; + /* 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) + port = servp->s_port; } } - if (ret == 0 && servp != NULL) { - addr.sin_port = servp->s_port; + if (port) { + addr.sin_port = port; if (bind(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) < 0) { errstr(_("Cannot bind to given address: %s\n"), strerror(errno)); close (sock); @@ -90,15 +94,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 port, int reuse) { - return svc_socket(number, SOCK_STREAM, IPPROTO_TCP, reuse); + return svc_socket(number, SOCK_STREAM, IPPROTO_TCP, port, 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 port, int reuse) { - return svc_socket(number, SOCK_DGRAM, IPPROTO_UDP, reuse); + return svc_socket(number, SOCK_DGRAM, IPPROTO_UDP, port, reuse); } |