* <local-addr>,<peer-addr>,<mtu>,<proto>
* As for slattach. Supported protocols are slip, cslip, and
* adaptive. Alternatively, set to `debug' to print debugging
- * info. <local-addr> is address of the interface on chiark;
- * <peer-addr> is the address of the point-to-point peer.
+ * info. <local-addr> is address of the interface on the local
+ * system; <peer-addr> is the address of the point-to-point peer.
* <prefix>/<mask>,<prefix>/<mask>,...
* List of additional routes to add for this interface.
* May be the empty argument, or `-' if this is problematic.
*
* <config> is either
- * <gid>,<prefix>/<len>[,<junk>]
+ * <gid>,[=]<prefix>/<len>[,<junk>]
* indicating that that gid may allocate addresses in
* the relevant subspace (<junk> is ignored)
+ * if `=' is specified then it's only allowed for the local
+ * endpoint address
* or #...
* which is a comment
* or /<config-file-name> or ./<config-file-name> or ../<config-file-name>
*
* Should be run from userv with no-disconnect-hup.
*/
+/*
+ * Copyright (C) 1999 Ian Jackson
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with userv-utils; if not, write to the Free Software
+ * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
#include <stdio.h>
#include <string.h>
#define NARGS 4
#define MAXEXROUTES 5
-#define ATXTLEN 12
+#define ATXTLEN 16
static const unsigned long gidmaxval= (unsigned long)((gid_t)-2);
static const char *const protos_ok[]= { "slip", "cslip", "adaptive", 0 };
}
-static void permit(unsigned long pprefix, unsigned long pmask) {
+static void permit(unsigned long pprefix, unsigned long pmask, int localonly) {
int i, any;
assert(!(pprefix & ~pmask));
any= 0;
- if (!proto) fputs("permits",stdout);
+ if (!proto) fputs(localonly ? "permits-l" : "permits",stdout);
if (addrnet_isin(localaddr,~0UL, pprefix,pmask)) {
if (!proto) fputs(" local-addr",stdout);
any= localallow= 1;
}
- if (addrnet_isin(peeraddr,~0UL, pprefix,pmask)) {
- if (!proto) fputs(" peer-addr",stdout);
- any= peerallow= 1;
- }
- for (i=0; i<nexroutes; i++) {
- if (addrnet_isin(exroutes[i].prefix,exroutes[i].mask, pprefix,pmask)) {
- if (!proto) printf(" route#%d",i);
- any= exroutes[i].allow= 1;
+ if (!localonly) {
+ if (addrnet_isin(peeraddr,~0UL, pprefix,pmask)) {
+ if (!proto) fputs(" peer-addr",stdout);
+ any= peerallow= 1;
+ }
+ for (i=0; i<nexroutes; i++) {
+ if (addrnet_isin(exroutes[i].prefix,exroutes[i].mask, pprefix,pmask)) {
+ if (!proto) printf(" route#%d",i);
+ any= exroutes[i].allow= 1;
+ }
}
}
if (!proto) {
- if (!any) fputs(" nothing!",stderr);
+ if (!any) fputs(" nothing",stdout);
putchar('\n');
}
}
static void pconfig(const char *configstr, int truncated) {
unsigned long fgid, tgid, pprefix, pmask;
- int plen;
+ int plen, localonly;
char ptxt[ATXTLEN];
const char *gidlist;
switch (configstr[0]) {
case '*':
if (strcmp(configstr,"*")) badusage("`*' directive must be only thing on line");
- permit(0UL,0UL);
+ permit(0UL,0UL,0);
return;
case '#':
badusage("unknown configuration directive");
fgid= eat_number(&configstr,"gid", 0,gidmaxval, ",",0);
+ if (configstr[0] == '=') {
+ localonly= 1;
+ configstr++;
+ } else {
+ localonly= 0;
+ }
eat_prefixmask(&configstr,"permitted-prefix", ",",0, &pprefix,&pmask,&plen);
if (!configstr && truncated) badusage("gid,prefix/len,... spec too long");
tgid= eat_number(&gidlist,"userv-gid", 0,gidmaxval, " ",0);
if (tgid == fgid) break;
}
- permit(pprefix,pmask);
+ permit(pprefix,pmask,localonly);
return;
}
}