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

  1. From: lenny@icus.ICUS.COM (Lenny Tropiano)
  2. Newsgroups: unix-pc.sources,alt.sources
  3. Subject: Re: dpasswd: Dialup Password Administration/Version 2.1 (Patch1)
  4. Message-ID: <1204@icus.ICUS.COM>
  5. Date: 18 Jun 90 16:05:00 GMT
  6.  
  7. This is a small update to the program that I thought of this morning while
  8. using it.  It upgrades the program from 2.0 to 2.1.
  9.  
  10. -- cut and apply patch -- -- cut and apply patch -- -- cut and apply patch --
  11.  
  12. *** old/README    Sun Jun 17 00:49:59 1990
  13. --- README    Mon Jun 18 10:59:11 1990
  14. ***************
  15. *** 81,86
  16.   dpasswd: Dialup terminal restriction added for /dev/ph1.
  17.   dpasswd: Dialup program restriction added for /bin/ksh.
  18.   
  19.   Appropriate "messages" will be given for all cases.  
  20.   
  21.   If the program is compiled with the -DDEBUG flag, then diagnostic output 
  22.  
  23. --- 81,98 -----
  24.   dpasswd: Dialup terminal restriction added for /dev/ph1.
  25.   dpasswd: Dialup program restriction added for /bin/ksh.
  26.   
  27. + # dpasswd
  28. + Dialup lines:
  29. +     tty001
  30. +     tty002
  31. + Login programs:
  32. +     /bin/ksh
  33. +     /bin/sh
  34. + *    /usr/lib/uucp/uucico
  35. + * = no password necessary
  36.   Appropriate "messages" will be given for all cases.  
  37.   
  38.   If the program is compiled with the -DDEBUG flag, then diagnostic output 
  39. *** old/dpasswd.1    Sun Jun 17 00:46:08 1990
  40. --- dpasswd.1    Mon Jun 18 10:58:25 1990
  41. ***************
  42. *** 56,61
  43.   # dpasswd -n -p /usr/lib/uucp/uucico
  44.   dpasswd: Dialup program restriction added for /usr/lib/uucp/uucico.
  45.   
  46.   .fi
  47.   
  48.   .RE
  49.  
  50. --- 56,73 -----
  51.   # dpasswd -n -p /usr/lib/uucp/uucico
  52.   dpasswd: Dialup program restriction added for /usr/lib/uucp/uucico.
  53.   
  54. + # dpasswd
  55. + Dialup lines:
  56. +     tty001
  57. +     tty002
  58. + Login programs:
  59. +     /bin/ksh
  60. +     /bin/sh
  61. + *    /usr/lib/uucp/uucico
  62. + * = no password necessary
  63.   .fi
  64.   
  65.   .RE
  66. *** old/dpasswd.c    Sun Jun 17 01:04:20 1990
  67. --- dpasswd.c    Mon Jun 18 10:57:34 1990
  68. ***************
  69. *** 7,12
  70.   ** Date:         December 4, 1988      [Version 1.0]                    **
  71.   **               May 16, 1990          [Version 1.6]                    **
  72.   **               June 16, 1990         [Version 2.0]                    **
  73.   **                                                                      **
  74.   ** Modified by Gary Butler, ST, Pacific Bell [1.6]                      **
  75.   ** Modified by Joe Wasik, ST, Pacific Bell   [1.6]                      **
  76.  
  77. --- 7,13 -----
  78.   ** Date:         December 4, 1988      [Version 1.0]                    **
  79.   **               May 16, 1990          [Version 1.6]                    **
  80.   **               June 16, 1990         [Version 2.0]                    **
  81. + **               June 18, 1990         [Version 2.1]                    **
  82.   **                                                                      **
  83.   ** Modified by Gary Butler, ST, Pacific Bell [1.6]                      **
  84.   ** Modified by Joe Wasik, ST, Pacific Bell   [1.6]                      **
  85. ***************
  86. *** 10,16
  87.   **                                                                      **
  88.   ** Modified by Gary Butler, ST, Pacific Bell [1.6]                      **
  89.   ** Modified by Joe Wasik, ST, Pacific Bell   [1.6]                      **
  90. ! ** Modified by Lenny Tropiano, ICUS Software Systems [2.0]              **
  91.   **                                                                      **
  92.   **************************************************************************
  93.   **                                                                      **
  94.  
  95. --- 11,17 -----
  96.   **                                                                      **
  97.   ** Modified by Gary Butler, ST, Pacific Bell [1.6]                      **
  98.   ** Modified by Joe Wasik, ST, Pacific Bell   [1.6]                      **
  99. ! ** Modified by Lenny Tropiano, ICUS Software Systems [2.0, 2.1]         **
  100.   **                                                                      **
  101.   **************************************************************************
  102.   **                                                                      **
  103. ***************
  104. *** 120,125
  105.   **
  106.   **    - Lenny Tropiano
  107.   **
  108.   */
  109.   
  110.   #include <stdio.h>
  111.  
  112. --- 121,133 -----
  113.   **
  114.   **    - Lenny Tropiano
  115.   **
  116. + ** June 18, 1990
  117. + **
  118. + ** Modifications:
  119. + **
  120. + ** 1 -    If no arguments are given, dialup password'ed shells and ttys are
  121. + **        displayed.
  122. + **
  123.   */
  124.   
  125.   #include <stdio.h>
  126. ***************
  127. *** 220,226
  128.       extern int    optind;
  129.       extern char    *optarg;
  130.       void        manage_dialup(),
  131. !             manage_program();
  132.   
  133.   
  134.       /*
  135.  
  136. --- 228,235 -----
  137.       extern int    optind;
  138.       extern char    *optarg;
  139.       void        manage_dialup(),
  140. !             manage_program(),
  141. !             list_dialup();
  142.   
  143.   
  144.       /*
  145. ***************
  146. *** 234,239
  147.       if (debug)
  148.           (void) printf("buffer length: %d\n", DPASSWDLEN);
  149.   
  150.       /*
  151.       ** read command line options
  152.       */
  153.  
  154. --- 243,253 -----
  155.       if (debug)
  156.           (void) printf("buffer length: %d\n", DPASSWDLEN);
  157.   
  158. +     if (argc == 1) {    /* no parameters given */
  159. +         (void) list_dialup();
  160. +         exit(0);
  161. +     }
  162.       /*
  163.       ** read command line options
  164.       */
  165. ***************
  166. *** 268,274
  167.   
  168.       if (errflg || (!chgterm && !chgprog)) {
  169.           (void) fprintf(stderr,
  170. !             "Usage: %s [-qnd] -p program -t terminal\n", 
  171.               thisprg);
  172.           exit(1);
  173.       }
  174.  
  175. --- 282,288 -----
  176.   
  177.       if (errflg || (!chgterm && !chgprog)) {
  178.           (void) fprintf(stderr,
  179. !             "Usage: %s [-qnd] [-p program] [-t terminal]\n", 
  180.               thisprg);
  181.           exit(1);
  182.       }
  183. ***************
  184. *** 693,698
  185.       return 0;
  186.   }
  187.   
  188.   #ifndef lint
  189.   static    char sccsid[] = "@(#)dpasswd.c    Version 2.0";
  190.   #endif
  191.  
  192. --- 707,801 -----
  193.       return 0;
  194.   }
  195.   
  196. + void list_dialup()
  197. + {
  198. +     FILE    *fp;
  199. +     int    fd,
  200. +         nullfound;
  201. +     char    ttybuffer[TTYLEN],
  202. +         pswbuffer[DPASSWDLEN],
  203. +         *program,
  204. +         *password,
  205. +         *buffer,
  206. +         *c;
  207. +     /* read in the old dialups file */
  208. +     /* if it doesn't exist, then create it */
  209. +     if ((fp = fopen(dttyfile, "r")) == NULL) {
  210. +         if (debug)
  211. +             (void) printf("creating %s\n", dttyfile);
  212. +         if ((fd = creat(dttyfile, DIALUPS_PERMS)) < 0) {
  213. +             perror(dttyfile);
  214. +             exit(1);
  215. +         }
  216. +         fp = fdopen(fd, "r");
  217. +     }
  218. +     printf("Dialup lines:\n");
  219. +     while (fgets(ttybuffer, TTYLEN, fp) != NULL) {
  220. +         if (strncmp(ttybuffer,"/dev/",5) == 0)
  221. +             buffer = ttybuffer + 5;
  222. +         else
  223. +             buffer = ttybuffer;
  224. +         printf("\t%s", buffer);
  225. +     }
  226. +     (void) fclose(fp);
  227. +     /* read in the old dialups password file */
  228. +     /* if it doesn't exist, then create it */
  229. +     if ((fp = fopen(dpswfile, "r")) == NULL) {
  230. +         if (debug)
  231. +             (void) printf("creating %s\n", dpswfile);
  232. +         if ((fd = creat(dpswfile, DIALUPS_PERMS)) < 0) {
  233. +             perror(dpswfile);
  234. +             exit(1);
  235. +         }
  236. +         fp = fdopen(fd, "r");
  237. +     }
  238. +     nullfound = 0;
  239. +     printf("\nLogin programs:\n");
  240. +     while (fgets(pswbuffer, DPASSWDLEN, fp) != NULL) {
  241. +         /* 
  242. +         ** set the line which is "program:password:<CR>" to it's 
  243. +         ** individual components
  244. +         */
  245. +         program = pswbuffer;
  246. +         c = strrchr(pswbuffer, ':');
  247. +         *c = '\0';
  248. +         c = strchr(pswbuffer, ':');
  249. +         password = c + 1;
  250. +         *c = '\0';
  251. +         if (password[0] == '\0') {
  252. +             nullfound = 1;
  253. +             printf("*");
  254. +         }
  255. +         printf("\t%s\n", program);
  256. +     }
  257. +     if (nullfound)
  258. +         printf("\n* = no password necessary\n");
  259. +     (void) fclose(fp);
  260. +     printf("\n");
  261. + }
  262.   #ifndef lint
  263.   static    char sccsid[] = "@(#)dpasswd.c    Version 2.1";
  264.   #endif
  265. ***************
  266. *** 694,698
  267.   }
  268.   
  269.   #ifndef lint
  270. ! static    char sccsid[] = "@(#)dpasswd.c    Version 2.0";
  271.   #endif
  272.  
  273. --- 797,801 -----
  274.   }
  275.   
  276.   #ifndef lint
  277. ! static    char sccsid[] = "@(#)dpasswd.c    Version 2.1";
  278.   #endif
  279. -- 
  280. | Lenny Tropiano           ICUS Software Systems        lenny@icus.ICUS.COM |
  281. | {ames,pacbell,decuac,sbcs,hombre,rayssd}!icus!lenny   attmail!icus!lenny  |
  282. +------ ICUS Software Systems --  PO Box 1;  Islip Terrace, NY  11752 ------+
  283.