[comp.unix.sysv386] "-Xp", truncating file lengths, and restricted "chown" in ISC 2.2

lubkin@cs.rochester.edu (Saul Lubkin) (05/21/91)

Here is most of the text of a note that I recently emailed to
Uwe Doering:

>As I noted previously, I've applied your very useful binary patch to
>"os.o", and no longer have kernel panics with "-Xp" compiled binaries.
>
>I've made a POSIX job-controlled bash1.07 that's very useful.  (Actually,
>I used "gcc -traditional -posix" rather than "cc -Xp", but "cc -Xp" 
>should work, too.)
>
>One (relatively minor) aditional problem:
>By default, "-Xp" compiled binaries have the two standard POSIX security
>features, "_POSIX_NO_TRUNC" and "_POSIX_CHOWN_RESTRICTED" turned on.
>The first of these, does not allow truncating of filename lengths 
>greater than 14 chars -- the files simply are not created, with an OS
>generated error message.  The second only allows root to use the "chown"
>system call -- a nuiscence, e.g., when running uucp, since uucico at
>certain times creates directories, tries (unsuccessfully) to "chown"
>them to uucp, and then fails in its task, when uucp is run by an ordinary
>user under a POSIX shell).
>
>In SVR4, there is a tunable parameter, I think called "RSTCHOWN", which
>allows turning on or off "_POSIX_CHOWN_RESTRICTED".
>
>There is a standard POSIX system call, "pathconf", that allows applications
>to test the current value of these two features.  But this is not used
>by, e.g., ISC's "tar" or "cp"; so changing the supplied "pathconf.o"
>in "/lib/libcposix.a" doesn't help.
>
>I've downloaded the GNU fileutilites (including a prerelease of GNU
>"chown"), and I found that making them, WITH A CALL TO
>__setostype(_OS_SYSV), as well as NOT using "-Xp", will produce useful
>versions of cp, etc, that work under POSIX bash, and use SVR3 versions
>of system calls like "chown", etc.  (So that the usual truncation of
>filename lengths occurs.)
>
>It seems that the problem is this:  ISC "cp", etc., is compiled without
>any call to __setostype, so that they will work in either SVR3 or POSIX
>mode, depending on how the calling shell was compiled.
>
>Of course, rather than make different versions of all utilities ("tar" 
>and "cpio" would be next), the right way to do it is to somehow turn off
>"_POSIX_NO_TRUNC" and "_POSIX_CHOWN_RESTRICTED".  This may require a
>binary patch of some sort; so far I've been unsuccessful in doing this.
>
>Any advice would be greatly appreciated.
>
>BTW, ISC "mv", when used to rename directories under a POSIX bash, is
>particularly bizarre.  "mv dir1 dir2", produces the error message,
>"cannot unlink ."  And, you are left with both "dir1" and "dir2", two
>apparently LINKED DIRECTORIES! (Same inode number).  Once, while
>experimenting, it DID seem to "unlink .", resulting in all the files
>in "." being orphaned.  ".", my home directory, became a zero length
>unreferenced file, as well.
>
>No similar problems with GNU "mv", no matter how you compile it.

			Sincerely yours,

			Saul Lubkin