[net.news.b] Local network mods to 2.10.2

joe@fluke.UUCP (Joe Kelsey) (09/22/84)

Well, since we are seeing quite an explosion in local networks along with a
large number of wierd and inconsistent host names.  It seems like it is just
too hard to avoid conflicts in names as these networks expand.  Witness the
flap last year over the name 'garfield', the latest entry in
net.news.newsite for site 'x' at CRDS, etc.  We faced this problem a long
time ago here at Fluke and came up with a fair solution.  We have fairly
unimaginitive names for our local VAXen - vax1, vax2, vax3, vax4.  However,
each system contains a full alias database for ALL users on ALL systems, so
no one has to remember which system their friends are on - they just treat
the systems as one giant local host for mail.  This is easy to do as it only
involves the alias database and works for all systems with alias databases
regardless of whether or not you are running sendmail...The only slightly
tricky part is making sure all hosts are relatively up to date with their
alias databases, and that is easily done by copying the alias database from
the master system to all the subordinates every night.

News is a little more difficult.  The news softwre has basically two
variables which are used to build host identifiers: FULLSYSNAME and
MYDOMAIN. (There is also SYSNAME, but that is just a sanitized version of
FULLSYSNAME.)  FULLSYSNAME is acquired either from the uname sys call for
USG systems, gethostname for 4.2 systems, or by reading whoami.h on all
other systems.  This means that when ever you run news on a local system,
you always get the local system name in your addresses.  This is bad if you
want to hide the structure of your local network for the users AND from the
outside world.  I have a solution here.  It is a quite simple change to
news.

What I do is add a new variable, LOCLASYSNAME, which will the return
value from uname().  FULLSYSNAME is now initialized from a #define constant
called HIDDENNET.  HIDDENNET is #define'd in defs.h to be a string
containing the you want to advertise to the outside world.  Here, I added
the following line to localize.sh:

/MYDOMAIN/i
#define HIDDENNET "fluke"	/* hide local hosts behind a network name */
.

Then, you need to midify params.h to add the extern declaration of
LOCALSYSNAME.  Also, here is the fix for 4.2 systems since time.h is now in
/usr/include/sys:

*** /tmp/,RCSt1026477	Fri Sep 21 14:35:03 1984
--- params.h	Wed Sep 12 08:35:41 1984
***************
*** 11,17
  #include <pwd.h>
  #include <sys/stat.h>
  #include <ctype.h>
- #include <time.h>
  
  #include "defs.h"
  

--- 11,16 -----
  #include <pwd.h>
  #include <sys/stat.h>
  #include <ctype.h>
  
  #include "defs.h"
  
