home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: karish@mindcraft.com (Chuck Karish)
-
- In article <1991Jul21.222926.12659@uunet.uu.net> brnstnd@KRAMDEN.ACF.NYU.EDU
- (Dan Bernstein) writes:
- >In article <1991Jul19.033239.8917@uunet.uu.net> Chuck Karish
- >(karish@mindcraft.com) writes:
- [ Dan Bernstein wrote: ]
- [ Secondary included text deleted for brevity's sake -- mod ]
- >My objection is to the idea of standardizing something which vendors
- >haven't even begun to look at. I feel the same way about sysconf() and
- >pathconf(), POSIX sessions (oh, right, HP-UX already had something like
- >this---how dare I argue against such a precedent?), and most of POSIX's
- >other inventions.
-
- If you've been paying attention to this newsgroup, you know
- that POSIX sessions were invented because, when the working
- group tried to write a specification for job control, they
- discovered that the BSD behavior was underspecified and
- inconsistent. They chose invention as the lesser of two
- evils rather than standardize on something that was wrong.
-
- To elaborate on the security and efficiency issues, I fail to
- see that either getconf or /inst/bin has any impact on the
- administrator's ability to maintain reasonable system security.
- The directories and executables in the default path, including
- getconf, have to be protected no matter how many links there are
- to each file. If it's possible for a bad guy to put a Trojan
- horse into the default path it doesn't matter whether its name
- is 'getconf' or 'login' or 'sh' or '/.profile' or '/etc/environment'.
-
- As others have pointed out, the efficiency of using /inst/bin
- depends on the implementation. I consider it to be a poor
- candidate for standardization. If you want to use it on
- systems where it helps, go ahead. Nothing in 1003.1 or 1003.2
- will break it.
-
- >In this particular case, existing programs can be used with /inst/bin
- >without even changing the source code. All you have to do is change the
- >default system PATH. Adding getconf to a program means that the program
- >will no longer work on the vast majority of systems. That's what I mean
- >by unportable.
-
- There's a simple fix that makes such scripts work: install
- getconf. It's easy to implement and no harder to install than
- patch or compress, which I regularly install on new systems in
- order to port other programs. Scripts can be written to use
- getconf only if it exists, which allows them to be portable to
- non-POSIX.2 systems.
-
- The issue of script portability is something of a red herring,
- because it has never been possible to write really portable
- scripts. There's just too much variability in internal limits
- and return codes in utilities, which are formally standardized
- for the first time ("our implementation IS the standard",
- as AT&T is fond of saying, doesn't cut it) in POSIX.2.
-
- getconf, sysconf(), pathconf() and fpathconf() exist to make it
- possible to allow programs to make full use of system
- capabilities without being re-compiled for differently-
- configured members of a binary-compatible family and without
- being crippled down to a lowest common denominator. If
- you're happy to write code that works only on BSD systems,
- you're free to continue to do so. Others who try to write
- portable programs can protect calls to pathconf(), sysconf(),
- etc. inside "#ifdef _POSIX_SOURCE" blocks and leave the
- traditional porting hackery to you, if that's what you want.
-
- >> A puzzle for the reader (maybe this is obvious to everyone but
- >> me): How can a shell script determine whether it's running on
- >> a POSIX.2 system? If it calls getconf and getconf does not
- >> exist, the shell may exit. It could call getconf in a
- >> subshell, but that's ugly and expensive.
- >
- >Congratulations. You just hit the nail right on the head.
-
- There's a trivial fix for this, too: 1003.2 could require
- conforming systems or shells to pre-define an environment
- variable to indicate that POSIX.2 features are available. Has
- this been considered? If so, why was it rejected?
- --
-
- Chuck Karish karish@mindcraft.com
- Mindcraft, Inc. (415) 323-9000
-
- Volume-Number: Volume 24, Number 58
-
-