[comp.unix.xenix] Pathalias Problem

gumby@ucrmath.UCR.EDU (john donahue) (05/09/90)

My site just received some more map files in "comp.mail.maps"
last night and suddenly, pathalias no longer works. It is now complaining
that the argument list of files is too long. There are now 178 files in
my "/usr/spool/uucp/Maps" directory and when a shell script called
"/usr/lib/uucp/uugetmaps" is executed, pathalias is run with:

/usr/lib/uucp/pathalias -i /usr/spool/uucp/Maps/* > /tmp/paths

It complains that the "arg list too long" and terminates. I moved some of
the files to another directory temporarily so that it will work again
(when this failed, my "paths" file was truncated to 0 so then "smail"
would no longer resolve domain addresses).

So, do I need a better version of "getopt ()" than the one supplied
by SCO? I'm running v2.3.2 for the 386 (of the Dev system and the OS).
The Makefile for pathalias metions that you may "use your own getopts",
but since the OS provides it, I just used that one. Is there a better
one I should be using? Should I just "forget" about sites in Argentina
and other "remote" places? (These are the map files I moved from the
Maps directory so pathalias would work again).

Any ideas?

-- John

karl_kleinpaste@cis.ohio-state.edu (05/09/90)

gumby@ucrmath.UCR.EDU writes:
   ...pathalias is run with:
       /usr/lib/uucp/pathalias -i /usr/spool/uucp/Maps/* > /tmp/paths
   It complains that the "arg list too long" and terminates.

The problem is not with getopt(3).  The problem is that the number of
files is simply too large, for each to be a complete pathname not less
than 30 or so characters long -- the limit on how many things can be
passed to a program from the shell via argv[] is too small.

Change the way that pathalias is invoked, so that pathalias is invoked
from within the directory where the map files live:
	cd /usr/spool/uucp/Maps
	/usr/lib/uucp/pathalias -i * > /tmp/paths
and it'll probably work just fine again.

--karl

davidsen@zephyrus.Berkeley.EDU (william E Davidsen) (05/09/90)

In article <6145@ucrmath.UCR.EDU>, gumby@ucrmath.UCR.EDU (john donahue) writes:
 
> It complains that the "arg list too long" and terminates. I moved some of
> the files to another directory temporarily so that it will work again
> (when this failed, my "paths" file was truncated to 0 so then "smail"
> would no longer resolve domain addresses).

  This means the list is larger than the buffer size for argv (I believe
5k). A new version of getopt won't help, you never get that far. I
solved it by writing a little sed script which accepted the names of all
the files as input and output only the non-comment lines. I put all USA
in one file, all domain, world other than usa, etc. Then I pathalias the
combined files.

  The script is a one liner, maybe even two lines, like:
	sed "
	s/#.*$//
	/^$/d
	" u.usa.* >usa.all

daveh@marob.masa.com (Dave Hammond) (05/09/90)

In article <6145@ucrmath.UCR.EDU> gumby@ucrmath.ucr.edu (john donahue) writes:
>/usr/lib/uucp/pathalias -i /usr/spool/uucp/Maps/* > /tmp/paths
>It complains that the "arg list too long" and terminates.
>So, do I need a better version of "getopt ()" than the one supplied
>by SCO?

This message is generated by the shell (not getopt), when the number of
characters in the argument vector to some program exceeds the limit
imposed by execv() -- around 5000 characters, as I recall.  Try changing
to /usr/spool/uucp/Maps before running the command, as in:

cd /usr/lib/uucp/Maps
/usr/lib/uucp/pathalias -i * > /tmp/paths

This will reduce the number of chars passed to getopt by 18 (the length
of /usr/lib/uucp/Maps) for each file to be processed.

--
Dave Hammond
daveh@marob.masa.com
uunet!masa.com!marob!daveh

john@frog.UUCP (John Woods) (05/10/90)

In article <6145@ucrmath.UCR.EDU>, gumby@ucrmath.UCR.EDU (john donahue) writes:
> My site just received some more map files in "comp.mail.maps"
> last night and suddenly, pathalias no longer works. It is now complaining
> that the argument list of files is too long. There are now 178 files in
> my "/usr/spool/uucp/Maps" directory and when a shell script called
> "/usr/lib/uucp/uugetmaps" is executed, pathalias is run with:
> /usr/lib/uucp/pathalias -i /usr/spool/uucp/Maps/* > /tmp/paths
> It complains that the "arg list too long" and terminates.

That complaint is presumably from the shell which finds that it cannot
build a sufficiently small argument list (exec() limits the size of the
combined environment/argument area).  The only long-term fix is an operating
system version with a higher limit (or no limit, preferably);  for the
short (and probably permanent) term, you could preprocess the files with
something like "cat d.* > D ; cat u.* > U; /usr/lib/uucp/pathalias -i D U"
(elaborate as necessary), or even "(cat d.* ; cat u.*) | pathalias -i".
As the pool of u.* files grows, you'll probably have to split them up also.
-- 
John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101
...!decvax!frog!john, john@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu