home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume24 / pucc-install / part06 < prev    next >
Encoding:
Internet Message Format  |  1991-03-19  |  58.4 KB

  1. Subject:  v24i068:  Purdue software product installation system, Part06/07
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: e67424df a20290dd eb3cd3ee 9d087e7c
  5.  
  6. Submitted-by: Kevin Braunsdorf <ksb@nostromo.cc.purdue.edu>
  7. Posting-number: Volume 24, Issue 68
  8. Archive-name: pucc-install/part06
  9.  
  10. Submitted-by: ksb@cc.purdue.edu (Kevin Braunsdorf)
  11. Archive-name: pucc-1b/part06
  12.  
  13. #!/bin/sh
  14. # This is part 06 of pucc-1b
  15. # ============= purge/filedup.c ==============
  16. if test ! -d 'purge'; then
  17.     echo 'x - creating directory purge'
  18.     mkdir 'purge'
  19. fi
  20. if test -f 'purge/filedup.c' -a X"$1" != X"-c"; then
  21.     echo 'x - skipping purge/filedup.c (File already exists)'
  22. else
  23. echo 'x - extracting purge/filedup.c (Text)'
  24. sed 's/^X//' << 'Purdue' > 'purge/filedup.c' &&
  25. /*
  26. X * $Id: filedup.c,v 3.0 90/09/17 11:38:20 ksb Exp $
  27. X * keep track of unique inode/dev pairs for me                (ksb)
  28. X */
  29. #include <sys/param.h>
  30. #include <sys/types.h>
  31. #include <sys/stat.h>
  32. #include <errno.h>
  33. #include <stdio.h>
  34. X
  35. extern char *sys_errlist[];
  36. #define strerror(Me) (sys_errlist[Me])
  37. extern int errno;
  38. X
  39. #include "filedup.h"
  40. X
  41. static AVL *AVpAVInsert = nilAV;    /* used by AVInsert & AVVerify()*/
  42. static AE_ELEMENT *AVpAEInsert = nilAE;
  43. static struct stat *AEpstCur;
  44. static char *AEpcName;
  45. X
  46. static void
  47. AEInit(pAE)
  48. AE_ELEMENT *pAE;
  49. {
  50. X    extern char *malloc(), *strcpy();
  51. X    pAE->mydev = AEpstCur->st_dev;
  52. X    pAE->myino = AEpstCur->st_ino;
  53. X    pAE->pcname = strcpy(malloc(strlen(AEpcName)+1),AEpcName);
  54. }
  55. X
  56. static int
  57. AECmp(pAE)
  58. AE_ELEMENT *pAE;
  59. {
  60. X    register int cmp;
  61. X    if (0 == (cmp = pAE->mydev - AEpstCur->st_dev)) {
  62. X        if (0 == (cmp = pAE->myino - AEpstCur->st_ino)) {
  63. X            return 0;
  64. X        }
  65. X    }
  66. X    return cmp;
  67. }
  68. X
  69. /*
  70. X * make an AVL tree empty                        (ksb)
  71. X *
  72. X * in most code "AVL *pAVRoot = nilAV;" is better than calling this routine
  73. X */
  74. void
  75. AVInit(ppAV)
  76. AVL **ppAV;
  77. {
  78. X    *ppAV = nilAV;
  79. }
  80. X
  81. /*
  82. X * Fix an AVL tree node that is in violation of the rules        (dsg)
  83. X * calls look like:
  84. X *     AV_rotate(ppAVRoot, AV_LCHILD)
  85. X *     AV_rotate(ppAVRoot, AV_RCHILD)
  86. X * to fix nodes that are left tipped, and right tipped respectivly
  87. X *
  88. X * return
  89. X *    1: if the tree is shorter after the rotate (always true for insert)
  90. X *    0: if same depth
  91. X */
  92. static int
  93. AV_rotate(ppAVRoot, fSide)
  94. AVL **ppAVRoot;
  95. register int fSide;
  96. {
  97. X    register AVL *pAVCopy, *pAVFirst, *pAVSecond;
  98. X    register int fOther;
  99. X
  100. X    pAVCopy = *ppAVRoot;
  101. X    pAVFirst = pAVCopy->AVsbpAVchild[fSide];
  102. X
  103. X    fOther = 1^fSide;
  104. X                        /* Three point rotate    */
  105. X    if (fSide == pAVFirst->AVbtipped) {
  106. X        pAVCopy->AVbtipped = AV_BAL_CENTER;
  107. X        pAVFirst->AVbtipped = AV_BAL_CENTER;
  108. X
  109. X        *ppAVRoot = pAVFirst;
  110. X        pAVCopy->AVsbpAVchild[fSide] = pAVFirst->AVsbpAVchild[fOther];
  111. X        pAVFirst->AVsbpAVchild[fOther] = pAVCopy;
  112. X
  113. X                        /* Five point rotate    */
  114. X    } else if (AV_BAL_CENTER != pAVFirst->AVbtipped) {
  115. X        pAVSecond = pAVFirst->AVsbpAVchild[fOther];
  116. X
  117. X        if (AV_BAL_CENTER == pAVSecond->AVbtipped) {
  118. X            pAVCopy->AVbtipped = AV_BAL_CENTER;
  119. X            pAVFirst->AVbtipped = AV_BAL_CENTER;
  120. X        } else if (fSide == pAVSecond->AVbtipped) {
  121. X            pAVCopy->AVbtipped = fOther;
  122. X            pAVFirst->AVbtipped = AV_BAL_CENTER;
  123. X        } else {
  124. X            pAVCopy->AVbtipped = AV_BAL_CENTER;
  125. X            pAVFirst->AVbtipped = fSide;
  126. X        }
  127. X        pAVSecond->AVbtipped = AV_BAL_CENTER;
  128. X        *ppAVRoot = pAVFirst->AVsbpAVchild[fOther];
  129. X        pAVFirst->AVsbpAVchild[fOther] = pAVSecond->AVsbpAVchild[fSide];
  130. X        pAVSecond->AVsbpAVchild[fSide] = pAVCopy->AVsbpAVchild[fSide];
  131. X        pAVCopy->AVsbpAVchild[fSide] = pAVSecond->AVsbpAVchild[fOther];
  132. X        pAVSecond->AVsbpAVchild[fOther] = pAVCopy;
  133. X
  134. X    /*
  135. X     * Insert: we shouldn't be here
  136. X     * Delete: a 3-point or a 5-point rotate works here, so we
  137. X     * choose the less expensive one.  Also, this is the case
  138. X     * where the balance factors come out skewed, and the tree
  139. X     * doesn't shrink.
  140. X     */
  141. X    } else {
  142. X        pAVCopy->AVbtipped = fSide;
  143. X        pAVFirst->AVbtipped = fOther;
  144. X
  145. X        *ppAVRoot = pAVFirst;
  146. X        pAVCopy->AVsbpAVchild[fSide] = pAVFirst->AVsbpAVchild[fOther];
  147. X        pAVFirst->AVsbpAVchild[fOther] = pAVCopy;
  148. X
  149. X        return 0;
  150. X    }
  151. X    return 1;
  152. }
  153. X
  154. /*
  155. X * find a node keyed on AVpAEInsert -- set AVpAVInsert to inserted    (dsg)
  156. X * element if fAdd
  157. X *
  158. X * calling sequence:
  159. X *    { AECmp must know the "current key now" }
  160. X *    AVInsert(& pAVRoot, fAdd);
  161. X *
  162. X * result:
  163. X *    AVpAVInsert is inserted element (don't touch!)
  164. X *    AVpAEInsert points to user data in the record
  165. X *
  166. X * returns:
  167. X *    true if tree became deeper
  168. X */
  169. static int
  170. AVInsert(ppAVRoot, fAdd)
  171. AVL **ppAVRoot;
  172. int fAdd;
  173. {
  174. X    extern char *malloc();
  175. X    register AVL *pAVCopy;
  176. X    auto int fCmp;
  177. X
  178. X    pAVCopy = *ppAVRoot;
  179. X    if (nilAV == pAVCopy) {
  180. X        if (fAdd) {
  181. X            AVpAVInsert = *ppAVRoot = (AVL *)malloc(sizeof(AVL));
  182. X            AVpAVInsert->AVbtipped = AV_BAL_CENTER;
  183. X            AVpAVInsert->AVsbpAVchild[AV_LCHILD] = nilAV;
  184. X            AVpAVInsert->AVsbpAVchild[AV_RCHILD] = nilAV;
  185. X            AVpAEInsert = & AVpAVInsert->AE_data;
  186. X            AEInit(AVpAEInsert);
  187. X            return 1;
  188. X        }
  189. X        AVpAEInsert = nilAE;
  190. X        AVpAVInsert = nilAV;
  191. X    } else if (0 == (fCmp = AECmp(& pAVCopy->AE_data))) {
  192. X        AVpAVInsert = pAVCopy;
  193. X        AVpAEInsert = & AVpAVInsert->AE_data;
  194. X    } else if (fCmp < 0) {
  195. X        if (AVInsert(& pAVCopy->AVsbpAVchild[AV_LCHILD], fAdd)) {
  196. X            switch (pAVCopy->AVbtipped) {
  197. X            case AV_BAL_LEFT:
  198. X                (void)AV_rotate(ppAVRoot, AV_LCHILD);
  199. X                break;
  200. X            case AV_BAL_CENTER:
  201. X                pAVCopy->AVbtipped = AV_BAL_LEFT;
  202. X                return 1;
  203. X            case AV_BAL_RIGHT:
  204. X                pAVCopy->AVbtipped = AV_BAL_CENTER;
  205. X                break;
  206. X            }
  207. X        }
  208. X    } else if (AVInsert(& pAVCopy->AVsbpAVchild[AV_RCHILD], fAdd)) {
  209. X        switch (pAVCopy->AVbtipped) {
  210. X        case AV_BAL_RIGHT:
  211. X            (void)AV_rotate(ppAVRoot, AV_RCHILD);
  212. X            break;
  213. X        case AV_BAL_CENTER:
  214. X            pAVCopy->AVbtipped = AV_BAL_RIGHT;
  215. X            return 1;
  216. X        case AV_BAL_LEFT:
  217. X            pAVCopy->AVbtipped = AV_BAL_CENTER;
  218. X            break;
  219. X        }
  220. X    }
  221. X    return 0;
  222. }
  223. X
  224. #if 0
  225. /*
  226. X * a prototype function for AVScan                    (ksb)
  227. X */
  228. int
  229. AV_prototype(pAE)
  230. AE_ELEMENT *pAE;
  231. {
  232. X    /* bar(pAE->foo); */
  233. X    return 0;        /* compatible with MICE            */
  234. }
  235. #endif /* example */
  236. X
  237. /*
  238. X * scan an avl tree inorder calling pFunc with each each node        (ksb)
  239. X *
  240. X * the function passed should return non-zero for stop (MICE)
  241. X */
  242. int
  243. AVScan(pAVRoot, pFunc)
  244. AVL *pAVRoot;
  245. int (*pFunc)();            /* prototype AV_prototype        */
  246. {
  247. X    register int r;
  248. X
  249. X    while (nilAV != pAVRoot) {
  250. X        if (0 != (r = AVScan(pAVRoot->AVsbpAVchild[AV_LCHILD], pFunc)))
  251. X            return r;
  252. X        if (0 != (r = (*pFunc)(& pAVRoot->AE_data)))
  253. X            return r;
  254. X        pAVRoot = pAVRoot->AVsbpAVchild[AV_RCHILD];
  255. X    }
  256. X    return 0;
  257. }
  258. X
  259. X
  260. #if 0
  261. /*
  262. X * return name for this node in tree                    (ksb)
  263. X */
  264. char *
  265. FDName(ppAV, pst)
  266. AVL **ppAV;
  267. struct stat *pst;
  268. {
  269. X    /* see if it was the last one we found
  270. X     */
  271. X    if (nilAE != AVpAEInsert && pst->st_ino == AVpAEInsert->myino &&
  272. X         pst->st_dev == AVpAEInsert->mydev)
  273. X        return AVpAEInsert->pcname;
  274. X
  275. X    AEpstCur = pst;
  276. X    (void)AVInsert(ppAV, 0);
  277. X    AEpstCur = (struct stat *)0;
  278. X
  279. X    if (nilAE != AVpAEInsert)
  280. X        return AVpAEInsert->pcname;
  281. X    return (char *)0;
  282. }
  283. #endif
  284. X
  285. /*
  286. X * return name that is in tree                        (ksb)
  287. X */
  288. char *
  289. FDAdd(ppAV, pcName, pst)
  290. AVL **ppAV;
  291. struct stat *pst;
  292. char *pcName;
  293. {
  294. X    AEpstCur = pst;
  295. X    AEpcName = pcName;
  296. X    (void)AVInsert(ppAV, 1);
  297. X    AEpcName = (char *)0;
  298. X    AEpstCur = (struct stat *)0;
  299. X    return AVpAEInsert->pcname;
  300. }
  301. X
  302. #if TEST
  303. char *progname = "frtest";
  304. X
  305. int
  306. main(argc, argv)
  307. int argc;
  308. char **argv;
  309. {
  310. X    auto char acFile[MAXPATHLEN+2];
  311. X    auto struct stat stBuf;
  312. X    register char *pcEnd;
  313. X    auto AVL *pAV;
  314. X    extern char *strchr();
  315. X
  316. X    AVInit(& pAV);
  317. X
  318. X    while ((char *)0 != fgets(acFile, MAXPATHLEN+1, stdin)) {
  319. X        if ((char *)0 == (pcEnd = strchr(acFile, '\n'))) {
  320. X            fprintf(stderr, "%s: name too long\n", progname);
  321. X            exit(1);
  322. X        }
  323. X        *pcEnd = '\000';
  324. X        if (-1 == lstat(acFile, &stBuf)) {
  325. X            fprintf(stderr, "%s: stat: %s: %s\n", progname, acFile, strerror(errno));
  326. X            continue;
  327. X        }
  328. X        printf("%s %s\n", acFile, FDAdd(&pAV, acFile, &stBuf));
  329. X    }
  330. X    exit(0);
  331. }
  332. #endif
  333. Purdue
  334. chmod 0444 purge/filedup.c ||
  335. echo 'restore of purge/filedup.c failed'
  336. Wc_c="`wc -c < 'purge/filedup.c'`"
  337. test 6893 -eq "$Wc_c" ||
  338.     echo 'purge/filedup.c: original size 6893, current size' "$Wc_c"
  339. fi
  340. # ============= install.d/install.h ==============
  341. if test ! -d 'install.d'; then
  342.     echo 'x - creating directory install.d'
  343.     mkdir 'install.d'
  344. fi
  345. if test -f 'install.d/install.h' -a X"$1" != X"-c"; then
  346.     echo 'x - skipping install.d/install.h (File already exists)'
  347. else
  348. echo 'x - extracting install.d/install.h (Text)'
  349. sed 's/^X//' << 'Purdue' > 'install.d/install.h' &&
  350. /*
  351. X * $Id: install.h,v 7.1 90/09/17 10:34:16 ksb Exp $
  352. X * Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  353. X * 47907.  All rights reserved.
  354. X *
  355. X * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  356. X *
  357. X * This software is not subject to any license of the American Telephone
  358. X * and Telegraph Company or the Regents of the University of California.
  359. X *
  360. X * Permission is granted to anyone to use this software for any purpose on
  361. X * any computer system, and to alter it and redistribute it freely, subject
  362. X * to the following restrictions:
  363. X *
  364. X * 1. Neither the authors nor Purdue University are responsible for any
  365. X *    consequences of the use of this software.
  366. X *
  367. X * 2. The origin of this software must not be misrepresented, either by
  368. X *    explicit claim or by omission.  Credit to the authors and Purdue
  369. X *    University must appear in documentation and sources.
  370. X *
  371. X * 3. Altered versions must be plainly marked as such, and must not be
  372. X *    misrepresented as being the original software.
  373. X *
  374. X * 4. This notice may not be removed or altered.
  375. X */
  376. X
  377. /*
  378. X * all the externs and positioning for install                (ksb)
  379. X */
  380. #define PATCH_LEVEL    0
  381. X
  382. #if defined(SYSV) || defined(HPUX7)
  383. X
  384. #include <sys/signal.h>
  385. #include <sys/fcntl.h>
  386. #include <string.h>
  387. X
  388. #if !defined(MAXPATHLEN)
  389. #define MAXPATHLEN    256
  390. #endif    /* already defined by someone        */
  391. #define vfork    fork        /* no vfork                */
  392. extern struct group *getgrent(), *getgrgid(), *getgrnam();
  393. extern struct passwd *getpwent(), *getpwuid(), *getpwnam();
  394. X
  395. #else    /* BSD                    */
  396. X
  397. #include <fcntl.h>
  398. #include <strings.h>
  399. X
  400. #define strchr    index
  401. #define strrchr    rindex
  402. X
  403. #if defined(pdp11)
  404. #include <wait.h>
  405. #else    /* bsd 4.?                */
  406. #include <sys/wait.h>
  407. #endif    /* bsd 2.?                */
  408. X
  409. #endif    /* system 5                */
  410. X
  411. #if defined(DYNIX)
  412. #include <sys/universe.h>
  413. #endif    /* universe stuff for symlinks        */
  414. X
  415. extern int errno;        /* for perror(3)            */
  416. extern char *sys_errlist[];
  417. #define strerror(Me)    (sys_errlist[Me])
  418. X
  419. #if !HAVE_ACCTTYPES
  420. #define    uid_t int
  421. #define gid_t int
  422. #endif    /* find a uid/gid type            */
  423. X
  424. #if defined(HAVE_SLINKS) ? HAVE_SLINKS : defined(S_IFLNK)
  425. X
  426. #define LSTAT    lstat
  427. #if !defined(HAVE_SLINKS)
  428. #define HAVE_SLINKS    1
  429. #endif
  430. X
  431. #if !defined(SLINKOK)
  432. #define SLINKOK        FALSE    /* allow src to be a symlink?        */
  433. #endif    /* default source links to not allow    */
  434. X
  435. #if !defined(DLINKOK)
  436. #define DLINKOK        FALSE    /* allow dst to be a symlink?        */
  437. #endif    /* default destination links to not allow */
  438. X
  439. #else    /* we don't need to worry about lstat    */
  440. X
  441. #define LSTAT    stat
  442. #if !defined(HAVE_SLINKS)
  443. #define HAVE_SLINKS    0
  444. #endif
  445. #endif    /* if we have symlink preserving stat    */
  446. X
  447. X
  448. /* a crutch or two
  449. X */
  450. #define EQUAL(s1,s2)    (0==strcmp(s1,s2))
  451. #define MAXTRIES    16        /* retrys on mktemp clashes    */
  452. #define    PATMKTEMP    "XXXXXX"    /* tack this on for mktemp(3)    */
  453. #define TRUE        (1)        /* you know, boolean like    */
  454. #define FALSE        (0)        /* you know, boolean like    */
  455. #define SUCCEED        (1)        /* our internal success code    */
  456. #define FAIL        (-1)        /* our internal failure code    */
  457. #define EXIT_FSYS    0x40        /* failed system call        */
  458. #define EXIT_OPT    0x41        /* bad option or data        */
  459. #define EXIT_INTER    0x42        /* internal error        */
  460. X
  461. #define PERM_RWX(x)    ((x) & 0777)
  462. #define PERM_BITS(x)    ((x) & 07777)
  463. #define SAFEMASK    (~(S_ISUID|S_ISGID|S_ISVTX))
  464. X
  465. X
  466. /*
  467. X * defaults that the installer gets if here doesn't -D define them
  468. X */
  469. #if defined(INHERIT_OK)
  470. X
  471. /* in this case we will copy modes whenever we get a chance,
  472. X * (we use a (char*)0 to record `inherit').
  473. X */
  474. #if !defined(DEFOWNER)
  475. #define DEFOWNER    (char *)0    /* files are all inherit owner    */
  476. #endif    /* might not want to use this; old UNIX?*/
  477. X
  478. #if !defined(DEFGROUP)
  479. #define DEFGROUP    (char *)0    /* inherit group owner of file    */
  480. #endif    /* any local should be set in Makefile    */
  481. X
  482. #if !defined(DEFMODE)
  483. #define DEFMODE        (char *)0    /* file installation mode    */
  484. #endif    /* all other files            */
  485. X
  486. #if !defined(DEFDIROWNER)
  487. #define DEFDIROWNER    (char *)0    /* dirs inherit owner        */
  488. #endif    /* might not want to use this; old UNIX?*/
  489. X
  490. #if !defined(DEFDIRGROUP)
  491. #define DEFDIRGROUP    (char *)0    /* inherit group owner of dirs    */
  492. #endif    /* any local should be set in Makefile    */
  493. X
  494. #if !defined(DEFDIRMODE)
  495. #define DEFDIRMODE    (char *)0    /* inherit directory mode    */
  496. #endif    /* all dirs can be read by default    */
  497. X
  498. #if !defined(ODIROWNER)
  499. #define ODIROWNER    (char *)0
  500. #endif    /* default backup dir owner        */
  501. X
  502. #if !defined(ODIRGROUP)
  503. #define ODIRGROUP    (char *)0
  504. #endif    /* default backup dir group        */
  505. X
  506. #if !defined(ODIRMODE)
  507. #define ODIRMODE    (char *)0
  508. #endif    /* default backup dir mode        */
  509. X
  510. #else
  511. X
  512. /*
  513. X * otherwise we want to set all these default modes here...
  514. X */
  515. X
  516. #if !defined(DEFOWNER)
  517. #define DEFOWNER    "root"        /* files are all root owned    */
  518. #endif    /* might not want to use this; old UNIX?*/
  519. X
  520. #if !defined(DEFGROUP)
  521. #define DEFGROUP    "binary"    /* group owner of files        */
  522. #endif    /* any local should be set in Makefile    */
  523. X
  524. #if !defined(DEFMODE)
  525. #define DEFMODE        "0755"        /* file installation mode    */
  526. #endif    /* all other files            */
  527. X
  528. #if !defined(DEFDIROWNER)
  529. #define DEFDIROWNER    DEFOWNER    /* dirs are all root owned    */
  530. #endif    /* might not want to use this; old UNIX?*/
  531. X
  532. #if !defined(DEFDIRGROUP)
  533. #define DEFDIRGROUP    DEFGROUP    /* group owner of dirs        */
  534. #endif    /* any local should be set in Makefile    */
  535. X
  536. #if !defined(DEFDIRMODE)
  537. #define DEFDIRMODE    "0755"        /* directory installation mode    */
  538. #endif    /* all dirs can be read by default    */
  539. X
  540. #if !defined(ODIROWNER)
  541. #define ODIROWNER    DEFDIROWNER
  542. #endif    /* default backup dir owner        */
  543. X
  544. #if !defined(ODIRGROUP)
  545. #define ODIRGROUP    DEFDIRGROUP
  546. #endif    /* default backup dir group        */
  547. X
  548. #if !defined(ODIRMODE)
  549. #define ODIRMODE    DEFDIRMODE
  550. #endif    /* default backup dir mode        */
  551. X
  552. #endif    /* must never inherit modes        */
  553. X
  554. X
  555. #if !defined(OLDDIR)
  556. #define OLDDIR        "OLD"
  557. #endif    /* default backup directory name    */
  558. X
  559. #if !defined(TMPINST)
  560. #define TMPINST        "#instXXXXXX"
  561. #endif    /* mktemp to get source on same device    */
  562. X
  563. #if !defined(TMPBOGUS)
  564. #define TMPBOGUS    "#bogusXXXXXX"
  565. #endif    /* last link to a running binary wedge    */
  566. X
  567. #if defined(INST_FACILITY)
  568. #include <syslog.h>
  569. #if !defined(MAXLOGLINE)
  570. #define MAXLOGLINE    256
  571. #endif    /* sprintf buffer size for syslog    */
  572. #endif    /* syslog changes to the system        */
  573. X
  574. #if !defined(BLKSIZ)
  575. #define BLKSIZ        8192    /* default blocksize for DoCopy()    */
  576. #endif    /* maybe not big enough            */
  577. Purdue
  578. chmod 0444 install.d/install.h ||
  579. echo 'restore of install.d/install.h failed'
  580. Wc_c="`wc -c < 'install.d/install.h'`"
  581. test 6261 -eq "$Wc_c" ||
  582.     echo 'install.d/install.h: original size 6261, current size' "$Wc_c"
  583. fi
  584. # ============= install.d/configure.h ==============
  585. if test -f 'install.d/configure.h' -a X"$1" != X"-c"; then
  586.     echo 'x - skipping install.d/configure.h (File already exists)'
  587. else
  588. echo 'x - extracting install.d/configure.h (Text)'
  589. sed 's/^X//' << 'Purdue' > 'install.d/configure.h' &&
  590. /*
  591. X * $Id: configure.h,v 7.5 90/10/08 11:42:13 ksb Exp $
  592. X * Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  593. X * 47907.  All rights reserved.
  594. X *
  595. X * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  596. X *
  597. X * This software is not subject to any license of the American Telephone
  598. X * and Telegraph Company or the Regents of the University of California.
  599. X *
  600. X * Permission is granted to anyone to use this software for any purpose on
  601. X * any computer system, and to alter it and redistribute it freely, subject
  602. X * to the following restrictions:
  603. X *
  604. X * 1. Neither the authors nor Purdue University are responsible for any
  605. X *    consequences of the use of this software.
  606. X *
  607. X * 2. The origin of this software must not be misrepresented, either by
  608. X *    explicit claim or by omission.  Credit to the authors and Purdue
  609. X *    University must appear in documentation and sources.
  610. X *
  611. X * 3. Altered versions must be plainly marked as such, and must not be
  612. X *    misrepresented as being the original software.
  613. X *
  614. X * 4. This notice may not be removed or altered.
  615. X */
  616. X
  617. /* install includes this file for the system admin to #define things
  618. X * she wants to change from the default values.  Read the descriptions
  619. X * in the install source code (lines 150-250) and #define them here
  620. X * to the local values.
  621. X *
  622. X * Some other major feature can be activated here.
  623. X */
  624. X
  625. /* some machines define one of these in /usr/include/sys/param.h
  626. X * if so you do not need it here...
  627. X */
  628. /* #define SYSV /**/
  629. /* #define bsd /**/
  630. /* #define DYNIX /**/
  631. /* #define HPUX7 /**/
  632. /* #define sun /**/
  633. X
  634. /* if we still don't know the platform look for other clues
  635. X */
  636. #if !defined(bsd) && !defined(SYSV) && !defined(DYNIX) && !defined(HPUX7)
  637. X
  638. #if defined(BSD)
  639. #define bsd 1
  640. #else
  641. #if defined(dynix)
  642. #define DYNIX 1
  643. #endif /* try dynix */
  644. #endif /* try bsd */
  645. X
  646. #endif /* still do not know */
  647. X
  648. /* DYNIX looks enough like bsd for this to be true
  649. X */
  650. #if defined(DYNIX) && !defined(bsd)
  651. #define bsd
  652. #endif
  653. X
  654. X
  655. /* Some sysV machines have getwd, some getcwd, some none
  656. X * If you do not have one, get one.
  657. X * (maybe popen a /bin/pwd and read it into the buffer?)
  658. X */
  659. #if defined(SYSV) || defined(HPUX7)
  660. #define getwd(Mp) getcwd(Mp,MAXPATHLEN)    /* return pwd        */
  661. extern char *getcwd();
  662. #else
  663. extern char *getwd();
  664. #endif
  665. X
  666. X
  667. /* the macros {DEF,DEFDIR,ODIR}{MODE,GROUP,OWNER}
  668. X * provide the default modes for any new files installed on the system
  669. X * a value in "quotes" will force that value, a nil pointer will
  670. X * force the value to be inherited from the parrent directory.
  671. X *
  672. X * The ones you do not set will be extrapolated from the others,
  673. X * start with DEFMODE as the default mode for a file, DEFDIRMODE
  674. X * as the defualt directory mode for all directories, and ODIRMODE
  675. X * as the mode for building OLD directories.
  676. X */
  677. /* #define DEFGROUP    "daemon"    /* ls -lg /bin/ls for a guess    */
  678. /* #define ODIROWNER    "charon"    /* safe login for purge to use    */
  679. #define ODIRGROUP    ((char *)0)    /* inherit group so mode works    */
  680. #define ODIRMODE    ((char *)0)    /* inherit the OLD dir mode    */
  681. X
  682. X
  683. /* this option allows all the binaries in a directory to
  684. X * get their default owner/group/mode from the directory
  685. X * (rather then hard coded defaults)
  686. X * This has the drawback that errors are propogated as well!
  687. X */
  688. /* #define INHERIT_OK            /* propogate modes down tree    */
  689. X
  690. X
  691. /* should the user be able to install a file on top of a symbolic link?
  692. X */
  693. /* #define DLINKOK    TRUE        /* yes, back it up        */
  694. X
  695. X
  696. /* should the user be able to use a symbolic link as a source file?
  697. X */
  698. /* #define SLINKOK    TRUE        /* yes, copy as a plain file    */
  699. X
  700. X
  701. /* if we have ansi C prototypes (cannot depend on __STDC__, sorry)
  702. X */
  703. #define HAVE_PROTO    0
  704. X
  705. X
  706. /* do we have an mkdir(2) system call?
  707. X */
  708. #if defined(pdp11) || defined(SYSV)
  709. #define HAVE_MKDIR    0
  710. #else
  711. #define HAVE_MKDIR    1
  712. #endif
  713. X
  714. X
  715. /* do we have to run a ranlib command on *.a files (-l)
  716. X */
  717. #if defined(SYSV) || defined(HPUX7)
  718. #define HAVE_RANLIB    0
  719. #else
  720. #define HAVE_RANLIB    1
  721. #endif
  722. X
  723. /* here you may #define alternate paths to some programs
  724. X * BIN{CHGRP,LS,MKDIR,RANLIB,STRIP}
  725. X */
  726. /* #define BINRANLIB    "/usr/gnu/ranlib"        /**/
  727. X
  728. X
  729. /* here you may set the flags used when we (under -v) run ls on a file
  730. X * or directory
  731. X * LS{,DIR}ARGS
  732. X */
  733. /* #define LSARGS    "-lsg"            /**/
  734. X
  735. X
  736. /* which file to include <strings.h> or <string.h> {STRINGS=1, STRING=0}
  737. X */
  738. #define STRINGS        defined(bsd)
  739. X
  740. X
  741. /* do we have scandir,readdir and friends in <sys/dir.h>, else look for
  742. X * <ndir.h>
  743. X */
  744. #define BSDDIR        defined(bsd)||defined(sun)
  745. X
  746. X
  747. /* do we have accounting type (uid_t, gid_t)?  (default to int)
  748. X */
  749. #if defined(pdp11) || defined(DYNIX) || defined(SYSV) || defined(sun)
  750. #define HAVE_ACCTTYPES    0
  751. #else
  752. #define HAVE_ACCTTYPES    1
  753. #endif
  754. X
  755. X
  756. /* do we have a kernel quota system?  (bsd like)
  757. X * (if so savepwent has to copy a quota struct)
  758. X */
  759. #if defined(bsd)
  760. #define HAVE_QUOTA    1
  761. #else
  762. #define HAVE_QUOTA    0
  763. #endif
  764. X
  765. X
  766. /* if your chmod(2) will not drop setgid bits on a dir with `chmod 755 dir`
  767. X * you need to define BROKEN_CHMOD (Suns have this problem -- yucko!)
  768. X * See SunBotch() in instck.c for more flamage.
  769. X */
  770. #define BROKEN_CHMOD    defined(sun)
  771. X
  772. X
  773. /* instck needs to know the name of the magic number field in a
  774. X * (struct exec) in <a.out.h>, and some other stuff
  775. X */
  776. #if defined(HPUX7)
  777. #define MNUMBER        a_magic.file_type
  778. #define MSYMS        a_lesyms
  779. #define EXHDR        struct exec
  780. #else
  781. #if defined(bsd)||defined(sun)
  782. #define MNUMBER        a_magic        /* magic number            */
  783. #define MSYMS        a_syms        /* number of symbols (strip)    */
  784. #define EXHDR        struct exec    /* type of this struct        */
  785. #else
  786. #if defined(eta)
  787. #define MNUMBER        f_magic
  788. #define MSYMS        f_nsyms
  789. #define EXHDR        struct filehdr
  790. #else /* SYSV? */
  791. #define MNUMBER        a_info
  792. #define MSYMS        a_syms
  793. #define EXHDR        struct exec
  794. #endif
  795. #endif
  796. #endif
  797. X
  798. X
  799. /* CONFIG controls the code to consult a checklist of special files.
  800. X * Set CONFIG to "", or (char *)0, for other effects.
  801. X * By #define'ing a checklist file you enable the code for it.
  802. X */
  803. #define CONFIG "/usr/local/etc/install.cf"    /* check list, and code    */
  804. /* #define CONFIG ""                /* no list, but code    */
  805. /* #undef CONFIG                /* no check or code    */
  806. X
  807. X
  808. /* INST_FACILITY controls installation syslogging.
  809. X * (LOG_LOCAL2 was the first local slot we had a PUCC)
  810. X * To enable installation syslog'ing uncomment the #define below.
  811. X */
  812. #if defined(bsd) || defined(HPUX7)
  813. X
  814. #if BSD > 42 || defined(HPUX7)
  815. #define INST_FACILITY LOG_LOCAL2     /* our 4.3 log facility        */
  816. #else
  817. #define INST_FACILITY LOG_INFO         /* our 4.2 log facility        */
  818. #endif
  819. X
  820. #else /* not bsd, not dynix */
  821. X
  822. #if defined(eta10)
  823. #define INST_FACILITY LOG_LOCAL2     /* eta10 uses 4.3 log facility    */
  824. #else    /* assume no logging here */
  825. #undef INST_FACILITY            /* we do not log changes    */
  826. #endif
  827. X
  828. #endif 
  829. Purdue
  830. chmod 0644 install.d/configure.h ||
  831. echo 'restore of install.d/configure.h failed'
  832. Wc_c="`wc -c < 'install.d/configure.h'`"
  833. test 6676 -eq "$Wc_c" ||
  834.     echo 'install.d/configure.h: original size 6676, current size' "$Wc_c"
  835. fi
  836. # ============= instck/instck.1l ==============
  837. if test ! -d 'instck'; then
  838.     echo 'x - creating directory instck'
  839.     mkdir 'instck'
  840. fi
  841. if test -f 'instck/instck.1l' -a X"$1" != X"-c"; then
  842.     echo 'x - skipping instck/instck.1l (File already exists)'
  843. else
  844. echo 'x - extracting instck/instck.1l (Text)'
  845. sed 's/^X//' << 'Purdue' > 'instck/instck.1l' &&
  846. .\" Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  847. .\" 47907.  All rights reserved.
  848. .\"
  849. .\" Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  850. .\"           Jeff Smith, jsmith@cc.purdue.edu, purdue!jsmith
  851. .\"
  852. .\" This software is not subject to any license of the American Telephone
  853. .\" and Telegraph Company or the Regents of the University of California.
  854. .\"
  855. .\" Permission is granted to anyone to use this software for any purpose on
  856. .\" any computer system, and to alter it and redistribute it freely, subject
  857. .\" to the following restrictions:
  858. .\"
  859. .\" 1. Neither the authors nor Purdue University are responsible for any
  860. .\"    consequences of the use of this software.
  861. .\"
  862. .\" 2. The origin of this software must not be misrepresented, either by
  863. .\"    explicit claim or by omission.  Credit to the authors and Purdue
  864. .\"    University must appear in documentation and sources.
  865. .\"
  866. .\" 3. Altered versions must be plainly marked as such, and must not be
  867. .\"    misrepresented as being the original software.
  868. .\"
  869. .\" 4. This notice may not be removed or altered.
  870. .\"
  871. .\" $Laser: ${tbl-tbl} %f | ${ltroff-ltroff} -man
  872. .\" $Compile: ${tbl-tbl} %f | ${nroff-nroff} -man | ${PAGER-${more-more}}
  873. .TH INSTCK 1L PUCC
  874. .SH NAME
  875. instck \- look for improperly installed files
  876. .SH SYNOPSIS
  877. \fBinstck\fP [\fB\-dilSv\fP] [\fB\-C\fP\fIchecklist\fP] [\fB\-g\fP\fIgroup\fP] [\fB\-m\fP\fImode\fP] [\fB\-o\fP\fIowner\fP] \fIdirectories\fP
  878. .br
  879. \fBinstck\fP [\fB\-G\fP] [\fB\-dl\fP] \fIdirectories\fP
  880. .br
  881. \fBinstck\fP [\fB\-hV\fP]
  882. .SH DESCRIPTION
  883. .PP
  884. .I Instck
  885. reads a system \fIchecklist\fP for a list of correct modes for
  886. installed files.
  887. It scans the file systems for incorrect owners, groups, modes etc.
  888. .PP
  889. For instance, if the shell were installed setuid root via:
  890. .br
  891. X    install \-m7555 \-o root \-g wheel sh /bin
  892. .br
  893. (note the extra \`5\') instck might find it.
  894. .PP
  895. If the given \fIdirectories\fP end with \*(lqOLD\*(rq they are
  896. only searched for half installed files and insecure backup modes.
  897. Patterns read from the \fIchecklist\fP which do not start with
  898. a slash (`/') are examined from the remaining \fIdirectories\fP.
  899. .PP
  900. .I Instck
  901. prompts stdin with suggested repairs under the \fB\-i\fP option.
  902. .SH OPTIONS
  903. .TP
  904. .BI \-C checklist
  905. Search \fIchecklist\fP for the expressions to match the
  906. installed files (see \fIinstall.cf\fP(5L).
  907. .TP
  908. .B \-d
  909. Do not check the contents of a directory, as in \fIls\fP(1).
  910. .TP
  911. .BI \-g group
  912. Set the default group for installed files.
  913. .TP
  914. .B \-G
  915. This option will generate a checklist file for the given directories.
  916. Such a file may have to be edited to be useful.
  917. .TP
  918. .B \-h
  919. Print a summary of \fIinstck\fP's usage.
  920. .TP
  921. .B \-i
  922. Prompt the user with suggested shell commands, for example if /tmp was
  923. the wrong mode \fIinstck\fP might prompt with:
  924. .sp 1
  925. X    instck: `/tmp' mode 0777 doesn't have bits to match drwxrwxrwt (1777)
  926. .br
  927. X    instck: chmod 1777 /tmp [nfhqy]
  928. .sp 1
  929. A reply of `y' or `Y' will run the proposed command, `f' will skip to
  930. the next file.
  931. .TP
  932. .B \-l
  933. A long list will be made of all the files that didn't match any rule.
  934. Under \-\fBG\fP all files will be put in the checklist.
  935. .TP
  936. .BI \-m mode
  937. Set the default mode for installed files.
  938. .TP
  939. .BI \-o owner
  940. Set the default owner for installed files.
  941. .TP
  942. .B \-S
  943. Run as if geteuid() returned zero.
  944. .TP
  945. .B \-v
  946. Be more verbose.
  947. .TP
  948. .B \-V
  949. Give version information.
  950. .SH EXAMPLES
  951. .TP
  952. instck /bin /usr/bin /usr/ucb /usr/local/bin /etc
  953. report inconsistent installations in the listed directories.
  954. .TP
  955. instck \-v /etc
  956. report inconsistent installations in /etc, be very verbose.
  957. .TP
  958. instck \-G /bin
  959. generate a checklist for /bin and all the files in /bin.
  960. .TP
  961. instck \-V
  962. Report version information, e.g.
  963. .br
  964. .RS
  965. .TS
  966. l s s
  967. l s s
  968. l l l.
  969. instck: version: $\&Id: main.c,v 6.0 90/03/08 15:34:49 ksb Exp $
  970. instck: configuration file: /usr/local/etc/install.cf
  971. instck: defaults: owner=root    group=binary    mode=\-rwxr\-xr\-x
  972. .TE
  973. .RE
  974. .SH FILES
  975. .TS
  976. l l.
  977. /usr/local/lib/instck.cf    the default \fIchecklist\fP file
  978. .TE
  979. .SH AUTHOR
  980. Kevin Braunsdorf, Purdue University Computing Center (ksb@cc.purdue.edu)
  981. .br
  982. Copyright \*(co 1990 Purdue Research Foundation.  All rights reserved.
  983. .SH SEE ALSO
  984. ls(1), chown(8), chgrp(1), chmod(1), install(1), ranlib(1), strip(1),
  985. geteuid(2),
  986. syslog(3), install.cf(5L)
  987. Purdue
  988. chmod 0444 instck/instck.1l ||
  989. echo 'restore of instck/instck.1l failed'
  990. Wc_c="`wc -c < 'instck/instck.1l'`"
  991. test 4281 -eq "$Wc_c" ||
  992.     echo 'instck/instck.1l: original size 4281, current size' "$Wc_c"
  993. fi
  994. # ============= instck/path.c ==============
  995. if test -f 'instck/path.c' -a X"$1" != X"-c"; then
  996.     echo 'x - skipping instck/path.c (File already exists)'
  997. else
  998. echo 'x - extracting instck/path.c (Text)'
  999. sed 's/^X//' << 'Purdue' > 'instck/path.c' &&
  1000. /*
  1001. X * $Id: path.c,v 7.1 90/09/17 10:25:42 ksb Exp $
  1002. X * Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  1003. X * 47907.  All rights reserved.
  1004. X *
  1005. X * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  1006. X *
  1007. X * This software is not subject to any license of the American Telephone
  1008. X * and Telegraph Company or the Regents of the University of California.
  1009. X *
  1010. X * Permission is granted to anyone to use this software for any purpose on
  1011. X * any computer system, and to alter it and redistribute it freely, subject
  1012. X * to the following restrictions:
  1013. X *
  1014. X * 1. Neither the authors nor Purdue University are responsible for any
  1015. X *    consequences of the use of this software.
  1016. X *
  1017. X * 2. The origin of this software must not be misrepresented, either by
  1018. X *    explicit claim or by omission.  Credit to the authors and Purdue
  1019. X *    University must appear in documentation and sources.
  1020. X *
  1021. X * 3. Altered versions must be plainly marked as such, and must not be
  1022. X *    misrepresented as being the original software.
  1023. X *
  1024. X * 4. This notice may not be removed or altered.
  1025. X */
  1026. X
  1027. /*
  1028. X * routines to keep track of many files in a UNIX file system        (ksb)
  1029. X */
  1030. #include <sys/param.h>
  1031. #include <sys/types.h>
  1032. #include <sys/stat.h>
  1033. X
  1034. #include "configure.h"
  1035. #include "install.h"
  1036. #include "main.h"
  1037. #include "special.h"
  1038. #include "instck.h"
  1039. #include "path.h"
  1040. X
  1041. #if STRINGS
  1042. #include <strings.h>
  1043. #else
  1044. #include <string.h>
  1045. #endif
  1046. X
  1047. extern char *malloc();
  1048. X
  1049. int chSep = '/';
  1050. X
  1051. static int (*pFunc)();
  1052. static char acBuffer[MAXPATHLEN];
  1053. X
  1054. static int
  1055. RecurPath(pCM, pch)
  1056. COMPONENT *pCM;
  1057. char *pch;
  1058. {
  1059. X    register int i;
  1060. X
  1061. X    if (nilCM == pCM) {
  1062. X        return 0;
  1063. X    }
  1064. X    for (*pch++ = chSep; (COMPONENT *)0 != pCM; pCM = pCM->pCMsibling) {
  1065. X        (void)strcpy(pch, pCM->pccomp);
  1066. X        if (pCM->fprint)
  1067. X            (*pFunc)(acBuffer, & pCM->user_data);
  1068. X        i = RecurPath(pCM->pCMchild, strchr(pch, '\000'));
  1069. X        if (0 != i) {
  1070. X            break;
  1071. X        }
  1072. X    }
  1073. X    return i;
  1074. }
  1075. X
  1076. int
  1077. ApplyPath(pCM, l_func)
  1078. COMPONENT *pCM;
  1079. int (*l_func)();
  1080. {
  1081. X    auto int (*temp)();
  1082. X    auto int i;
  1083. X
  1084. X    temp = pFunc;
  1085. X    if (nilCM != pCM) {
  1086. X        pFunc = l_func;
  1087. X        i = RecurPath(pCM, acBuffer);
  1088. X    }
  1089. X    pFunc = temp;
  1090. X    return i;
  1091. }
  1092. X
  1093. /*
  1094. X * add a (unique) path element
  1095. X *    AddPath(& pCMPath, "/usr/local/bin/foo");
  1096. X *
  1097. X * does a lot of unneded work some times, but a good hack at 2:30 am
  1098. X */
  1099. PATH_DATA *
  1100. AddPath(ppCM, pch)
  1101. COMPONENT **ppCM;
  1102. char *pch;
  1103. {
  1104. X    static char acEnd[] = "\000";
  1105. X    register char *pchTemp;
  1106. X    register COMPONENT *pCM = nilCM;
  1107. X
  1108. X    while ('\000' != *pch) {
  1109. X        while (chSep == *pch) {        /* /a//b        */
  1110. X            ++pch;
  1111. X        }
  1112. X
  1113. X        if ((char *)0 == (pchTemp = strchr(pch, chSep))) {
  1114. X            pchTemp = acEnd;
  1115. X        } else {
  1116. X            *pchTemp = '\000';
  1117. X        }
  1118. X        while (nilCM != (pCM = *ppCM)) {    /* level match      */
  1119. X            if (0 == strcmp(pCM->pccomp, pch)) {
  1120. X                if ('\000' == pchTemp[1]) {
  1121. X                    /* break 2 ! */
  1122. X                    goto escape;
  1123. X                }
  1124. X                goto contin;
  1125. X            }
  1126. X            ppCM = & pCM->pCMsibling;
  1127. X        }
  1128. X
  1129. X        /* not at this level, add it at end
  1130. X         */
  1131. X        pCM = newCM();
  1132. X        pCM->pCMsibling = nilCM;
  1133. X        pCM->pCMchild = nilCM;
  1134. X        pCM->pccomp = malloc((strlen(pch)|7)+1);
  1135. X        PUInit(& pCM->user_data);
  1136. X        (void)strcpy(pCM->pccomp, pch);
  1137. X        pCM->fprint = 0;
  1138. X        *ppCM = pCM;
  1139. X
  1140. X    contin:
  1141. X        *pchTemp++ = chSep;
  1142. X        pch = pchTemp;
  1143. X        ppCM = & pCM->pCMchild;
  1144. X    }
  1145. escape:
  1146. X    if (nilCM != pCM)
  1147. X        pCM->fprint = 1;
  1148. X    return (nilCM != pCM) ? & pCM->user_data : (PATH_DATA *)0;
  1149. }
  1150. Purdue
  1151. chmod 0444 instck/path.c ||
  1152. echo 'restore of instck/path.c failed'
  1153. Wc_c="`wc -c < 'instck/path.c'`"
  1154. test 3262 -eq "$Wc_c" ||
  1155.     echo 'instck/path.c: original size 3262, current size' "$Wc_c"
  1156. fi
  1157. # ============= install.d/Makefile ==============
  1158. if test -f 'install.d/Makefile' -a X"$1" != X"-c"; then
  1159.     echo 'x - skipping install.d/Makefile (File already exists)'
  1160. else
  1161. echo 'x - extracting install.d/Makefile (Text)'
  1162. sed 's/^X//' << 'Purdue' > 'install.d/Makefile' &&
  1163. # Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  1164. # 47907.  All rights reserved.
  1165. #
  1166. # Written by Jeff Smith, jsmith@cc.purdue.edu, purdue!jsmith
  1167. #
  1168. # This software is not subject to any license of the American Telephone
  1169. # and Telegraph Company or the Regents of the University of California.
  1170. #
  1171. # Permission is granted to anyone to use this software for any purpose on
  1172. # any computer system, and to alter it and redistribute it freely, subject
  1173. # to the following restrictions:
  1174. #
  1175. # 1. Neither the authors nor Purdue University are responsible for any
  1176. #    consequences of the use of this software.
  1177. #
  1178. # 2. The origin of this software must not be misrepresented, either by
  1179. #    explicit claim or by omission.  Credit to the authors and Purdue
  1180. #    University must appear in documentation and sources.
  1181. #
  1182. # 3. Altered versions must be plainly marked as such, and must not be
  1183. #    misrepresented as being the original software.
  1184. #
  1185. # 4. This notice may not be removed or altered.
  1186. #
  1187. # install's Makefile
  1188. #
  1189. # $Id: Makefile,v 7.3 90/10/08 13:14:57 ksb Exp $
  1190. #
  1191. # Set appropriate defaults for your site in (configure.h) unless you want
  1192. # the default owner, group, and mode for installations where none were
  1193. # specified and install can't figure out something reasonable.
  1194. #
  1195. # I suggest you lpr install.h and look at it while you edit configure.h
  1196. #
  1197. X
  1198. BIN=    ${DESTDIR}/usr/bin
  1199. ETC=    ${DESTDIR}/usr/local/etc
  1200. PROG=    install
  1201. TPROG=    installp
  1202. X
  1203. #L=/usr/include/local
  1204. L=../libopt
  1205. I=/usr/include
  1206. S=/usr/include/sys
  1207. P=
  1208. X
  1209. CDEFS=
  1210. INCLUDE= -I$L
  1211. DEBUG=    -O
  1212. CFLAGS= ${DEBUG} ${CDEFS} ${INCLUDE}
  1213. X
  1214. HDR=    configure.h dir.h file.h install.h main.h special.h special.i \
  1215. X    syscalls.h
  1216. OBJ=    dir.o file.o main.o special.o syscalls.o
  1217. SRC=    dir.c file.c main.c special.c syscalls.c
  1218. MAN=    install.1l
  1219. SOURCE=    Makefile ${SRC} ${HDR} ${MAN}
  1220. X
  1221. all: ${TPROG}
  1222. X
  1223. ${TPROG}:$P ${OBJ}
  1224. #    ${CC} ${CFLAGS} ${OBJ} -o $@ -lopt
  1225. #    ${CC} ${CFLAGS} ${OBJ} -o $@ -L /usr/local/lib -lopt
  1226. X    ${CC} ${CFLAGS} ${OBJ} -o $@ ../libopt/libopt.a
  1227. #    ${CC} ${CFLAGS} ${OBJ} -o $@ -lopt -lsocket
  1228. X
  1229. clean: FRC
  1230. X    rm -f Makefile.bak ${TPROG} *.o a.out core errs lint.errs shar tags
  1231. X
  1232. depend:    ${SRC} ${HDR} FRC
  1233. X    maketd ${CDEFS} ${INCLUDE} ${SRC}
  1234. X
  1235. install: all myself.cf FRC
  1236. X    ./installp -C./myself.cf -cvs ${TPROG} ${BIN}/${PROG}
  1237. X
  1238. lint: ${SRC} ${HDR} FRC
  1239. X    lint -h ${CDEFS} ${INCLUDE} ${SRC}
  1240. X
  1241. mkcat: ${MAN}
  1242. X    mkcat ${MAN}
  1243. X
  1244. print: ${SROUCE} FRC
  1245. X    lpr -J'${PROG} source' ${SROUCE}
  1246. X
  1247. source: ${SOURCE}
  1248. X
  1249. spotless: clean
  1250. X    rcsclean ${SOURCE}
  1251. X
  1252. tags: ${SRC} ${HDR}
  1253. X    ctags -t ${SRC} ${HDR}
  1254. X
  1255. ${SOURCE}:
  1256. X    co -q $@
  1257. X
  1258. FRC:
  1259. X
  1260. # DO NOT DELETE THIS LINE - maketd DEPENDS ON IT
  1261. X
  1262. dir.o: configure.h dir.c install.h main.h special.h syscalls.h
  1263. X
  1264. file.o: configure.h dir.h file.c install.h main.h special.h syscalls.h
  1265. X
  1266. main.o: configure.h dir.h file.h install.h main.c special.h syscalls.h
  1267. X
  1268. special.o: configure.h install.h main.h special.c special.h special.i \
  1269. X    syscalls.h
  1270. X
  1271. syscalls.o: configure.h install.h main.h syscalls.c
  1272. X
  1273. # *** Do not add anything here - It will go away. ***
  1274. Purdue
  1275. chmod 0644 install.d/Makefile ||
  1276. echo 'restore of install.d/Makefile failed'
  1277. Wc_c="`wc -c < 'install.d/Makefile'`"
  1278. test 2977 -eq "$Wc_c" ||
  1279.     echo 'install.d/Makefile: original size 2977, current size' "$Wc_c"
  1280. fi
  1281. # ============= install.d/README ==============
  1282. if test -f 'install.d/README' -a X"$1" != X"-c"; then
  1283.     echo 'x - skipping install.d/README (File already exists)'
  1284. else
  1285. echo 'x - extracting install.d/README (Text)'
  1286. sed 's/^X//' << 'Purdue' > 'install.d/README' &&
  1287. # $Id: README,v 7.0 90/09/17 09:41:36 ksb Exp $
  1288. X
  1289. Install is a tool for updating system files in a  controlled
  1290. environment.   The  design philosophy of install is to automate the
  1291. installation process and put  it  as  much  out  of reach  of  human
  1292. carelessness as possible, while providing a flexible, easy to use
  1293. tool.  Install provides the  following features:
  1294. X
  1295. X o    Install increases system security by providing  a  con-
  1296. X      trolled   installation   environment.   It  checks  the
  1297. X      actions of the superuser against a  configuration  file
  1298. X      that  you  build  (either by hand or using instck(1L)),
  1299. X      and can prevent grievous mistakes such as installing  a
  1300. X      shell  setuid  to  a  privileged  user, or installing a
  1301. X      world-writable password file.   An  appropriate  confi-
  1302. X      guration  file  can  guarantee that files are installed
  1303. X      with correct owner, group and mode,  that  strip(1)  is
  1304. X      run  on  binaries  and  ranlib(1)  is run on libraries.
  1305. X      Regardless of whether you create a configuration  file,
  1306. X      install  warns  you of many possible errors, unless you
  1307. X      make it quiet with its -q option.  For instance, if you
  1308. X      install a new version of the ex(1) editor and forget to
  1309. X      update its links, install will notice the  extra  links
  1310. X      to  the existing version and warn you that you might be
  1311. X      making a mistake.
  1312. X
  1313. X o    Installed files do not overwrite current versions.  The
  1314. X      current  version  is backed up to a subdirectory of its
  1315. X      dot directory (named "OLD" by default), where it may be
  1316. X      easily  re-installed  in  the case of an unforseen bug.
  1317. X      The companion program purge(1L) removes these backed-up
  1318. X      files  after a user-specified interval.  By default, if
  1319. X      you repeatedly install new versions of a file,  install
  1320. X      creates a series of backups, providing a primitive form
  1321. X      of version control.
  1322. X
  1323. X o    Install increases accountability by logging the actions
  1324. X      of  the  superuser.  This makes it easier to track down
  1325. X      errors after the fact.
  1326. X
  1327. X o    Install simplifies Makefiles by allowing you to combine
  1328. X      operations that would require several steps into a sin-
  1329. X      gle one (e.g., you can specify in a single command line
  1330. X      a   file's  ownership,  group,  mode,  whether  to  run
  1331. X      strip(1) or ranlib(1), and which  hard  or  soft  links
  1332. X      should be made).
  1333. X
  1334. X o    Despite its power and potential complexity, install  is
  1335. X      easy  to use interactively because it intuits appropri-
  1336. X      ate installation parameters for you,  either  by  using
  1337. X      those   associated  with  the  existing  file,  or  its
  1338. X      compilation-dependent defaults.  In most cases  you  do
  1339. X      not  have  to  specify  a  file's owner, group, or mode
  1340. X      unless you want them to be different from  an  existing
  1341. X      file.   Typical  interactive  usage  is simply "install
  1342. X      file destination."
  1343. X
  1344. X o    Install is as careful as  it  can  be  to  complete  an
  1345. X      installation once it is begun.  There is a point in the
  1346. X      code where unlink(2) and rename(2) must be executed  in
  1347. X      close  succession, and that is the only window in which
  1348. X      a system crash or a signal might leave system files  in
  1349. X      an  inconsistent state (unfortunately, this is not true
  1350. X      under operating systems that do not provide  an  atomic
  1351. X      rename(2) system call).  This is true even when install
  1352. X      must copy files across file system boundaries.
  1353. X
  1354. X o    Install may also be used to remove  (de-install)  files
  1355. X      in a controlled manner.
  1356. X
  1357. X o    Finally, install currently runs on a variety of  archi-
  1358. X      tectures  and  operating systems and is easy to port to
  1359. X      new platforms.
  1360. X
  1361. X
  1362. Known bugs, or problems....
  1363. X
  1364. install -d -rn /tmp/i-do-not-exist/OLD
  1365. X
  1366. X    outputs an error from stat about i-do-not-exist not existings,
  1367. X    (we know).  This is because the structure of building OLD dirs
  1368. X    from main.c is broken.  It should be easy to fix with a check
  1369. X    in dir.c/DirInstall for -n.  But then we have to find a directory
  1370. X    to stat to get the modes for the parent, and we can be wrong
  1371. X    (explicit owner/group/mode options will fool us).
  1372. X
  1373. X
  1374. kayessbee, ksb@cc.purdue.edu
  1375. Purdue
  1376. chmod 0444 install.d/README ||
  1377. echo 'restore of install.d/README failed'
  1378. Wc_c="`wc -c < 'install.d/README'`"
  1379. test 4174 -eq "$Wc_c" ||
  1380.     echo 'install.d/README: original size 4174, current size' "$Wc_c"
  1381. fi
  1382. # ============= install.d/main.h ==============
  1383. if test -f 'install.d/main.h' -a X"$1" != X"-c"; then
  1384.     echo 'x - skipping install.d/main.h (File already exists)'
  1385. else
  1386. echo 'x - extracting install.d/main.h (Text)'
  1387. sed 's/^X//' << 'Purdue' > 'install.d/main.h' &&
  1388. /*
  1389. X * $Id: main.h,v 7.0 90/09/17 09:41:59 ksb Exp $
  1390. X * Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  1391. X * 47907.  All rights reserved.
  1392. X *
  1393. X * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  1394. X *
  1395. X * This software is not subject to any license of the American Telephone
  1396. X * and Telegraph Company or the Regents of the University of California.
  1397. X *
  1398. X * Permission is granted to anyone to use this software for any purpose on
  1399. X * any computer system, and to alter it and redistribute it freely, subject
  1400. X * to the following restrictions:
  1401. X *
  1402. X * 1. Neither the authors nor Purdue University are responsible for any
  1403. X *    consequences of the use of this software.
  1404. X *
  1405. X * 2. The origin of this software must not be misrepresented, either by
  1406. X *    explicit claim or by omission.  Credit to the authors and Purdue
  1407. X *    University must appear in documentation and sources.
  1408. X *
  1409. X * 3. Altered versions must be plainly marked as such, and must not be
  1410. X *    misrepresented as being the original software.
  1411. X *
  1412. X * 4. This notice may not be removed or altered.
  1413. X */
  1414. X
  1415. /*
  1416. X * paths, names and options of tools we need to fork
  1417. X */
  1418. extern char BINCHGRP[];
  1419. extern char BINSTRIP[];
  1420. #if !defined(SYSV)
  1421. extern char BINRANLIB[];
  1422. #endif    /* sysV site do not have to run ranlib    */
  1423. extern char BINLS[];
  1424. #if defined(SYSV)
  1425. extern char LSARGS[];
  1426. extern char LSDIRARGS[];
  1427. #else    /* bsd needs a -g option to show group    */
  1428. extern char LSARGS[];
  1429. extern char LSDIRARGS[];
  1430. #endif    /* how does ls(1) show both owner&group    */
  1431. X
  1432. X
  1433. /* global variables for options
  1434. X */
  1435. extern char *progname;        /* tail of argv[0]            */
  1436. extern char *Group;        /* given group ownership        */
  1437. extern char *Owner;        /* given owner                */
  1438. extern char *Mode;        /* given mode                */
  1439. extern char *HardLinks;        /* hard links to installed file        */
  1440. extern char *SoftLinks;        /* symlinks to installed file        */
  1441. extern int Copy;        /* we're copying            */
  1442. extern int Destroy;        /* user doesn't want an OLD        */
  1443. extern int BuildDir;        /* we're installing a directory        */
  1444. extern int KeepTimeStamp;    /* if preserving timestamp        */
  1445. extern int fQuiet;        /* suppress some errors, be quiet    */
  1446. extern int Ranlib;        /* if we're running ranlib(1)        */
  1447. extern int Strip;        /* if we're running strip(1)        */
  1448. extern int fDelete;        /* remove the file/dir, log it        */
  1449. extern int fRecurse;        /* Sun-like recursive dir install    */
  1450. extern int fTrace;        /* if just tracing            */
  1451. extern int fVerbose;        /* if verbose                */
  1452. extern int f1Copy;        /* only keep one copy            */
  1453. #if defined(CONFIG)
  1454. extern struct passwd *pwdDef;    /* aux default owner for config file    */
  1455. extern struct group *grpDef;    /* aux default group for config file    */
  1456. extern char *pcSpecial;        /* file contains ckecked paths        */
  1457. #endif    /* have a -C option?            */
  1458. X
  1459. /*
  1460. X * global variables, but not option flags
  1461. X */
  1462. extern int bHaveRoot;        /* we have root permissions        */
  1463. extern char *pcGuilty;        /* the name logged as the installer    */
  1464. X
  1465. #define INSTALL    1
  1466. Purdue
  1467. chmod 0444 install.d/main.h ||
  1468. echo 'restore of install.d/main.h failed'
  1469. Wc_c="`wc -c < 'install.d/main.h'`"
  1470. test 2898 -eq "$Wc_c" ||
  1471.     echo 'install.d/main.h: original size 2898, current size' "$Wc_c"
  1472. fi
  1473. # ============= install.d/special.h ==============
  1474. if test -f 'install.d/special.h' -a X"$1" != X"-c"; then
  1475.     echo 'x - skipping install.d/special.h (File already exists)'
  1476. else
  1477. echo 'x - extracting install.d/special.h (Text)'
  1478. sed 's/^X//' << 'Purdue' > 'install.d/special.h' &&
  1479. /*
  1480. X * $Id: special.h,v 7.1 90/10/22 11:47:12 ksb Exp $
  1481. X * Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  1482. X * 47907.  All rights reserved.
  1483. X *
  1484. X * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  1485. X *
  1486. X * This software is not subject to any license of the American Telephone
  1487. X * and Telegraph Company or the Regents of the University of California.
  1488. X *
  1489. X * Permission is granted to anyone to use this software for any purpose on
  1490. X * any computer system, and to alter it and redistribute it freely, subject
  1491. X * to the following restrictions:
  1492. X *
  1493. X * 1. Neither the authors nor Purdue University are responsible for any
  1494. X *    consequences of the use of this software.
  1495. X *
  1496. X * 2. The origin of this software must not be misrepresented, either by
  1497. X *    explicit claim or by omission.  Credit to the authors and Purdue
  1498. X *    University must appear in documentation and sources.
  1499. X *
  1500. X * 3. Altered versions must be plainly marked as such, and must not be
  1501. X *    misrepresented as being the original software.
  1502. X *
  1503. X * 4. This notice may not be removed or altered.
  1504. X */
  1505. X
  1506. /*
  1507. X * if we have a config file (check list) we need to represent each    (ksb)
  1508. X * line of the file in a struct.
  1509. X */
  1510. #if defined(CONFIG)
  1511. X
  1512. #define    CF_STRIP    's'
  1513. #define CF_RANLIB    'l'
  1514. #define CF_NONE        'n'
  1515. #define CF_ANY        '?'
  1516. X
  1517. #define CF_IS_STRIP(MCF)    (CF_STRIP == (MCF).chstrip)
  1518. #define CF_IS_RANLIB(MCF)    (CF_RANLIB == (MCF).chstrip)
  1519. #define CF_IS_NONE(MCF)        (CF_NONE == (MCF).chstrip)
  1520. #define CF_IS_ANY(MCF)        (CF_ANY == (MCF).chstrip)
  1521. X
  1522. typedef struct CFnode {
  1523. X    int ffound;        /* is the file we have            */
  1524. X    int mtype;        /* file type bits            */
  1525. X    int mmust;        /* mode as an int            */
  1526. X    int moptional;        /* optional mode as an int        */
  1527. X    short int fbangowner;    /* !root form for owner            */
  1528. X    short int fbanggroup;    /* !system form for group        */
  1529. X    char acmode[16];    /* mode as a string            */
  1530. X    char acowner[16];    /* owner as a string            */
  1531. X    char acgroup[16];    /* group as a string            */
  1532. X    char chstrip;        /* strip ('l','s','-','*')        */
  1533. X    char *pcmesg;        /* text to print after install        */
  1534. X    uid_t uid;        /* used only by instck, to save lookups */
  1535. X    gid_t gid;        /* same as above            */
  1536. X    int iline;        /* the matching line on the cf file    */
  1537. X    char *pcspecial;    /* the special file we were searching    */
  1538. X    char *pcpat;        /* the glob pattern we matched on    */
  1539. X    char *pclink;        /* we a re just a link to another file    */
  1540. } CHLIST;
  1541. X
  1542. #if !defined(MAXCNFLINE)
  1543. #define MAXCNFLINE    132
  1544. #endif    /* lenght of a config line        */
  1545. X
  1546. #if HAVE_PROTO
  1547. extern char *NodeType(unsigned int, char *);
  1548. extern void ModetoStr(char *, int, int);
  1549. #if defined(INSTCK)
  1550. extern void DirCk(int, char **, char *, CHLIST *);
  1551. #endif
  1552. extern void Special(char *, char *, CHLIST *);
  1553. X
  1554. #else
  1555. extern char *NodeType();
  1556. extern void ModetoStr();
  1557. #if defined(INSTCK)
  1558. extern void DirCk();
  1559. #endif
  1560. extern void Special();
  1561. X
  1562. #endif
  1563. X
  1564. #endif    /* set check list flags from config file */
  1565. X
  1566. #define IS_LINK(MCL)  ((char *)0 != (MCL).pclink)
  1567. extern char *apcOO[];        /* name of 0/1 for user            */
  1568. extern struct group *grpDef;    /* default group on all files (this dir)*/
  1569. extern struct passwd *pwdDef;    /* default owner on all files (this dir)*/
  1570. X
  1571. /*
  1572. X * this macro could be in glob.h, or not...
  1573. X */
  1574. #define SamePath(Mglob, Mfile)    _SamePath(Mglob, Mfile, 1)
  1575. X
  1576. #if HAVE_PROTO
  1577. extern void CvtMode(char *, int *, int *);
  1578. extern int _SamePath(char *, char *, int);
  1579. extern void InitCfg(char *, char *);
  1580. #else
  1581. extern void CvtMode();
  1582. extern int _SamePath();
  1583. extern void InitCfg();
  1584. #endif
  1585. Purdue
  1586. chmod 0444 install.d/special.h ||
  1587. echo 'restore of install.d/special.h failed'
  1588. Wc_c="`wc -c < 'install.d/special.h'`"
  1589. test 3429 -eq "$Wc_c" ||
  1590.     echo 'install.d/special.h: original size 3429, current size' "$Wc_c"
  1591. fi
  1592. # ============= purge/purge.8l ==============
  1593. if test -f 'purge/purge.8l' -a X"$1" != X"-c"; then
  1594.     echo 'x - skipping purge/purge.8l (File already exists)'
  1595. else
  1596. echo 'x - extracting purge/purge.8l (Text)'
  1597. sed 's/^X//' << 'Purdue' > 'purge/purge.8l' &&
  1598. .\" $Id: purge.8l,v 7.0 90/09/17 11:38:42 ksb Exp $
  1599. .\" by Kevin Braunsdorf
  1600. .TH PURGE 8L LOCAL
  1601. .SH NAME
  1602. purge \- remove outdated backup copies of installed programs
  1603. .SH SYNOPSIS
  1604. \fB/usr/local/etc/purge\fP [\-\fBASVhnv\fP] [\-\fBd\fP \fIdays\fP] [\-\fBu\fP \fIuser\fP] [\fIdirs\fP]
  1605. .SH DESCRIPTION
  1606. .PP
  1607. \fIPurge\fP removes backup files that are more than \fIdays\fP old from
  1608. OLD directories created by \fIinstall\fP(1L).  \fIPurge\fP locates the
  1609. OLD directories by recursively descending \fIdirs\fP selecting directories
  1610. named \*(lqOLD\*(rq that the invoker owns.
  1611. .PP
  1612. \fIPurge\fP does not remove backup files with multiple hard links if it
  1613. cannot find all the links.
  1614. This is an indication that a product was installed without
  1615. regard for multiple names (\fIinstall\fP warns the installer in
  1616. such cases, but the error message may have been inadvertently ignored).
  1617. \fIPurge\fP directs the maintainer to run \fIinstck\fP(1L)
  1618. to correct any such problems.
  1619. .SH OPTIONS
  1620. .TP
  1621. .BI \-A
  1622. Allow OLD directories owned by any user to be searched for out of date backup files.
  1623. .TP
  1624. .BI \-d days
  1625. Days to keep backup files (default 14).
  1626. .TP
  1627. .BI \-h 
  1628. Print a help message.
  1629. .TP
  1630. .BI \-n 
  1631. Do not really execute commands, output what would be done (see \-\fBv\fP).
  1632. .TP
  1633. .BI \-S 
  1634. Run as if we are the superuser.
  1635. In combination with \-\fBn\fP this allows a system administrator to
  1636. see what \fIpurge\fP would do when run as root.
  1637. .TP
  1638. .BI \-u user
  1639. OLD directories may (also) be owned by this user.
  1640. .TP
  1641. .BI \-v 
  1642. Be verbose by showing approximate actions as shell commands.
  1643. .TP
  1644. .BI \-V 
  1645. Show version information.
  1646. .SH EXAMPLES
  1647. .TP
  1648. purge -v -d7 $HOME/bin
  1649. Remove any backup files from my bin which are older than one week.
  1650. .TP
  1651. purge -Sn /bin/OLD
  1652. Show which files purge would remove from /bin's OLD directory.
  1653. .TP
  1654. purge -u news -u uucp -u adm -u lp /
  1655. When run as root, purge all system OLD directories on this machine.
  1656. .TP
  1657. purge -V
  1658. Output \fIpurge\fP's version information, eg.:
  1659. .sp 1
  1660. .nf
  1661. purge: $\&Id: purge.c,v 2.0 90/06/24 21:28:27 ksb Exp $
  1662. purge: default superuser login name: root
  1663. purge: backup directory name: OLD
  1664. purge: valid backup directory owner: root
  1665. .fi
  1666. .SH BUGS
  1667. .PP
  1668. \fIPurge\fP does not cross nfs mount points.
  1669. .PP
  1670. This version of \fIpurge\fP is slightly incompatible with the shell script.
  1671. .SH AUTHOR
  1672. David L Stevens, Purdue UNIX Group, dls@cc.purdue.edu
  1673. .br
  1674. Kevin Braunsdorf, Purdue UNIX Group, ksb@cc.purdue.edu
  1675. .SH "SEE ALSO"
  1676. install(1L), instck(1L), rm(1), sh(1)
  1677. Purdue
  1678. chmod 0444 purge/purge.8l ||
  1679. echo 'restore of purge/purge.8l failed'
  1680. Wc_c="`wc -c < 'purge/purge.8l'`"
  1681. test 2444 -eq "$Wc_c" ||
  1682.     echo 'purge/purge.8l: original size 2444, current size' "$Wc_c"
  1683. fi
  1684. # ============= purge/main.c ==============
  1685. if test -f 'purge/main.c' -a X"$1" != X"-c"; then
  1686.     echo 'x - skipping purge/main.c (File already exists)'
  1687. else
  1688. echo 'x - extracting purge/main.c (Text)'
  1689. sed 's/^X//' << 'Purdue' > 'purge/main.c' &&
  1690. /*
  1691. X * machine generated cmd line parser
  1692. X */
  1693. X
  1694. #include <ctype.h>
  1695. #include "getopt.h"
  1696. #include <stdio.h>
  1697. #include "configure.h"
  1698. #include "install.h"
  1699. #include "purge.h"
  1700. X
  1701. char
  1702. X    *progname = "$Id$",
  1703. X    u_terse[] = " [-ASVhnv] [-d days] [-u user] [dirs]",
  1704. X    *u_help[] = {
  1705. X        "A      purge for all users",
  1706. X        "S      run as if we were the superuser",
  1707. X        "V      show version information",
  1708. X        "d days days to keep backup files (default 14)",
  1709. X        "h      print this help message",
  1710. X        "n      do not really execute commands",
  1711. X        "u user OLD directories may be owned by this user",
  1712. X        "v      be verbose",
  1713. X        "dirs   dirs to purge",
  1714. X        (char *)0
  1715. X    };
  1716. int
  1717. X    fAnyOwner = 0,
  1718. X    fSuperUser = 0,
  1719. X    fVersion = 0,
  1720. X    iDays = 14,
  1721. X    fExec = 1,
  1722. X    fVerbose = 0;
  1723. X
  1724. static char sbData[] = "%s: illegal data for %s option `%c\'\n";
  1725. X
  1726. static void
  1727. chkint(opt, pch)
  1728. int opt;
  1729. char *pch;
  1730. {
  1731. X    register int c;
  1732. X
  1733. X    while (isspace(*pch))
  1734. X        ++pch;
  1735. X    c = *pch;
  1736. X    if ('+' == c || '-' == c)
  1737. X        ++pch;
  1738. X    while (isdigit(*pch))
  1739. X        ++pch;
  1740. X    if ('\000' != *pch) {
  1741. X        fprintf(stderr, sbData, progname, "integer", opt);
  1742. X        exit(1);
  1743. X    }
  1744. }
  1745. X
  1746. /*
  1747. X * parser
  1748. X */
  1749. int
  1750. main(argc, argv)
  1751. int argc;
  1752. char **argv;
  1753. {
  1754. X    static char
  1755. X        sbOpt[] = "ASVd:hnu:v",
  1756. X        *u_pch = (char *)0;
  1757. X    static int
  1758. X        u_loop = 0;
  1759. X    register int curopt;
  1760. X    extern int atoi();
  1761. X    extern char *strrchr();
  1762. X
  1763. X    progname = strrchr(argv[0], '/');
  1764. X    if ((char *)0 == progname)
  1765. X        progname = argv[0];
  1766. X    else
  1767. X        ++progname;
  1768. X    while (EOF != (curopt = getopt(argc, argv, sbOpt))) {
  1769. X        switch (curopt) {
  1770. X        case BADARG:
  1771. X            fprintf(stderr, "%s: option %c needs a parameter\n", progname, optopt);
  1772. X            exit(1);
  1773. X        case BADCH:
  1774. X            fprintf(stderr, "%s: usage%s\n", progname, u_terse);
  1775. X            exit(1);
  1776. X        case 'A':
  1777. X            fAnyOwner = ! 0;
  1778. X            continue;
  1779. X        case 'S':
  1780. X            fSuperUser = ! 0;
  1781. X            continue;
  1782. X        case 'V':
  1783. X            fVersion = ! 0;
  1784. X            continue;
  1785. X        case 'd':
  1786. X            chkint('d', optarg);
  1787. X            iDays = atoi(optarg);
  1788. X            continue;
  1789. X        case 'h':
  1790. X            fprintf(stdout, "%s: usage%s\n", progname, u_terse);
  1791. X            for (u_loop = 0; (char *)0 != (u_pch = u_help[u_loop]); ++u_loop) {
  1792. X                fprintf(stdout, "%s\n", u_pch);
  1793. X            }
  1794. X            exit(0);
  1795. X        case 'n':
  1796. X            fExec = !1;
  1797. X            fVerbose = !0;
  1798. X            continue;
  1799. X        case 'u':
  1800. X            (void)AddHer(optarg);
  1801. X            continue;
  1802. X        case 'v':
  1803. X            fVerbose = ! 0;
  1804. X            continue;
  1805. X        }
  1806. X        break;
  1807. X    }
  1808. X    InitAll();
  1809. X    if (fVersion) {
  1810. X        exit(Version());
  1811. X    }
  1812. X
  1813. X    curopt = 1;
  1814. X    while (EOF != getarg(argc, argv)) {
  1815. X        curopt = 0;
  1816. X        Which(optarg);
  1817. X    }
  1818. X    if (curopt) {
  1819. X        exit(0);
  1820. X    }
  1821. X
  1822. X    Done();
  1823. X    exit(0);
  1824. }
  1825. Purdue
  1826. chmod 0644 purge/main.c ||
  1827. echo 'restore of purge/main.c failed'
  1828. Wc_c="`wc -c < 'purge/main.c'`"
  1829. test 2394 -eq "$Wc_c" ||
  1830.     echo 'purge/main.c: original size 2394, current size' "$Wc_c"
  1831. fi
  1832. # ============= purge/Makefile.mkcmd ==============
  1833. if test -f 'purge/Makefile.mkcmd' -a X"$1" != X"-c"; then
  1834.     echo 'x - skipping purge/Makefile.mkcmd (File already exists)'
  1835. else
  1836. echo 'x - extracting purge/Makefile.mkcmd (Text)'
  1837. sed 's/^X//' << 'Purdue' > 'purge/Makefile.mkcmd' &&
  1838. #    $Id: Makefile,v 7.2 90/11/28 08:52:31 ksb Exp $
  1839. #
  1840. #    Makefile for purge
  1841. #
  1842. X
  1843. PROG=    purge
  1844. BIN=    ${DESTDIR}/usr/local/etc
  1845. MANROOT= ${DESTDIR}/usr/man
  1846. X
  1847. # where is the source code for install(1L)?
  1848. INSTALLD= ../install.d
  1849. #INSTALLD= /usr/src/usr.bin/install.d
  1850. #INSTALLD= /usr/src/local/cmd/install.d
  1851. X
  1852. # which type of links to build
  1853. #LN=ln
  1854. LN=ln -s
  1855. X
  1856. L=../libopt
  1857. #L=/usr/include/local
  1858. I=/usr/include
  1859. S=/usr/include/sys
  1860. P=
  1861. X
  1862. INCLUDE= -I$L
  1863. DEBUG=    -O
  1864. CDEFS=  
  1865. CFLAGS= ${DEBUG} ${CDEFS} ${INCLUDE}
  1866. X
  1867. LINKH=    configure.h install.h
  1868. LINKC=    
  1869. LINK=    ${LINKH} ${LINKC}
  1870. GENH=    main.h ${LINKH}
  1871. GENC=    main.c ${LINKC}
  1872. GEN=    ${GENC} ${GENH}
  1873. HDR=    purge.h filedup.h
  1874. SRC=    purge.c filedup.c
  1875. DEP=    ${GENC} ${SRC}
  1876. OBJ=    main.o purge.o filedup.o
  1877. MAN=    purge.8l
  1878. OTHER=    README purge.m
  1879. SOURCE=    Makefile ${OTHER} ${MAN} ${HDR} ${SRC}
  1880. X
  1881. all: ${PROG}
  1882. X
  1883. ${PROG}:$P ${OBJ}
  1884. #    ${CC} -o $@ ${CFLAGS} ${OBJ} -lopt
  1885. #    ${CC} -o $@ ${CFLAGS} ${OBJ} -L /usr/local/lib -lopt
  1886. X    ${CC} -o $@ ${CFLAGS} ${OBJ} ../libopt/libopt.a
  1887. X
  1888. main.h: main.c
  1889. X
  1890. main.c: ${PROG}.m
  1891. X    mkcmd std_help.m ${PROG}.m
  1892. X    -(cmp -s prog.c main.c || (cp prog.c main.c && echo main.c updated))
  1893. X    -(cmp -s prog.h main.h || (cp prog.h main.h && echo main.h updated))
  1894. X    rm -f prog.[ch]
  1895. X
  1896. swap: main.c main.h
  1897. X    mv Makefile Makefile.mkcmd
  1898. X    mv Makefile.plain Makefile
  1899. X    make depend
  1900. X
  1901. links: ${LINK}
  1902. X
  1903. ${LINK}:
  1904. X    ${LN} ${INSTALLD}/$@ ./$@
  1905. X
  1906. clean: FRC
  1907. X    rm -f Makefile.bak ${PROG} ${GEN} *.o a.out core errs lint.out tags
  1908. X
  1909. calls: ${SRC} ${HDR} ${GEN} FRC
  1910. X    calls ${CDEFS} ${INCLUDE} ${DEP}
  1911. X
  1912. depend: ${SRC} ${HDR} ${GEN} FRC
  1913. X    maketd ${CDEFS} ${INCLUDE} ${DEP}
  1914. X
  1915. dirs: ${BIN}
  1916. X
  1917. install: all dirs FRC
  1918. X    install -cs ${PROG} ${BIN}/${PROG}
  1919. X
  1920. lint: ${SRC} ${HDR} ${GEN} FRC
  1921. X    lint -h ${CDEFS} ${INCLUDE} ${DEP}
  1922. X
  1923. mkcat: ${MAN}
  1924. X    mkcat -r${MANROOT} ${MAN}
  1925. X
  1926. print: source FRC
  1927. X    lpr -J'${PROG} source' ${SOURCE}
  1928. X
  1929. source: ${SOURCE}
  1930. X
  1931. spotless: clean
  1932. X    rcsclean ${SOURCE}
  1933. X
  1934. tags: ${HDR} ${SRC} ${GEN}
  1935. X    ctags -t ${HDR} ${SRC} ${GEN}
  1936. X
  1937. / ${BIN}:
  1938. X    install -dr $@
  1939. X
  1940. ${SOURCE}:
  1941. X    co -q $@
  1942. X
  1943. FRC:
  1944. X
  1945. # DO NOT DELETE THIS LINE - maketd DEPENDS ON IT
  1946. X
  1947. main.o: configure.h install.h main.c purge.h
  1948. X
  1949. purge.o: configure.h filedup.h install.h main.h purge.c purge.h
  1950. X
  1951. filedup.o: filedup.c filedup.h
  1952. X
  1953. # *** Do not add anything here - It will go away. ***
  1954. Purdue
  1955. chmod 0644 purge/Makefile.mkcmd ||
  1956. echo 'restore of purge/Makefile.mkcmd failed'
  1957. Wc_c="`wc -c < 'purge/Makefile.mkcmd'`"
  1958. test 2197 -eq "$Wc_c" ||
  1959.     echo 'purge/Makefile.mkcmd: original size 2197, current size' "$Wc_c"
  1960. fi
  1961. # ============= install.cf/Makefile ==============
  1962. if test ! -d 'install.cf'; then
  1963.     echo 'x - creating directory install.cf'
  1964.     mkdir 'install.cf'
  1965. fi
  1966. if test -f 'install.cf/Makefile' -a X"$1" != X"-c"; then
  1967.     echo 'x - skipping install.cf/Makefile (File already exists)'
  1968. else
  1969. echo 'x - extracting install.cf/Makefile (Text)'
  1970. sed 's/^X//' << 'Purdue' > 'install.cf/Makefile' &&
  1971. #    $Id: Makefile,v 7.1 90/11/28 12:38:12 ksb Exp $
  1972. #
  1973. #    Makefile for install.cf
  1974. #
  1975. X
  1976. PROG=    install.cf
  1977. ETC=    ${DESTDIR}/usr/local/etc
  1978. DOC=    ${DESTDIR}/usr/man
  1979. X
  1980. SRC=    install.cf
  1981. MAN=    install.cf.5l
  1982. OTHER=    README
  1983. SOURCE=    Makefile ${OTHER} ${MAN} ${SRC}
  1984. X
  1985. all: ${PROG}
  1986. X
  1987. clean: FRC
  1988. X    rm -f Makefile.bak a.out core errs lint.out tags
  1989. X
  1990. deinstall: ${MAN} ${DOC} FRC
  1991. X    install -R ${ETC}/${PROG}
  1992. X    mkcat -r${DOC} -D ${MAN}
  1993. X
  1994. depend: FRC
  1995. X
  1996. dirs: ${ETC}
  1997. X
  1998. install: all dirs FRC
  1999. X    install -c -m644 ${PROG} ${ETC}/${PROG}
  2000. X
  2001. lint: FRC
  2002. X
  2003. mkcat: ${MAN} ${DOC} FRC
  2004. X    mkcat -r${DOC} ${MAN}
  2005. X
  2006. print: source FRC
  2007. X    lpr -J'${PROG} source' ${SOURCE}
  2008. X
  2009. source: ${SOURCE}
  2010. X
  2011. spotless: clean
  2012. X    rcsclean ${SOURCE}
  2013. X
  2014. tags: FRC
  2015. X
  2016. / ${ETC}:
  2017. X    install -dr $@
  2018. X
  2019. ${SOURCE}:
  2020. X    co -q $@
  2021. X
  2022. FRC:
  2023. X
  2024. # DO NOT DELETE THIS LINE - make depend DEPENDS ON IT
  2025. X
  2026. # *** Do not add anything here - It will go away. ***
  2027. Purdue
  2028. chmod 0644 install.cf/Makefile ||
  2029. echo 'restore of install.cf/Makefile failed'
  2030. Wc_c="`wc -c < 'install.cf/Makefile'`"
  2031. test 837 -eq "$Wc_c" ||
  2032.     echo 'install.cf/Makefile: original size 837, current size' "$Wc_c"
  2033. fi
  2034. # ============= install.d/syscalls.h ==============
  2035. if test -f 'install.d/syscalls.h' -a X"$1" != X"-c"; then
  2036.     echo 'x - skipping install.d/syscalls.h (File already exists)'
  2037. else
  2038. echo 'x - extracting install.d/syscalls.h (Text)'
  2039. sed 's/^X//' << 'Purdue' > 'install.d/syscalls.h' &&
  2040. /*
  2041. X * $Id: syscalls.h,v 7.0 90/09/17 09:42:07 ksb Exp $
  2042. X * Copyright 1990 Purdue Research Foundation, West Lafayette, Indiana
  2043. X * 47907.  All rights reserved.
  2044. X *
  2045. X * Written by Kevin S Braunsdorf, ksb@cc.purdue.edu, purdue!ksb
  2046. X *
  2047. X * This software is not subject to any license of the American Telephone
  2048. X * and Telegraph Company or the Regents of the University of California.
  2049. X *
  2050. X * Permission is granted to anyone to use this software for any purpose on
  2051. X * any computer system, and to alter it and redistribute it freely, subject
  2052. X * to the following restrictions:
  2053. X *
  2054. X * 1. Neither the authors nor Purdue University are responsible for any
  2055. X *    consequences of the use of this software.
  2056. X *
  2057. X * 2. The origin of this software must not be misrepresented, either by
  2058. X *    explicit claim or by omission.  Credit to the authors and Purdue
  2059. X *    University must appear in documentation and sources.
  2060. X *
  2061. X * 3. Altered versions must be plainly marked as such, and must not be
  2062. X *    misrepresented as being the original software.
  2063. X *
  2064. X * 4. This notice may not be removed or altered.
  2065. X */
  2066. X
  2067. #if HAVE_PROTO
  2068. extern void BlockSigs(void);
  2069. extern void UnBlockSigs(void);
  2070. extern void Die(char *);
  2071. extern struct group * savegrent(struct group *);
  2072. extern struct passwd *savepwent(struct passwd *);
  2073. extern void ChMode(char *, int);
  2074. extern void ChGroup(char *, struct group *pgroup);
  2075. extern void ChOwnGrp(char *, struct passwd *, struct group *);
  2076. extern void ChTimeStamp(char *, struct stat *);
  2077. extern int DoCopy(char *, char *);
  2078. extern char *Mytemp(char *);
  2079. extern void MungName(char *);
  2080. extern char *StrTail(char *);
  2081. #if HAVE_SLINK
  2082. extern int CopySLink(char *, char *);
  2083. #endif    /* don't handle links at all */
  2084. extern int Rename(char *, char *, char *);
  2085. extern int IsDir(char *);
  2086. extern int MyWait(int);
  2087. extern int RunCmd(char *, char *, char *);
  2088. #else
  2089. extern void BlockSigs();
  2090. extern void UnBlockSigs();
  2091. extern void Die();
  2092. extern struct group * savegrent();
  2093. extern struct passwd *savepwent();
  2094. extern void ChMode();
  2095. extern void ChGroup();
  2096. extern void ChOwnGrp();
  2097. extern void ChTimeStamp();
  2098. extern char *Mytemp();
  2099. extern void MungName();
  2100. extern char *StrTail();
  2101. extern int DoCopy();
  2102. #if HAVE_SLINK
  2103. extern int CopySLink();
  2104. #endif    /* don't handle links at all */
  2105. extern int Rename();
  2106. extern int IsDir();
  2107. extern int MyWait();
  2108. extern int RunCmd();
  2109. #endif
  2110. X
  2111. extern uid_t geteuid();
  2112. extern gid_t getegid();
  2113. Purdue
  2114. chmod 0444 install.d/syscalls.h ||
  2115. echo 'restore of install.d/syscalls.h failed'
  2116. Wc_c="`wc -c < 'install.d/syscalls.h'`"
  2117. test 2372 -eq "$Wc_c" ||
  2118.     echo 'install.d/syscalls.h: original size 2372, current size' "$Wc_c"
  2119. fi
  2120. true || echo 'restore of instck/path.h failed'
  2121. echo End of part 6, continue with part 7
  2122. exit 0
  2123.  
  2124. exit 0 # Just in case...
  2125.