home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / mod.std.unix.v4 / text0008.txt < prev    next >
Encoding:
Internet Message Format  |  1987-06-30  |  10.1 KB

  1. Date: Wed, 11 Dec 85 00:32:33 PST
  2. From: l5!gnu@LLL-CRG.ARPA (John Gilmore)
  3.  
  4. Section 10.1.1 introduces the terms "interpret" and "translate" for
  5. "load" and "dump".  Can we just use the familiar terms?  I have trouble
  6. remembering which is which.
  7.  
  8. [ I think using either of the words "dump" or "restore" (the latter
  9. actually used in the section) is a mistake, since they also connote
  10. a completely different set of programs than those usually associated
  11. with the format in question.  -mod ]
  12.  
  13. This section also says:
  14. > "The format-interpreting utility is defined such that if it is not a
  15. > privileged program, when data is read into the system from the
  16. > transportable media, all protection information is ignored.  Instead the
  17. > user ownership and group owership are set to that of the process context
  18. > which is running the utility.  All access protection information can be
  19. > set to be no more liberal than that of the process that is running the
  20. > utility.  A privileged version of the utility must have as a minimum, an
  21. > option that obeys the protection information stored on the transportable
  22. > media, such that this format and the corresponding utility can be used as
  23. > a save/restore mechanism."
  24.  
  25. First, this is self-contradictory; it says all protection information
  26. is ignored, then says it can be set "no more liberal" than the
  27. process.
  28.  
  29. [ The utility is not prevented from reading anything in the data
  30. because of any protections associated with it.  However, once the
  31. utility converts the data into files in the file system, there *is*
  32. protection associated with it, as with any file:  the utility must
  33. set the appropriate protection bits.  -mod ]
  34.  
  35. (I would assume the OS takes care of not letting your process
  36. set protection more liberal than its own, else there is no security.)
  37. I think what it means is that it's not legal for system V "tar" to always
  38. chown away the files, which you can't get back.
  39.  
  40. [ Cpio actually does that under System V.  Such chowning is a major
  41. security problem, much like your phrase:  "there is no security",
  42. since the numeric user ids on the "tape" may have completely different
  43. meanings on the system where it is being read than on the one where
  44. it was written.  This problem has been addressed in several other places
  45. in the standard as well as here.  -mod ]
  46.  
  47. Was there some other reason for this paragraph?  If not, can we replace
  48. the text with something like:
  49.  
  50.   "The format-loading utility must not set access protections that cannot
  51.   be revoked by the user running the utility (whether the user is
  52.   privileged or not).  If it can be run as a privileged utility, an
  53.   option (or default behaviour) must exist which obeys all the loaded
  54.   protection information, so it can be used for system backups."
  55.  
  56. ---
  57.  
  58. Also, section 10.1.2 uses confusing terminology with regard to blocks
  59. and records.  In the data processing world, a block is a big thing and
  60. one or more records fit in it (roughly speaking).  Like you write 100
  61. records 80 chars long in an 8000 byte block on tape.  Has anybody
  62. checked the ANSI standard for tape format to see what they call 'em?
  63. The Unix standard uses "block" for the small records, "group" for the
  64. large things, and also mentions that a "group" might turn into a single
  65. tape "record".
  66.  
  67. I also don't see the need for two records of zeros on the end.  One
  68. should be fine, and it won't break compatability with the Unix tar
  69. program, which quits as soon as it sees the first one.  Tar should
  70. really use EOF rather than this funny end of tape record; this would
  71. solve two or three minor problems with it, but would break
  72. compatability with existing Unix "tar".  (The problems:  the tape is
  73. positioned wrong after reading a tar archive from a multi-file tape,
  74. since the tape mark has not yet been read; you can't just concatenate
  75. tar archives to combine their contents (which would make multi-volume
  76. tar handling somewhat easier too); extra data is written, which
  77. makes it uneconomical to use a large, tape-efficient block size (like a
  78. megabyte on streaming cartridge tapes, since this will waste up to a
  79. megabyte of space on the tape).
  80.  
  81. What I suggest is that ANSI standard tar's should be required to work
  82. OK when reading an archive terminated by EOF (short last block, then
  83. zero length result from read()).  Suggested wording:
  84.  
  85.   An archive tape or file contains a series of records.  Each record is of
  86.   size TRECORDSIZE (see below).  Although this format may be thought of as
  87.   being on magnetic tape, this does not exclude the use of other
  88.   media.  Each file archived is represented by a header record
  89.   which describes the file, followed by zero or more records which give the
  90.   contents of the file.  At the end of the archive file there may be a record
  91.   filled with binary zeros as an end-of-file indicator.  A conforming
  92.   system must write a record of zeros at the end, but must not assume that
  93.   an end-of-file record exists when reading an archive.
  94.  
  95.   The records may be blocked for physical I/O operations.  Each block of
  96.   n records (where n is set by the application program creating the
  97.   archive file) may be written with a single write() operation.  On
  98.   magnetic tapes, the result of such a write is a single tape record.
  99.   When writing an archive, the last block of records shall be written
  100.   at the full size, with records after the zero record containing
  101.   undefined data.  When reading an archive, a confirming system shall
  102.   properly handle an archive whose last block is shorter than the rest.
  103.  
  104. This allows a system to provide an option to write more modern
  105. archives, which will be readable by all P1003 conforming systems, but
  106. requires that the default be compatible (readable with V7 Unix 'tar').
  107.  
  108. ---
  109.  
  110. > /* Values used in typeflag field */
  111. > #define REGTYPE   '0'         /* Regular file  */
  112. > #define AREGTYPE  '\0'        /* Regular file  */
  113. > #define LNKTYPE   '1'         /* Link          */
  114. > #define SYMTYPE   '2'         /* Reserved      */
  115. > #define CHRTYPE   '3'         /* Char. special */
  116. > #define BLKTYPE   '4'         /* Block special */
  117. > #define DIRTYPE   '5'         /* Directory     */
  118. > #define FIFOTYPE  '6'         /* FIFO special  */
  119. > #define CONTTYPE  '7'         /* Reserved      */
  120.  
  121. In the header file, less generic names than e.g. "REGTYPE" should be used.
  122. How about "TF_REGULAR" (typeflag = regular file).  This avoids the well
  123. known problem that a #define is a joy (or a pain) forever, especially
  124. when some other header file wants to use the same name:
  125.  
  126.   /* The typeflag defines the type of file */
  127.   #define    TF_OLDNORMAL    '\0'        /* Normal disk file, compat */
  128.   #define    TF_NORMAL    '0'        /* Normal disk file */
  129.   #define    TF_LINK        '1'        /* Link to dumped file */
  130.   #define    TF_SYMLINK    '2'        /* Symbolic link */
  131.   #define    TF_CHR        '3'        /* Character special file */
  132.   #define    TF_BLK        '4'        /* Block special file */
  133.   #define    TF_DIR        '5'        /* Directory */
  134.   #define    TF_FIFO        '6'        /* FIFO special file */
  135.   #define    TF_CONTIG    '7'        /* Contiguous file */
  136.   /*
  137.    * All other type values except A-Z are reserved for future standardization
  138.    * and may not be used.  A-Z may be used for implementation-dependent
  139.    * record types.
  140.    */
  141.  
  142. The mode fields should use a prefix like "TM_" rather than just "T".
  143. Also, TSVTX (the sticky bit) cannot be "reserved" otherwise implementations
  144. cannot write archives that have it turned on.  Call it implementation-defined,
  145. if you must.
  146.  
  147. > All characters are represented in ASCII, using 8-bit characters without
  148. > parity.  Each field within the structure is contiguous; that is, there is
  149. > no padding used within the structure.  Each character on the archive media
  150. > is stored contiguously.
  151.  
  152. You'd better be more specific.  USASCII, with the 7-bit character in the
  153. low-order 7 bits and the high-order bit cleared?  What about foreign
  154. sites with funny characters in their file names?
  155.  
  156. > The fields name, linkname, magic, uname and gname are null-terminated
  157. > character strings.
  158.  
  159. Does this mean that when writing an archive, you MUST put in the null,
  160. or if the value exactly fills the field, is it OK to not have a null
  161. there?  In other words, caveat writer or caveat reader?  Here again, a
  162. prudent course would be to require the writer to do it right, and
  163. require the reader to accept it either way.
  164.  
  165. > The mtime field is the modification time of the file at the time it was
  166. > archived.  It is the ASCII representation of the octal value of the
  167. > modification time obtained from the stat() call.
  168.  
  169. This should be spelled out in detail, so the definition of the archive
  170. format can stand alone.
  171.  
  172. > ASCII digit `2' is reserved.
  173. > ASCII digit `7' is reserved.
  174. > ASCII letters `A' through `Z' are reserved for custom implementations.
  175. > All other values are reserved for specification in future revisions of the
  176. > standard.
  177.  
  178. As I understand standards, something that is reserved canNOT be used by
  179. an implementation to extend the standard.  This is not the intention
  180. here, since I presume compatability with BSD systems (which use 2 for
  181. symlinks) is desired.  I'm not sure why we don't just standardize
  182. symlinks here; after all, not all systems have fifos or contiguous
  183. files either...
  184.  
  185. [ They were in there at one point.  I wonder what happened to them.  -mod ]
  186.  
  187. > The encoding of the header is designed to be portable across machines.
  188.  
  189. This sentence can go... 
  190.  
  191. > 10.1.3  Notes
  192. > ...
  193. > Implementors should be aware that the previous file format did not include
  194. > a mechanism to archive directory type files.  For this reason, the
  195. > convention of using a file name which ended with a slash (/) was adopted
  196. > to specify the archiving of a directory.
  197.  
  198. But ANSI standard systems are not required to read such a tape?  I think
  199. they should be required to read it but not write it.
  200.  
  201.  
  202. An additional point.  The standard does not specify what fields are defined
  203. in what record types.  For example, is it OK to have garbage in the linkname
  204. in record type 0 (normal files)?  Is it OK to put zeros in the uid/gid fields
  205. if you have filled in the uname/gname/magic fields (say your system does not
  206. have numeric uids?).  What about the bytes in the header records that
  207. are not defined by the structure?  Or the bytes beyond the end of a file,
  208. in its last record?  I'd suggest that we require these fields to be nulls
  209. on writing, and require them to be ignored on reading, again for prudence.
  210.  
  211. Volume-Number: Volume 4, Number 9
  212.  
  213.