home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1154 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  31.2 KB

  1. From: pjc@pcbox.UUCP (Paul J. Condie)
  2. Newsgroups: alt.sources
  3. Subject: menu(1)  part 11 of 11
  4. Message-ID: <433@pcbox.UUCP>
  5. Date: 6 Apr 90 17:58:33 GMT
  6.  
  7.  
  8. #!/bin/sh
  9. # this is part 11 of a multipart archive
  10. # do not concatenate these parts, unpack them in order with /bin/sh
  11. # file utilities.d/libgeti.d/popmenu.3 continued
  12. #
  13. CurArch=11
  14. if test ! -r s2_seq_.tmp
  15. then echo "Please unpack part 1 first!"
  16.      exit 1; fi
  17. ( read Scheck
  18.   if test "$Scheck" != $CurArch
  19.   then echo "Please unpack part $Scheck next!"
  20.        exit 1;
  21.   else exit 0; fi
  22. ) < s2_seq_.tmp || exit 1
  23. echo "x - Continuing file utilities.d/libgeti.d/popmenu.3"
  24. sed 's/^X//' << 'SHAR_EOF' >> utilities.d/libgeti.d/popmenu.3
  25. Xwill be displayed.
  26. X.TP 6
  27. Xhelpfile
  28. XThe helpfile name that contains help text to be displayed when the uses presses
  29. Xthe help key.  If a helpfile is supplied a "?" is displayed in the lower
  30. Xright hand corner of the menu.  Set to null if no help file is provided.
  31. X.br
  32. XThe help file should be in a format corresponding to GetInput(3),  see
  33. XGetInput(3X) for more information.  Popmenu is hard-coded to look for
  34. X\fIhelptag\fP "popmenu" in the helpfile.
  35. X.TP 6
  36. Xwin_size
  37. XThe length of the pop-up window.  This may be less than the number of
  38. Xoptions, so that popmenu() will only display
  39. X.I win_size
  40. Xnumber of options on the screen.  A window size of 6 or the number of options,
  41. Xwhichever is less, is used if this field is set to 0.  Note that this field
  42. Xshould not be set to be more than 22, which is the normal screen size (24)
  43. Xminus 2 for the borders.
  44. X.TP 6
  45. Xsizeof( option[0] ) or 0
  46. XIs an integer telling popmenu() the size of one option array element.  It can
  47. Xalso be set to
  48. X.I zero(0)
  49. Xif (char **) array is passed as the next argument,
  50. X.I popmenu
  51. Xwill figure out the increment as the size of a char pointer.
  52. X.TP 6
  53. Xoption    
  54. XThis is a (char *) to an array which store
  55. Xthe options you want to appear in the menu.  This array can be either a
  56. Xtwo dimensional char array, or a structure array, or even an array of pointers.
  57. XThe first char string in each array element up to the first NULL character is
  58. Xused to be displayed as options.  The rest of the field may just be table
  59. Xlook-up items.  Also, The last element must be NULL to signify the end of the
  60. Xtable.
  61. X.PP
  62. XFor menus that has to be built dynamically during run time,
  63. Xthere are benefit of preparing your option table either way.  With a pre-set
  64. Xchar array storing the menu entries, cpu usage is optimized in the expense of
  65. Xmemory; while using char *array will optimize memory usage but has to allocate
  66. Xmemory on the fly.  Menus built at compiled time are about equal with either
  67. Xmethod.
  68. X
  69. X.SH CREDITS
  70. XPaul J. Condie      7/87    (original author)
  71. X.br
  72. X{ihnp4,lll-crg,qantel,pyramid}!ptsfa!pbody!pcbox!pjc
  73. X
  74. XSam S. Lok        enhancements
  75. X
  76. X.SH EXAMPLE
  77. X.nf
  78. X#include    <curses.h>
  79. X
  80. X#define    NEWMENU    0
  81. X
  82. Xint    KeyHelp = 23;        /* control w */
  83. Xint    KeyCancel = 27;        /* ESC */
  84. Xint    KeyDown;
  85. Xint    KeyUp;
  86. X
  87. Xmain ()
  88. X{
  89. X    int    option;        /* the option the user selected */
  90. X    static char    mymenu[][7] = {
  91. X        "QUERY", "ADD", "DELETE", (char *)NULL };
  92. X    static char    *yourmenu[] = {
  93. X        "QUERY", "ADD", "DELETE", (char *)NULL };
  94. X
  95. X
  96. X    /* define a new menu */
  97. X    popmenu(NEWMENU, 1, 5,10, "Title", "", 3, sizeof( mymenu[0] ), mymenu );
  98. X    popmenu(NEWMENU, 2, 7,15, "Title", "", 0, 0, yourmenu );
  99. X
  100. X    /* run the menu */
  101. X    option = popmenu (1);
  102. X    option = popmenu (2);
  103. X
  104. X    /* remove the menu from the screen */
  105. X    touchwin (stdscr);
  106. X    wrefresh (stdscr);
  107. X}
  108. X.fi
  109. X
  110. X.SH SEE ALSO
  111. Xcurses(3X), GetInput(3X).
  112. SHAR_EOF
  113. echo "File utilities.d/libgeti.d/popmenu.3 is complete"
  114. chmod 0444 utilities.d/libgeti.d/popmenu.3 || echo "restore of utilities.d/libgeti.d/popmenu.3 fails"
  115. echo "x - extracting utilities.d/libgeti.d/GetInput.hlp (Text)"
  116. sed 's/^X//' << 'SHAR_EOF' > utilities.d/libgeti.d/GetInput.hlp &&
  117. XGETINPUT
  118. X.TITLE GETINPUT Help
  119. XMover Keys:
  120. X        KEY_RETURN  (^m)    Traverse forwards through the fields.
  121. X        KEY_DOWN  (^j)      Traverse forwards through the fields.
  122. X        KEY_UP  (^k)        Traverse backwards through the fields.
  123. X        KEY_TAB  (^i)       Fast forward through the fields.
  124. X        KEY_BTAB            Fast reverse through the fields.
  125. XField Editing Keys:
  126. X        KEY_BEG  (^b)       Place cursor at beginning of field.
  127. X        KEY_END  (^e)       Place cursor at end of input in field.
  128. X        KEY_RIGHT  (^l)     Forward space within the field.
  129. X        KEY_LEFT  (^h)      Backspace within the field (non-destructive).
  130. X        KEY_BACKSPACE  (^h) Same as KEY_LEFT.
  131. X        KEY_EOL  (^d)       Delete from cursor to end of field.
  132. X        KEY_DL  (^c)        Clear field and home cursor.
  133. X        KEY_DC  (^x)        Delete a character.
  134. X        KEY_IC  (^t)        Toggle between type-over and insert mode.
  135. XOther Keys:
  136. X        KEY_HELP  (?)       Display help screen.
  137. X        KEY_REFRESH  (^r)   Redraw the screen.
  138. X        KEY_ACCEPT  (^a)    Accept all input and exit screen.
  139. X        KEY_CANCEL  (esc)   Cancel all input and exit screen.
  140. X        KEY_SAVE  (^f)      Save screen to a file.
  141. X        KEY_PRINT  (^p)     Print screen to lp.
  142. XGETINPUT
  143. X
  144. X
  145. X
  146. Xpopmenu
  147. X.TITLE Pop-Up Menu Help
  148. XSELECTING OPTIONS:
  149. X    Press the "up arrow key", "^k", "down arrow key", "^j" 
  150. X    to place bar on option and press "return".
  151. X
  152. X    or
  153. X
  154. X    Enter the first character of the option you
  155. X    wish to select and press "return".
  156. X
  157. X    KEY_CANCEL (esc)   - Cancel selection.
  158. Xpopmenu
  159. X
  160. X
  161. X
  162. Xhelp
  163. X.TITLE Using Help
  164. XHelp displays consist of a description displayed in a window.
  165. XIf the description doesn't fit in the window, the Up Arrow and
  166. XDown Arrow keys can be used to view a few more lines of the 
  167. Xdisplay.  Exiting the help system will return the display to 
  168. Xthe state it was in when you asked for help.
  169. X
  170. X   The following keys are active in help:
  171. X        KEY_CANCEL  (esc)   Exit help.
  172. X        KEY_DOWN  (^j)      View a few more lines.
  173. X        KEY_UP  (^k)        View the previous lines.
  174. X        KEY_BEG  (^b)       Display first page.
  175. X        KEY_END  (^e)       Display last page.
  176. Xhelp
  177. SHAR_EOF
  178. chmod 0444 utilities.d/libgeti.d/GetInput.hlp || echo "restore of utilities.d/libgeti.d/GetInput.hlp fails"
  179. echo "x - extracting utilities.d/checkpass.d/checkpass.1 (Text)"
  180. sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.1 &&
  181. X. \ %W% DeltaDate %G% ExtrDate %H% 
  182. X.po 6
  183. X.TH CHECKPASS 1 "" "Menu Utility"
  184. X
  185. X.SH \s9NAME\s0
  186. Xcheckpass \- find matching passwd in /etc/passwd file for a specified login.
  187. X
  188. X.SH SYNOPSIS
  189. Xcheckpass login passwd 
  190. X
  191. X.SH DESCRIPTION
  192. X.I Checkpass 
  193. Xfinds the \fIlogin\fP password in the /etc/passwd file, encrypts the
  194. X\fIpasswd\fP and does a comparison. 
  195. X.SH FILES
  196. X/etc/passwd
  197. X
  198. X.SH AUTHOR
  199. XVickie C. Chui
  200. X
  201. X.SH DIAGNOSTICS
  202. XCheckpass returns exit code zero if it was successful, otherwise, it
  203. Xreturns a 4.
  204. SHAR_EOF
  205. chmod 0644 utilities.d/checkpass.d/checkpass.1 || echo "restore of utilities.d/checkpass.d/checkpass.1 fails"
  206. echo "x - extracting utilities.d/checkpass.d/checkpass.c (Text)"
  207. sed 's/^X//' << 'SHAR_EOF' > utilities.d/checkpass.d/checkpass.c &&
  208. X/*
  209. X *    checkpass.c:  encrypt entered passwd and comparing it against 
  210. X *         the /etc/passwd.
  211. X *    
  212. X *    Inputs:     argv[1] - login
  213. X *         argv[2] - passwd
  214. X *    
  215. X *    Return Values: 4 failure
  216. X *        0 - matched passwd found
  217. X */
  218. X
  219. X#include <pwd.h>
  220. X
  221. Xmain(argc, argv)
  222. Xint argc;
  223. Xchar *argv[];
  224. X{
  225. X    struct     passwd *getpwnam(), *pwentry;
  226. X    char     salt[2], 
  227. X        *crypt(),
  228. X        *encryptedpw;
  229. X
  230. X
  231. X    /* check number of arguments */
  232. X    if(argc != 3) {
  233. X        printf("Usage:  checkpass login passwd\n");
  234. X        exit(4);
  235. X    }
  236. X    
  237. X    /* get passwd for login from /etc/passwd file */
  238. X    if((pwentry=getpwnam(argv[1])) == (struct passwd *) 0) 
  239. X        exit(4);
  240. X
  241. X    salt[0] = *(pwentry->pw_passwd);
  242. X    salt[1] = *(pwentry->pw_passwd +1);
  243. X
  244. X    /* encrypt entered passwd */
  245. X    encryptedpw = crypt(argv[2], salt);
  246. X
  247. X    /* compare passwd in /etc/passwd with the encrypted passwd */
  248. X    if(strcmp(encryptedpw, pwentry->pw_passwd) )
  249. X        exit(4);
  250. X    exit(0);
  251. X}
  252. SHAR_EOF
  253. chmod 0644 utilities.d/checkpass.d/checkpass.c || echo "restore of utilities.d/checkpass.d/checkpass.c fails"
  254. echo "x - extracting utilities.d/lock.d/junk (Text)"
  255. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/junk &&
  256. X                lockfd = open(diallock, O_WRONLY|O_CREAT|O_EXCL,
  257. X                        0444) ;
  258. X                if (lockfd < 0) 
  259. X                {
  260. X                    if (debug & D_DEVICE) 
  261. X                    {
  262. X                        dialmsg("%s: %s\n", errstring(),
  263. X                            diallock) ;
  264. X                    }
  265. X                    continue ;
  266. X                }
  267. X                else
  268. X                {
  269. X                    /* pjc */
  270. X                    /* write process id to lock file */
  271. X                    sprintf (tmpstr, "%d", getpid());
  272. X                    sprintf (spid, "%10.10s", tmpstr);
  273. X                    write (lockfd, spid, strlen(spid));
  274. X                }
  275. X
  276. X                (void) close(lockfd) ;
  277. SHAR_EOF
  278. chmod 0644 utilities.d/lock.d/junk || echo "restore of utilities.d/lock.d/junk fails"
  279. echo "x - extracting utilities.d/lock.d/lock.1 (Text)"
  280. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.1 &&
  281. X. \ %W% DeltaDate %G% ExtrDate %H% 
  282. X.po 6
  283. X.TH LOCK 1 "" "Menu Utility"
  284. X
  285. X.SH \s9NAME\s0
  286. Xlock \- does a lock on a file
  287. X
  288. X.SH SYNOPSIS
  289. X.B lock  filename
  290. X
  291. X.SH DESCRIPTION
  292. X.B LOCK
  293. Xis designed to be a utility program to be used in conjunction with the menu(1)
  294. Xprogram.  Lock does a lock on a file.  When used with the menu(1)
  295. Xprogram the filename should probably be the program name.  A "LCK.." is 
  296. Xprepended
  297. Xto the filename to indicate that this is a lock file.  This is in keeping
  298. Xwith uucp lock file syntax.  If the \fILCK..filename\fP
  299. Xdoes not exist it will be created.  The lock file is created/looked for in
  300. Xgetenv("LOCKDIR").
  301. X
  302. X
  303. X.SH EXAMPLE
  304. X.nf
  305. Xlock program_name
  306. Xif [ $? -eq 0 ]
  307. X   then    program_name
  308. X        unlock program_name
  309. Xfi
  310. X.fi
  311. X
  312. X.SH FILES
  313. X\fI$LOCKDIR/LCK..filename\fP    the lock file
  314. X
  315. X.SH AUTHOR
  316. XPaul J. Condie       10/88
  317. X.br
  318. X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
  319. X
  320. X.SH SEE ALSO
  321. Xmenu(1), unlock(1).
  322. X
  323. X.SH DIAGNOSTICS
  324. XLock returns a zero if the lock was successfully created,
  325. X99 no file specified on command line,
  326. Xotherwise, it returns \fIerrno\fP.  See errno description in manual.
  327. SHAR_EOF
  328. chmod 0644 utilities.d/lock.d/lock.1 || echo "restore of utilities.d/lock.d/lock.1 fails"
  329. echo "x - extracting utilities.d/lock.d/lock.c (Text)"
  330. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/lock.c &&
  331. X/*
  332. X** Returns:
  333. X**    0    lock successful
  334. X**    99    no file on command line
  335. X**    otherwise    errno
  336. X*/
  337. X
  338. X#include    <stdio.h>
  339. X#include    <fcntl.h>
  340. X#include    <errno.h>
  341. X
  342. Xmain (argc, argv)
  343. X    int    argc;
  344. X    char    *argv[];
  345. X{
  346. X    char        *getenv();
  347. X    int        fd;            /* file descriptor */
  348. X    char        file[40];
  349. X
  350. X    if (argc != 2)
  351. X        exit (1);
  352. X
  353. X    if (getenv("LOCKDIR") != (char *)NULL)
  354. X        sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
  355. X    else
  356. X        sprintf (file, "LCK..%s", argv[1]);
  357. X
  358. X    if ((fd = open (file, O_WRONLY|O_CREAT|O_EXCL, 0444)) < 0)
  359. X    {
  360. X        /* check to see if process is still running */
  361. X        exit (errno);
  362. X    }
  363. X
  364. X    /* write process id to lock file */
  365. X    /*
  366. X    sprintf (tmpstr, "%d", getpid());
  367. X    sprintf (spid, "%10.10s", tmpstr);
  368. X    write (lockfd, spid, strlen(spid));
  369. X    */
  370. X
  371. X    close (fd);
  372. X    exit (0);
  373. X}
  374. X/* Paul J. Condie  8-89 */
  375. SHAR_EOF
  376. chmod 0644 utilities.d/lock.d/lock.c || echo "restore of utilities.d/lock.d/lock.c fails"
  377. echo "x - extracting utilities.d/lock.d/unlock.1 (Text)"
  378. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.1 &&
  379. X. \ %W% DeltaDate %G% ExtrDate %H% 
  380. X.po 6
  381. X.TH UNLOCK 1 "" "Menu Utility"
  382. X
  383. X.SH \s9NAME\s0
  384. Xunlock \- unlocks a semaphore lock on a file
  385. X
  386. X.SH SYNOPSIS
  387. Xlock  filename
  388. X
  389. X.SH DESCRIPTION
  390. X.B UNLOCK
  391. Xis designed to be a utility program to be used in conjunction with the menu(1)
  392. Xprogram.  Unlock does a semaphore unlock on a file then unlinks the filename.  
  393. XThe filename should have been previously locked using lock(1).
  394. XA "LCK.." is prepended
  395. Xto the filename to indicate that this is a lock file.
  396. XThe lock file is looked for in getenv("LOCKDIR").
  397. X
  398. X.PP
  399. XThe important thing for unlock is to make sure it runs regardless of how
  400. Xthe program exits.  Examples of how insure that this happens is illustrated
  401. Xbelow:
  402. X.br
  403. Xtrap 'unlock pgm; trap 2' 2; (pgm; unlock pgm); trap 2
  404. X.br
  405. X(nohup pgm; nohup unlock)&
  406. X
  407. X.SH FILES
  408. X\fI$LOCKDIR/LCK..filename\fP    the lock file
  409. X
  410. X.SH AUTHOR
  411. XPaul J. Condie          10/88
  412. X.br
  413. X{att,bellcore,sun,ames,pyramid}!pacbell!pcbox!pjc
  414. X
  415. X.SH SEE ALSO
  416. Xmenu(1), lock(1).
  417. X
  418. X.SH DIAGNOSTICS
  419. XUnlock returns exit code zero if the unlock was successful, otherwise, it
  420. Xreturns a non-zero.
  421. SHAR_EOF
  422. chmod 0644 utilities.d/lock.d/unlock.1 || echo "restore of utilities.d/lock.d/unlock.1 fails"
  423. echo "x - extracting utilities.d/lock.d/unlock.c (Text)"
  424. sed 's/^X//' << 'SHAR_EOF' > utilities.d/lock.d/unlock.c &&
  425. X/*
  426. X** Name:    unlock(1)
  427. X** Returns:
  428. X**    0    unlock successful
  429. X**    99    no file on command line
  430. X**    otherwise    errno
  431. X*/
  432. X
  433. X#include    <stdio.h>
  434. X#include    <errno.h>
  435. X
  436. Xmain (argc, argv)
  437. X    int    argc;
  438. X    char    *argv[];
  439. X{
  440. X    char        *getenv();
  441. X    char        file[40];
  442. X
  443. X    if (argc != 2)
  444. X        exit (99);
  445. X
  446. X    if (getenv("LOCKDIR") != (char *)NULL)
  447. X        sprintf (file, "%s/LCK..%s", getenv("LOCKDIR"), argv[1]);
  448. X    else
  449. X        sprintf (file, "LCK..%s", argv[1]);
  450. X
  451. X    if (unlink (file) < 0)
  452. X        exit (errno);
  453. X
  454. X    exit (0);
  455. X}
  456. X/* Paul J. Condie  8-89 */
  457. SHAR_EOF
  458. chmod 0644 utilities.d/lock.d/unlock.c || echo "restore of utilities.d/lock.d/unlock.c fails"
  459. echo "x - extracting utilities.d/m.d/adduser (Text)"
  460. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/adduser &&
  461. X#! /bin/ksh
  462. X# %W%   DeltaDate %G%   ExtrDate %H%
  463. X
  464. X###  adduser
  465. X###    Add a new user login to the system.
  466. X###    This script is designed to be run from the menu(1) program.
  467. X###    Menu script file is sadmin.m
  468. X###    This script needs to be run with a set uid to root program.  You
  469. X###    pick the one you want to use.
  470. X###
  471. X###  Arguments:
  472. X###    $1 = login ID
  473. X###    $2 = encrypted password
  474. X###    $3 = numerical user ID
  475. X###    $4 = numerical group ID
  476. X###    $5 = Text (Users Read Name)
  477. X###    $6 = directory to create users home directory in
  478. X###    $7 = program to use as Shell
  479. X###    $8 = default .profile for user
  480. X###    $9 = default printer
  481. X###
  482. X###  Note:
  483. X###      In order to get chgrp to work you need to chown to $LOGNAME first.
  484. X###      The setuid does not work for chgrp ????
  485. X###
  486. X
  487. X###    Validate argument count
  488. Xif [ $# -ne 9 ]
  489. X   then    exit 1
  490. Xfi
  491. X
  492. XLOGNAME=$1
  493. XPASSWD=$2
  494. XUID=$3
  495. XGID=$4
  496. XNAME=$5
  497. XHOMEDIR=$6/$LOGNAME
  498. XLOGSHELL=$7
  499. XDPROFILE=$8
  500. XPRINTER=$9
  501. X
  502. XPWDFILE=/etc/passwd
  503. XGROUPFILE=/etc/group
  504. XECHO=/bin/echo
  505. X
  506. X#stty sane erase '^h' echoe isig
  507. X
  508. Xtrap "$ECHO 'Adduser aborted.\nPress [ Return ] to continue...\c'; read reply; exit" 2 3 15
  509. X
  510. X$ECHO "\n"
  511. X
  512. Xif grep '^'$LOGNAME: $PWDFILE > /dev/null 2>&1
  513. X   then $ECHO "Logname $LOGNAME is already in use."
  514. X    $ECHO "Please try another."
  515. X    $ECHO "Press [ Return ] to continue...\c"
  516. X    read reply
  517. X    exit 0
  518. Xfi
  519. X
  520. XGROUP=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$GID $GROUPFILE`
  521. X
  522. X
  523. X
  524. X$ECHO "Logname:         $LOGNAME"
  525. X$ECHO "Default Passwd:  $PASSWD"
  526. X$ECHO "Real name:       $NAME"
  527. X$ECHO "User id:         $UID"
  528. X$ECHO "Group:           $GROUP"
  529. X$ECHO "Group number:    $GID"
  530. X$ECHO "Home directory:  $HOMEDIR"
  531. X$ECHO "Default Printer: $PRINTER"
  532. X    
  533. X#$ECHO "\nDatabase Permissions:"
  534. X#$ECHO "\tService Rep: $rep"
  535. X    
  536. X$ECHO "\nOkay to add (y/n)? \c"
  537. Xread reply
  538. X
  539. X$ECHO "\n"
  540. Xif [ "$reply" = "y" ]
  541. X   then trap "$ECHO 'Too late to abort adduser!'" 2 3 15
  542. X    $ECHO "Adding entry to $PWDFILE"
  543. X    ###  Next line is for standard SYSV
  544. X    $ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> $PWDFILE
  545. X    if [ $? -ne 0 ]
  546. X       then    $ECHO "Unable to add entry to $PWDFILE"
  547. X        $ECHO "Aborting add new user."
  548. X        $ECHO "Press [ Return ] to continue...\c"
  549. X        read reply
  550. X        exit 0
  551. X    fi
  552. X    ###  Next Line is for the SUN
  553. X#    $ECHO "/^+/i\\" > /tmp/adduser.script
  554. X#    $ECHO "$LOGNAME:$PASSWD:$UID:$GID:$NAME:$HOMEDIR:$LOGSHELL" >> /tmp/adduser.script
  555. X#    sed -f /tmp/adduser.script $PWDFILE > /tmp/newpasswd
  556. X#    cp /tmp/newpasswd $PWDFILE
  557. X#    rm -f /tmp/adduser.script
  558. X#    rm -f /tmp/newpasswd
  559. X   else
  560. X    $ECHO "$LOGNAME not added."
  561. X    exit
  562. Xfi
  563. X
  564. X
  565. X###    Make home directory
  566. XMAKEDIR=yes
  567. Xif [ -s $HOMEDIR ]
  568. X   then $ECHO "Warning: $HOMEDIR exists. Okay to use it (y/n)? \c"
  569. X    read reply
  570. X    if [ "$reply" = "y" ]
  571. X       then MAKEDIR=no
  572. X    fi
  573. Xfi
  574. Xif [ "$MAKEDIR" = "yes" ]
  575. X   then    mkdir $HOMEDIR
  576. X    if [ $? -ne 0 ]
  577. X       then $ECHO "Could not create $HOMEDIR."
  578. X        $ECHO "Aborting adduser."
  579. X        $ECHO "Removing entry in $PWDFILE"
  580. X        sed -e "/^$LOGNAME:/D" $PWDFILE > /tmp/passwd
  581. X          if [ $? -ne 0 ]
  582. X                   then    $ECHO "Unable to delete entry from password file."
  583. X              exit
  584. X           else chmod 744 $PWDFILE
  585. X              cp /tmp/passwd $PWDFILE
  586. X            rm -f /tmp/passwd
  587. X        fi
  588. X        $ECHO "Press [ Return ] to continue...\c"
  589. X        read reply
  590. X        exit
  591. X    fi
  592. Xfi
  593. X# Correct mode of HOMEDIR
  594. Xchown $LOGNAME $HOMEDIR
  595. X/bin/chgrp $GROUP $HOMEDIR
  596. X/bin/chmod 754 $HOMEDIR
  597. Xchown $LOGNAME $HOMEDIR
  598. X
  599. X
  600. X
  601. X###
  602. X###  If there is no .profile in HOMEDIR
  603. X###     then  Copy default .profile to HOMEDIR
  604. X###
  605. X
  606. Xif [ -f $HOMEDIR/.profile ]
  607. X   then    $ECHO "A .profile already exists in $HOMEDIR."
  608. X   else
  609. X    if [ -f $DPROFILE ]
  610. X       then    $ECHO "Placing a .profile in $HOMEDIR"
  611. X        ###  Next line is used to set default printer LPDEST
  612. X        if [ "$PRINTER" != "NULL" ]
  613. X            # fix this
  614. X           then    sed "s/^LPDEST=local/LPDEST=$PRINTER/" $DPROFILE > $HOMEDIR/.profile
  615. X           else    cp $DPROFILE $HOMEDIR/.profile
  616. X        fi
  617. X        chown $LOGNAME $HOMEDIR/.profile
  618. X        /bin/chgrp $GROUP $HOMEDIR/.profile
  619. X        /bin/chmod 754 $HOMEDIR/.profile
  620. X        chown $LOGNAME $HOMEDIR/.profile
  621. X        $ECHO "Default .profile added for $LOGNAME."
  622. X       else    $ECHO "The default .profile ($DPROFILE) was not found."
  623. X    fi
  624. Xfi
  625. X
  626. X
  627. X
  628. X###
  629. X### Create bin in HOMEDIR
  630. X###
  631. X
  632. Xif [ -d $HOMEDIR/bin ]
  633. X   then    $ECHO "A bin directory already exists."
  634. X   else 
  635. X    $ECHO "Making directory $HOMEDIR/bin"
  636. X    mkdir $HOMEDIR/bin
  637. X    chown $LOGNAME $HOMEDIR/bin
  638. X    /bin/chgrp $GROUP $HOMEDIR/bin
  639. X    /bin/chmod 755 $HOMEDIR/bin
  640. X    chown $LOGNAME $HOMEDIR/bin
  641. X    $ECHO "Bin directory added for $LOGNAME."
  642. Xfi
  643. X
  644. X
  645. X
  646. X###
  647. X###  Grant Database Permissions
  648. X###
  649. X
  650. X#DBPATH=/prod/date.d; export DBPATH
  651. X#/usr/informix/bin/isql - - <<END
  652. X#database dateme;
  653. X#grant select on techs to $LOGNAME;
  654. X#grant insert on techs to $LOGNAME;
  655. X#grant update on techs to $LOGNAME;
  656. X#grant delete on techs to $LOGNAME;
  657. X#grant connect to $LOGNAME;
  658. X#END
  659. X
  660. X$ECHO "$LOGNAME added."
  661. X$ECHO "Press [ Return ] to continue...\c"
  662. Xread reply
  663. SHAR_EOF
  664. chmod 6755 utilities.d/m.d/adduser || echo "restore of utilities.d/m.d/adduser fails"
  665. echo "x - extracting utilities.d/m.d/deluser (Text)"
  666. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/deluser &&
  667. X#! /usr/lbin/ksh
  668. X# @(#)deluser.sh    1.1   DeltaDate 12/31/87   ExtrDate 12/31/87
  669. X###
  670. X###  You need to chown all files in the home directory you want to delete
  671. X###  to $LOGNAME before you can remove the home directory.
  672. X###
  673. X
  674. XLOGNAME=$1
  675. XECHO=echo
  676. XUIDBASE=2000
  677. X
  678. Xtrap "$ECHO 'Deluser aborted.'; exit 1" 2 3 15
  679. X
  680. Xtput clear
  681. X#stty sane erase '^h' echoe isig
  682. X
  683. X
  684. X
  685. Xcase $LOGNAME in
  686. X   dateme|pjc|root|nobody|daemon|sys|bin|uucp|nuucp|news|informix|telic|cadsys)
  687. X    $ECHO "Sorry, You don't have permission to delete that one."
  688. X    continue
  689. X    ;;
  690. Xesac
  691. X
  692. X###
  693. X### Check for validity - listed in password file.
  694. X###
  695. Xif grep '^'$LOGNAME: /etc/passwd > /dev/null 2>&1
  696. X   then
  697. X    ### Extract data for this user and display.
  698. X           setthem=`sed -n "s/^$LOGNAME:\(.*\):\(.*\):\(.*\):\(.*\):\(.*\):\(.*\)/passwd=\1;uid=\2;gid=\3;realname='\4';homedir=\5;shell=\6/p" /etc/passwd`
  699. X           eval $setthem
  700. X           group=`awk 'BEGIN{FS=":"} {if($3 == g) print $1}' g=$gid /etc/group`
  701. X
  702. X    ###
  703. X    ###  uid must be >= UIDBASE
  704. X    ###
  705. X    if [ "$uid" -lt $UIDBASE ]
  706. X          then    $ECHO "Sorry, You don't have permission to delete that one."
  707. X           continue
  708. X    fi
  709. X
  710. X    $ECHO "\nLogname:           $LOGNAME"
  711. X    $ECHO "Real name:         $realname"
  712. X           $ECHO "User id:           $uid"
  713. X           $ECHO "Group:             $group"
  714. X           $ECHO "Group number:      $gid"
  715. X           $ECHO "Home directory:    $homedir"
  716. X    $ECHO "\n\n"
  717. X           break
  718. X   else
  719. X    $ECHO "$LOGNAME is not listed in the password file. Try again."
  720. X    read reply
  721. Xfi
  722. X
  723. X
  724. X
  725. Xwhile true
  726. Xdo
  727. X    $ECHO "Do you wish to delete this user from the system  (y/n):  \c"
  728. X       read reply
  729. X
  730. X       case $reply in
  731. X       n|N)    break ;;
  732. X            y|Y)
  733. X        if [ "$homedir" != "/prod/date.d/cadsys.d" ]
  734. X              then
  735. X            ###  Not a Service Rep
  736. X            ###  Service Reps never had permission here
  737. X            DBPATH=/prod/date.d
  738. X            export DBPATH
  739. X/usr/informix/bin/isql - - <<END
  740. Xdatabase dateme;
  741. Xrevoke all on techs from $LOGNAME;
  742. Xrevoke all on turfs from $LOGNAME;
  743. Xrevoke all on techtime from $LOGNAME;
  744. Xrevoke all on factors from $LOGNAME;
  745. Xrevoke all on turfs from $LOGNAME;
  746. XEND
  747. X        fi
  748. X        DBPATH=/prod/date.d/cadsys.d
  749. X        export DBPATH
  750. X/usr/informix/bin/isql - - <<END
  751. Xdatabase cadsys;
  752. Xrevoke all on appt from $LOGNAME;
  753. Xrevoke all on grid from $LOGNAME;
  754. Xrevoke all on syserror from $LOGNAME;
  755. Xrevoke all on appt_time from $LOGNAME;
  756. Xrevoke all on sorder from $LOGNAME;
  757. Xrevoke all on sysdeflt from $LOGNAME;
  758. Xrevoke connect from $LOGNAME;
  759. XEND
  760. X            sed -e "/^$LOGNAME:/D" /etc/passwd > /tmp/passwd
  761. X              if [ $? -ne 0 ]
  762. X                       then    $ECHO "Unable to delete from password file."
  763. X                  exit
  764. X              fi
  765. X              chmod 744 /etc/passwd
  766. X              cp /tmp/passwd /etc/passwd
  767. X
  768. X            ###
  769. X            ###  CUSTOMIZE
  770. X            ###  if this is a service rep we don't want to remove homedir
  771. X            ###
  772. X            if [ "$homedir" != "/prod/date.d/cadsys.d" ]
  773. X                  then
  774. X                  find $homedir -exec /etc/chown $LOGNAME {} \;
  775. X                  rm -r $homedir
  776. X            fi
  777. X              $ECHO "\nUser removed from system."
  778. X              break;
  779. X              ;;
  780. X                   *)    $ECHO "Invalid reply."
  781. X                  continue ;;
  782. X           esac
  783. SHAR_EOF
  784. chmod 0777 utilities.d/m.d/deluser || echo "restore of utilities.d/m.d/deluser fails"
  785. echo "x - extracting utilities.d/m.d/junk.m (Text)"
  786. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/junk.m &&
  787. X###
  788. X###       .POPMENU
  789. X###    Printer Selection Menu
  790. X###
  791. X
  792. X.TITLE
  793. XPrinter Menu
  794. X
  795. X.TEXT 23 0
  796. XSelect A Printer.
  797. X
  798. X.SETENV BELL LPDEST=srv4e_700ps  Printer (srv4e_700ps) selected.
  799. Xsrv4e_700ps
  800. X
  801. X.SETENV BELL LPDEST=srv4e_700dm  Printer (srv4e_700dm) selected.
  802. Xsrv4e_700dm
  803. X
  804. X.SETENV BELL LPDEST=srv4e_811a  Printer (srv4e_811a) selected.
  805. Xsrv4e_811a
  806. X
  807. X.SETENV BELL LPDEST=srv4e_760c  Printer (srv4e_760c) selected.
  808. Xsrv4e_760c
  809. SHAR_EOF
  810. chmod 0644 utilities.d/m.d/junk.m || echo "restore of utilities.d/m.d/junk.m fails"
  811. echo "x - extracting utilities.d/m.d/passwdsrn.m (Text)"
  812. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/passwdsrn.m &&
  813. X.DEFINE_SCREEN passwdsrn
  814. X    window_title = "Password Screen"
  815. X    window_rows = 5
  816. X    window_cols = 26
  817. X    exit_last_field
  818. X
  819. X    field_name = $PASSWD
  820. X    field_label = Password
  821. X    field_row = 2
  822. X    field_col = 12
  823. X    field_length = 8
  824. X    field_edits = PROTECT
  825. X    field_prompt = "Enter password."
  826. XENDSCREEN
  827. SHAR_EOF
  828. chmod 0644 utilities.d/m.d/passwdsrn.m || echo "restore of utilities.d/m.d/passwdsrn.m fails"
  829. echo "x - extracting utilities.d/m.d/printer2.sh (Text)"
  830. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printer2.sh &&
  831. XFrom uucp Tue Nov 28 16:07 PST 1989
  832. X>From uucp Tue Nov 28 15:56 PST 1989 remote from pacbell
  833. X>From srv.PacBell.COM!pjcondie  Tue Nov 28 14:35:31 1989 remote from mother
  834. XReceived: from pbuddy.srv.PacBell.COM (pbuddy-gw) by srv.PacBell.COM (4.0/SMI-4.0)
  835. X    id AA17298; Tue, 28 Nov 89 14:35:31 PST
  836. XReceived: from lacm2.srv.PacBell.COM by pbuddy.srv.PacBell.COM (4.0/SMI-4.0)
  837. X    id AA02251; Tue, 28 Nov 89 14:37:38 PST
  838. XDate: Tue, 28 Nov 89 14:37:38 PST
  839. XFrom: pjcondie@srv.PacBell.COM (Paul J. Condie)
  840. XMessage-Id: <8911282237.AA02251@pbuddy.srv.PacBell.COM>
  841. XTo: pcbox!pjc
  842. XSubject: Re:  printers.sh
  843. XStatus: R
  844. X
  845. X
  846. X----- Begin Included Message -----
  847. X
  848. X>From pbear2!ssl Tue Nov 28 14:31:29 1989
  849. XSubject: printers.sh
  850. XTo: pjc (Paul J. Condie(baer))
  851. XX-Mailer: ELM [version 2.2 PL0]
  852. X
  853. X###
  854. X###       Build lpoptions.m from lpoptions.menu
  855. X###    Printer Selection Menu
  856. X###
  857. X
  858. XDUMMY="zzzzzzzz"            # end-of-list marker
  859. X
  860. Xsetprinters() {                # make a function
  861. Xlpstat -a | grep accept | cut -d' ' -f1 | ( sort ; echo $DUMMY ) |
  862. Xfor i in `cat`
  863. Xdo
  864. X    if [ $i = $DUMMY ]        # hit last one?
  865. X    then
  866. X        echo $PRINTERS
  867. X    fi
  868. X    PRINTERS=$PRINTERS","$i        # concat
  869. Xdone ; }
  870. X
  871. XPRINTERS=$LPDEST`setprinters`        # now build it
  872. Xsed -e s/\$PRINTERS/$PRINTERS/ $BVPS/misc/lpoptions.menu > lpoptions.m
  873. X
  874. X
  875. X----- End Included Message -----
  876. X
  877. X
  878. X
  879. SHAR_EOF
  880. chmod 0644 utilities.d/m.d/printer2.sh || echo "restore of utilities.d/m.d/printer2.sh fails"
  881. echo "x - extracting utilities.d/m.d/printers.m (Text)"
  882. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.m &&
  883. X###
  884. X###       .POPMENU
  885. X###    Printer Selection Menu
  886. X###
  887. X
  888. X.TITLE
  889. XPrinter Menu
  890. X
  891. X.TEXT 23 0
  892. XSelect A Printer.
  893. X
  894. X.SETENV BELL LPDEST=srv4e_700ps  Printer (srv4e_700ps) selected.
  895. Xsrv4e_700ps
  896. X
  897. X.SETENV BELL LPDEST=srv4e_700dm  Printer (srv4e_700dm) selected.
  898. Xsrv4e_700dm
  899. X
  900. X.SETENV BELL LPDEST=srv4e_811a  Printer (srv4e_811a) selected.
  901. Xsrv4e_811a
  902. X
  903. X.SETENV BELL LPDEST=srv4e_760c  Printer (srv4e_760c) selected.
  904. Xsrv4e_760c
  905. X
  906. X.POPMENU printers.m
  907. XPOP
  908. SHAR_EOF
  909. chmod 0644 utilities.d/m.d/printers.m || echo "restore of utilities.d/m.d/printers.m fails"
  910. echo "x - extracting utilities.d/m.d/printers.sh (Text)"
  911. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/printers.sh &&
  912. X###
  913. X###       Build a .POPMENU
  914. X###    Printer Selection Menu
  915. X###
  916. X
  917. Xecho ".TITLE" > printers.m
  918. Xecho "Printer Menu" >> printers.m
  919. X
  920. Xecho ".TEXT 23 0" >> printers.m
  921. Xecho "Select A Printer." >> printers.m
  922. X
  923. Xlpstat -p | awk '{ print $2 }' |
  924. Xfor i in `cat`
  925. Xdo
  926. X    echo ".SETENV BELL LPDEST=$i  Printer ($i) selected." >> printers.m
  927. X    echo "$i" >> printers.m
  928. Xdone
  929. SHAR_EOF
  930. chmod 0755 utilities.d/m.d/printers.sh || echo "restore of utilities.d/m.d/printers.sh fails"
  931. echo "x - extracting utilities.d/m.d/reportsrn.m (Text)"
  932. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/reportsrn.m &&
  933. X###    Screen to prompt user for report options.
  934. X###    Fields:
  935. X###        $FDATE    - From date.
  936. X###        $TDATE    - To date.
  937. X###        $PRIORITY - Priority
  938. X###        $LPDEST   - Printer Destination
  939. X###        $TARGET   - Print to terminal or printer.
  940. X
  941. X.DEFINE_SCREEN reportsrn
  942. X    window_title = "REPORT OPTIONS"
  943. X    window_rows = 10
  944. X    window_cols = 28
  945. X
  946. X    ###    $FDATE - From date.
  947. X
  948. X    field_name = $FDATE
  949. X    field_label = From
  950. X    field_row = 2
  951. X    field_col = 13
  952. X    field_length = 6
  953. X    field_type = DATE
  954. X    field_mask = "MM/DD/YY"
  955. X    field_mustenter
  956. X    field_prompt = "Enter starting date."
  957. X
  958. X    ###    $TDATE - To date.
  959. X
  960. X    field_name = $TDATE
  961. X    field_label = To
  962. X    field_row = 3
  963. X    field_col = 13
  964. X    field_length = 6
  965. X    field_type = DATE
  966. X    field_mask = "MM/DD/YY"
  967. X    field_mustenter
  968. X    field_prompt = "Enter starting date."
  969. X
  970. X    field_name = $PRIORITY
  971. X    field_label = Priority
  972. X    field_row = 5
  973. X    field_col = 13
  974. X    field_length = 6
  975. X    field_type = MENU
  976. X    field_range = "LOW,MEDIUM,HIGH"
  977. X    field_prompt = "Select priority level."
  978. X
  979. X    field_name = $LPDEST
  980. X    field_label = Printer
  981. X    field_row = 6
  982. X    field_col = 13
  983. X    field_length = 11
  984. X    field_type = SET
  985. X    field_range = "srv4e_700ps,srv4e_811a"
  986. X    field_prompt = "Select printer."
  987. X
  988. X    field_name = $TARGET
  989. X    field_label = "Print To"
  990. X    field_row = 7
  991. X    field_col = 13
  992. X    field_length = 8
  993. X    field_type = SET
  994. X    field_range = "TERMINAL,PRINTER,BOTH"
  995. X    field_prompt = "Print to terminal or printer."
  996. XENDSCREEN
  997. SHAR_EOF
  998. chmod 0644 utilities.d/m.d/reportsrn.m || echo "restore of utilities.d/m.d/reportsrn.m fails"
  999. echo "x - extracting utilities.d/m.d/sadmin.m (Text)"
  1000. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sadmin.m &&
  1001. X###    Add new user stuff
  1002. X###    GROUP - default group for new users
  1003. X###    HOMEDIRS - where to make home directories for new users
  1004. X
  1005. XGROUP=users
  1006. XHOMEDIRS=/tmp
  1007. XPRINTER=NULL
  1008. XDPROFILE=/tmp/profile.lacm
  1009. XLOGSHELL=/bin/sh
  1010. XUIDBASE=2000
  1011. XPASSWDAGE=",O/"
  1012. X
  1013. XPWDFILE=/etc/passwd
  1014. XGROUPFILE=/etc/group
  1015. X
  1016. X.TITLE
  1017. X$LOGNAME ...System Administration...$DATE
  1018. X.TITLE
  1019. X...Menu...$TIME
  1020. X.LINE
  1021. X
  1022. X.SYSTEM GETINPUT adduser \
  1023. X    suid_exec adduser $logname $PASSWDAGE $UID $GID "$realname" $HOMEDIRS $LOGSHELL $DPROFILE $PRINTER
  1024. XAdd New User To System.
  1025. X
  1026. X.SYSTEM GETINPUT deluser \
  1027. X    suid_exec deluser $logname
  1028. XRemove User From System.
  1029. X
  1030. X
  1031. X
  1032. X.DEFINE_SCREEN adduser
  1033. X    window_rows = 11
  1034. X    window_cols = 47
  1035. X    window_title = "Add New User Screen"
  1036. X
  1037. X    field_name = $logname
  1038. X    field_label = "Login Name"
  1039. X    field_row = 2, field_col = 19
  1040. X    field_length = 8
  1041. X    field_type = ALPHANUM, field_mask = "A       "
  1042. X    field_mustenter
  1043. X
  1044. X    field_name = $realname
  1045. X    field_label = "Real Name"
  1046. X    field_row = 3, field_col = 19
  1047. X    field_length = 25
  1048. X    field_type = ALPHANUM
  1049. X    field_mustenter
  1050. X
  1051. X    field_name = $UID
  1052. X    field_label = "User ID"
  1053. X    field_row = 4, field_col = 19
  1054. X    field_length = 5
  1055. X    field_noinput
  1056. X
  1057. X    field_name = $GROUP
  1058. X    field_label = "Group"
  1059. X    field_row = 5, field_col = 19
  1060. X    field_length = 10
  1061. X    field_noinput
  1062. X
  1063. X    field_name = $GID
  1064. X    field_label = "Group ID"
  1065. X    field_row = 6, field_col = 19
  1066. X    field_length = 5
  1067. X    field_noinput
  1068. X
  1069. X    field_name = $HOMEDIRS
  1070. X    field_label = "Home Directory"
  1071. X    field_row = 7, field_col = 19
  1072. X    field_length = 25
  1073. X    field_noinput
  1074. X
  1075. X    field_name = $PRINTER
  1076. X    field_label = "Default Printer"
  1077. X    field_row = 8, field_col = 19
  1078. X    field_length = 20
  1079. X    field_type = ALPHANUM
  1080. X
  1081. X    field_defaults = "UID=`awk 'BEGIN{ FS=\":\" } { x[$3] = 1 } END { i = 2000; while (x[i] == 1) { ++i }; print i }' $PWDFILE`
  1082. X        GID=`awk 'BEGIN{FS=\":\"} {if($1 == g) print $3}' g=$GROUP $GROUPFILE`
  1083. X        echo NULL NULL $UID $GROUP $GID $HOMEDIRS $PRINTER"
  1084. XENDSCREEN
  1085. X
  1086. X
  1087. X.DEFINE_SCREEN deluser
  1088. X    window_rows = 5
  1089. X    window_cols = 25
  1090. X    window_title = "Delete User Screen"
  1091. X
  1092. X    field_name = $logname
  1093. X    field_label = "Login Name"
  1094. X    field_row = 2, field_col = 14
  1095. X    field_length = 8
  1096. X    field_type = ALPHANUM, field_mask = "A       "
  1097. X    field_mustenter
  1098. XENDSCREEN
  1099. SHAR_EOF
  1100. chmod 0644 utilities.d/m.d/sadmin.m || echo "restore of utilities.d/m.d/sadmin.m fails"
  1101. echo "x - extracting utilities.d/m.d/sample.m (Text)"
  1102. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/sample.m &&
  1103. X###     Sample.Menu
  1104. X###    A sample menu script file.
  1105. X
  1106. X.TITLE
  1107. X$LOGNAME ...SAMPLE...$DATE
  1108. X.TITLE
  1109. X$MAIL...MENU...$TIME
  1110. X.LINE
  1111. X
  1112. X.GNAME sample sample.m
  1113. X
  1114. X.INCLUDE reportsrn.m
  1115. X.INCLUDE passwdsrn.m
  1116. X
  1117. X.TEXT 22 61
  1118. X"?" for help :
  1119. X
  1120. X.SYSTEM echo "Press [ ^d ] to return to menu ..."; ksh
  1121. XUnix System.
  1122. X
  1123. X.SYSTEM who; \
  1124. X    echo "Press [ Return ] to continue ..."; \
  1125. X    read reply
  1126. XShow Who Is On The System.
  1127. X
  1128. X.SYSTEM more sample.m; echo "Press [ Return ] to continue ...\c"; read reply
  1129. XDisplay sample.m script file.
  1130. X
  1131. X.POPMENU printers.m
  1132. XSelect Printer Menu ($LPDEST).
  1133. X
  1134. X.GETINPUT reportsrn
  1135. XA Sample GETINPUT Screen.
  1136. X
  1137. X.GETINPUT passwdsrn
  1138. XA Sample Password Screen.
  1139. X
  1140. X.SPACE
  1141. X
  1142. X.EXIT
  1143. XExit Menu Program.
  1144. SHAR_EOF
  1145. chmod 0644 utilities.d/m.d/sample.m || echo "restore of utilities.d/m.d/sample.m fails"
  1146. echo "x - extracting utilities.d/m.d/suid_exec.c (Text)"
  1147. sed 's/^X//' << 'SHAR_EOF' > utilities.d/m.d/suid_exec.c &&
  1148. X#include    <stdio.h>
  1149. X#include    <fcntl.h>
  1150. X#include    <sys/stat.h>
  1151. X
  1152. X#define    ROOT    0
  1153. X
  1154. Xmain (argc, argv)
  1155. X    int    argc;
  1156. X    char    *argv[];
  1157. X{
  1158. X    int        fd;
  1159. X    struct stat    sbuf;
  1160. X    char        command[200];
  1161. X    int        i;
  1162. X
  1163. X
  1164. X    if (argc < 2)
  1165. X        exit (1);
  1166. X
  1167. X    if ((fd = open (argv[1], O_RDONLY)) <= 0)
  1168. X        exit (1);                /* can't open */
  1169. X
  1170. X    /* Get file status information */
  1171. X       if (fstat (fd, &sbuf) < 0)
  1172. X        exit (1);
  1173. X
  1174. X    /* Is this a regular file */
  1175. X    if ((sbuf.st_mode & S_IFREG) != S_IFREG)
  1176. X        exit (1);
  1177. X
  1178. X    /* does root own this file */
  1179. X    if (sbuf.st_uid != ROOT)
  1180. X        exit (1);
  1181. X
  1182. X    /* Is file executable by owner(root) */
  1183. X    if ((sbuf.st_mode & S_IEXEC) != S_IEXEC)
  1184. X        exit (1);
  1185. X
  1186. X    /* Is set uid bit on */
  1187. X    if ((sbuf.st_mode & S_ISUID) != S_ISUID)
  1188. X        exit (1);
  1189. X
  1190. X    setuid (ROOT);
  1191. X
  1192. X    strcpy (command, argv[1]);            /* program name */
  1193. X    for (i = 2; i < argc; i++)
  1194. X    {
  1195. X        strcat (command, " ");
  1196. X        strcat (command, "\"");
  1197. X        strcat (command, argv[i]);        /* program arguments */
  1198. X        strcat (command, "\"");
  1199. X    }
  1200. X
  1201. X    system (command);
  1202. X}
  1203. X/* Paul J. Condie  2-89 */
  1204. SHAR_EOF
  1205. chmod 0644 utilities.d/m.d/suid_exec.c || echo "restore of utilities.d/m.d/suid_exec.c fails"
  1206. rm -f s2_seq_.tmp
  1207. echo "You have unpacked the last part"
  1208. exit 0
  1209.