***************
*** 15,20
  
  #include "defs.h"
  
  #ifndef UNAME
  /*
   * 9 bytes is for compatibility with USG, in case you forget to define UNAME.

--- 14,25 -----
  
  #include "defs.h"
  
+ #ifdef BSD4_2
+ #include <sys/time.h>
+ #else
+ #include <time.h>
+ #endif BSD4_2
+ 
  #ifndef UNAME
  /*
   * 9 bytes is for compatibility with USG, in case you forget to define UNAME.
***************
*** 65,70
  extern	char	*TELLME;
  #endif
  
  extern	char	*FULLSYSNAME;
  #ifndef SHELL
  extern char	*SHELL;

--- 70,78 -----
  extern	char	*TELLME;
  #endif
  
+ #ifdef HIDDENNET
+ extern 	char	*LOCALSYSNAME;
+ #endif HIDDENNET
  extern	char	*FULLSYSNAME;
  #ifndef SHELL
  extern char	*SHELL;

Then, we need to modify control.c to correct some of the references to our
name in some control messages.  This is not absolutely necessary, but I did
it so that some of the mail you get from control messages is clearer.
Otherwise, you have a hard time telling which local system a given control
message response is from:

*** /tmp/,RCSt1026483	Fri Sep 21 14:35:43 1984
--- control.c	Wed Sep 12 13:39:14 1984
***************
*** 651,656
  		fprintf(fp, "Date: %s\n", arpadate(&now));
  		fprintf(fp, "To: %s\n", to);
  		fprintf(fp, "Subject: %s\n", subject);
  		fprintf(fp, "Responding-System: %s%s\n", FULLSYSNAME, MYDOMAIN);
  	}
  	return fp;

--- 659,667 -----
  		fprintf(fp, "Date: %s\n", arpadate(&now));
  		fprintf(fp, "To: %s\n", to);
  		fprintf(fp, "Subject: %s\n", subject);
+ #ifdef HIDDENNET
+ 		fprintf(fp, "Responding-System: %s.%s%s\n", LOCALSYSNAME, FULLSYSNAME, MYDOMAIN);
+ #else !HIDDENNET
  		fprintf(fp, "Responding-System: %s%s\n", FULLSYSNAME, MYDOMAIN);
  #endif HIDDENNET
  	}
***************
*** 652,657
  		fprintf(fp, "To: %s\n", to);
  		fprintf(fp, "Subject: %s\n", subject);
  		fprintf(fp, "Responding-System: %s%s\n", FULLSYSNAME, MYDOMAIN);
  	}
  	return fp;
  }

--- 663,669 -----
  		fprintf(fp, "Responding-System: %s.%s%s\n", LOCALSYSNAME, FULLSYSNAME, MYDOMAIN);
  #else !HIDDENNET
  		fprintf(fp, "Responding-System: %s%s\n", FULLSYSNAME, MYDOMAIN);
+ #endif HIDDENNET
  	}
  	return fp;
  }

Similarly, we need to modify ifuncs.c so that it generates unique article
id's - otherwise articles posted on local machines will probably have
overlapping ids:

*** /tmp/,RCSt1026513	Fri Sep 21 14:36:42 1984
--- ifuncs.c	Wed Sep 12 08:26:41 1984
***************
*** 475,480
  	fprintf(fp, "%ld\n", seqn);
  	fclose(fp);
  	unlock();
  	sprintf(hp->ident, "<%ld@%s%s>", seqn, FULLSYSNAME, MYDOMAIN);
  }
  

--- 475,483 -----
  	fprintf(fp, "%ld\n", seqn);
  	fclose(fp);
  	unlock();
+ #ifdef HIDDENNET
+ 	sprintf(hp->ident, "<%ld@%s.%s%s>", seqn, LOCALSYSNAME, FULLSYSNAME, MYDOMAIN);
+ #else !HIDDENNET
  	sprintf(hp->ident, "<%ld@%s%s>", seqn, FULLSYSNAME, MYDOMAIN);
  #endif HIDDENNET
  }
***************
*** 476,481
  	fclose(fp);
  	unlock();
  	sprintf(hp->ident, "<%ld@%s%s>", seqn, FULLSYSNAME, MYDOMAIN);
  }
  
  /*

--- 479,485 -----
  	sprintf(hp->ident, "<%ld@%s.%s%s>", seqn, LOCALSYSNAME, FULLSYSNAME, MYDOMAIN);
  #else !HIDDENNET
  	sprintf(hp->ident, "<%ld@%s%s>", seqn, FULLSYSNAME, MYDOMAIN);
+ #endif HIDDENNET
  }
  
  /*

I also modify the id presented in mail sent by inews so that you can
separate local systems when you have problems:

*** /tmp/,RCSt1026537	Fri Sep 21 14:37:54 1984
--- inews.c	Wed Sep 12 08:28:14 1984
***************
*** 96,101
  	if (!rwaccess(ARTFILE)) {
  		mfd = mailhdr((struct hbuf *)NULL, exists(ARTFILE) ? "Unwritable files!" : "Missing files!");
  		if (mfd != NULL) {
  			fprintf(mfd,"System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ARTFILE);
  			sprintf(cbuf, "touch %s;chmod 666 %s", ARTFILE, ARTFILE);
  			system(cbuf);

--- 96,104 -----
  	if (!rwaccess(ARTFILE)) {
  		mfd = mailhdr((struct hbuf *)NULL, exists(ARTFILE) ? "Unwritable files!" : "Missing files!");
  		if (mfd != NULL) {
+ #ifdef HIDDENNET
+ 			fprintf(mfd,"System: %s.%s\n\nThere was a problem with %s!!\n", LOCALSYSNAME, FULLSYSNAME, ARTFILE);
+ #else !HIDDENNET
  			fprintf(mfd,"System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ARTFILE);
  #endif HIDDENNET
  			sprintf(cbuf, "touch %s;chmod 666 %s", ARTFILE, ARTFILE);
***************
*** 97,102
  		mfd = mailhdr((struct hbuf *)NULL, exists(ARTFILE) ? "Unwritable files!" : "Missing files!");
  		if (mfd != NULL) {
  			fprintf(mfd,"System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ARTFILE);
  			sprintf(cbuf, "touch %s;chmod 666 %s", ARTFILE, ARTFILE);
  			system(cbuf);
  			if (rwaccess(ARTFILE))

--- 100,106 -----
  			fprintf(mfd,"System: %s.%s\n\nThere was a problem with %s!!\n", LOCALSYSNAME, FULLSYSNAME, ARTFILE);
  #else !HIDDENNET
  			fprintf(mfd,"System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ARTFILE);
+ #endif HIDDENNET
  			sprintf(cbuf, "touch %s;chmod 666 %s", ARTFILE, ARTFILE);
  			system(cbuf);
  			if (rwaccess(ARTFILE))
***************
*** 109,114
  	if (!rwaccess(ACTIVE)) {
  		mfd = mailhdr((struct hbuf *)NULL, exists(ACTIVE) ? "Unwritable files!" : "Missing files!");
  		if (mfd != NULL) {
  			fprintf(mfd, "System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ACTIVE);
  			sprintf(cbuf, "touch %s;chmod 666 %s", ACTIVE, ACTIVE);
  			system(cbuf);

--- 113,121 -----
  	if (!rwaccess(ACTIVE)) {
  		mfd = mailhdr((struct hbuf *)NULL, exists(ACTIVE) ? "Unwritable files!" : "Missing files!");
  		if (mfd != NULL) {
+ #ifdef HIDDENNET
+ 			fprintf(mfd, "System: %s.%s\n\nThere was a problem with %s!!\n", LOCALSYSNAME, FULLSYSNAME, ACTIVE);
+ #else
  			fprintf(mfd, "System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ACTIVE);
  #endif HIDDENNET
  			sprintf(cbuf, "touch %s;chmod 666 %s", ACTIVE, ACTIVE);
***************
*** 110,115
  		mfd = mailhdr((struct hbuf *)NULL, exists(ACTIVE) ? "Unwritable files!" : "Missing files!");
  		if (mfd != NULL) {
  			fprintf(mfd, "System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ACTIVE);
  			sprintf(cbuf, "touch %s;chmod 666 %s", ACTIVE, ACTIVE);
  			system(cbuf);
  			if (rwaccess(ACTIVE))

--- 117,123 -----
  			fprintf(mfd, "System: %s.%s\n\nThere was a problem with %s!!\n", LOCALSYSNAME, FULLSYSNAME, ACTIVE);
  #else
  			fprintf(mfd, "System: %s\n\nThere was a problem with %s!!\n", FULLSYSNAME, ACTIVE);
+ #endif HIDDENNET
  			sprintf(cbuf, "touch %s;chmod 666 %s", ACTIVE, ACTIVE);
  			system(cbuf);
  			if (rwaccess(ACTIVE))

The real heart of the change is in pathinit.c.  Here we copy the return from
uname into LOCALSYSNAME, and copy HIDDENNET to FULLSYSNAME:

*** /tmp/,RCSt1026559	Fri Sep 21 14:38:33 1984
--- pathinit.c	Wed Sep 12 08:29:14 1984
***************
*** 38,43
  
  char *FULLSYSNAME, *SPOOL, *LIB, *BIN, *ACTIVE, *OLDNEWS, *SUBFILE, *ARTFILE,
  	*MAILPARSER, *LOCKFILE, *SEQFILE, *ARTICLE, *INFILE, *ALIASES,
  	*TELLME, *username, *userhome;
  
  extern char bfr[];

--- 38,46 -----
  
  char *FULLSYSNAME, *SPOOL, *LIB, *BIN, *ACTIVE, *OLDNEWS, *SUBFILE, *ARTFILE,
  	*MAILPARSER, *LOCKFILE, *SEQFILE, *ARTICLE, *INFILE, *ALIASES,
+ #ifdef HIDDENNET
+ 	*LOCALSYSNAME,
+ #endif HIDDENNET
  	*TELLME, *username, *userhome;
  
  extern char bfr[];
***************
*** 76,81
  	struct utsname ubuf;
  
  	uname(&ubuf);
  	FULLSYSNAME = AllocCpy(ubuf.nodename);
  #endif INEW || READ
  

--- 79,88 -----
  	struct utsname ubuf;
  
  	uname(&ubuf);
+ #ifdef HIDDENNET
+ 	LOCALSYSNAME = AllocCpy(ubuf.nodename);
+ 	FULLSYSNAME = AllocCpy(HIDDENNET);
+ #else !HIDDENNET
  	FULLSYSNAME = AllocCpy(ubuf.nodename);
  #endif HIDDENNET
  #endif INEW || READ
***************
*** 77,82
  
  	uname(&ubuf);
  	FULLSYSNAME = AllocCpy(ubuf.nodename);
  #endif INEW || READ
  
  #ifdef HOME

--- 84,90 -----
  	FULLSYSNAME = AllocCpy(HIDDENNET);
  #else !HIDDENNET
  	FULLSYSNAME = AllocCpy(ubuf.nodename);
+ #endif HIDDENNET
  #endif INEW || READ
  
  #ifdef HOME

That's it.  After you install this change you will  notice that your old sys
files probably won't work.  This is because now every local system thinks it
has the name specified in HIDDENNET.  This is a blessing in disguise,
because you can now have absolutely IDENTICAL sys files on every local
system, except for the one you choose to be the interface to the outside
world.  This makes administration of multiple systems much easier.
For example, here is the sys file for all of my local machines:
#
# John Fluke Mfg. Co., Inc.
#
# local machine sys file
# every UNIX node in our local net has the same sys file!  (Every machine
# thinks it is fluke!)
#
fluke:fluke,seattle,pnw,na,usa,mod,net,to,uwcsa,ug
# vax4 is the central server (for now)
vax4:all::/usr/local/news/bnstore vax4

The same changes I have outlined can be applied to 2.10.1, with minor
changes left as an exercise for the reader.

/Joe