home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / alt / bbs / unixbbs / 52 < prev    next >
Encoding:
Text File  |  1992-07-24  |  31.2 KB  |  1,156 lines

  1. Newsgroups: alt.bbs.unixbbs
  2. Path: sparky!uunet!decwrl!access.usask.ca!ccu.umanitoba.ca!umcarls9
  3. From: umcarls9@ccu.umanitoba.ca (Charles Carlson)
  4. Subject: Finger program to support BBS id
  5. Message-ID: <1992Jul24.171715.24665@ccu.umanitoba.ca>
  6. Organization: University of Manitoba, Winnipeg, Canada
  7. Date: Fri, 24 Jul 1992 17:17:15 GMT
  8. Lines: 1146
  9.  
  10.  
  11.  
  12.  
  13. Hi...
  14.  
  15. I've modified Phil's Finger program to support UnixBBS login "bbs" ids.  
  16. Now when the finger program comes across the login id "bbs", it attempts
  17. to open the UnixBBS files from /tmp and extract the callers name and city,
  18. and places it in the Full name and Console Location fields of Phil's
  19. Finger output.  For those who don't know what Phil's Finger is, it is
  20. a finger replace with a few more features for those of us lacking a good
  21. finger program.  He's some sample output:
  22.  
  23. -User-     --Full name--           -What- Idle TTY -Console Location-
  24. bbs        Beaker Breaker          bbs         vt0 Wpg, Mb
  25.            Charles Carlson         bbs         vt0 Winnipeg, Manitoba
  26.            Shan Durand             bbs         d02 Wpg, Mb
  27. charles    Charles                 tcsh      9 vt0 Unknown
  28.                                    telnet      vt0 Unknown
  29. root       Root                    tcsh   8:35 con Console Terminal
  30.                                    xf          vt0 Unknown
  31.                                    tcsh      8 vt0 Unknown
  32.  
  33.  
  34. One nice thing about this, is that it works over TCP/IP.  So if you have
  35. your UnixBBS running on a machine in a networked environment, you can
  36. finger the machine and find out who's on the BBS w/o having to log into
  37. that machine!
  38.  
  39. For those paranoid about such things, I'll tell you now that you now need
  40. to run the finger program as setuid root and setgid sys.  You need setuid
  41. root otherwise you cannot open the UnixBBS files in /tmp.   You probably
  42. could get by with running it setuid bbs, but I didn't bother trying.
  43.  
  44. Phil's Finger was posted to comp.sources.unix(misc?) a while back, so you
  45. should be able to find it in the appropriate archives, if not, I've made
  46. it temporarily available via anonymous FTP from ccu.umanitoba.ca, as
  47. /pub/umcarls9/pfinger.tar.Z with my changes already included.  If you're
  48. running ISC 2.2.1 and TCP/IP you should be able to just type make.  If
  49. you're not using TCP/IP, you'll probably need to undefine the inet stuff. 
  50.  
  51. For those who already have Phil's Finger, the only files that need
  52. modifying are finger.c and ymakefile, and the addition of ubbswho.c.  I've
  53. included these at the end of the article.  Just search for UnixBBS if you
  54. want to see what has changed.
  55.  
  56. I would like to hear about problems, so let me know if I did anything wrong.
  57.  
  58. Charles
  59.  
  60. #! /bin/sh
  61. # This is a shell archive, meaning:
  62. # 1. Remove everything above the #! /bin/sh line.
  63. # 2. Save the resulting text in a file.
  64. # 3. Execute the file with /bin/sh (not csh) to create:
  65. #       finger.c
  66. #       ubbswho.c
  67. #       ymakefile
  68. # This archive created: Fri Jul 24 11:46:21 CDT 1992
  69. # By:   umcarls9 ()
  70. export PATH; PATH=/bin:/usr/bin:$PATH
  71. echo shar: "extracting 'finger.c'" '(   14601 characters)'
  72. if test -f 'finger.c'
  73. then
  74.         echo shar: "will not over-write existing file 'finger.c'"
  75. else
  76.         sed 's/^X//' << \SHAR_EOF > 'finger.c'
  77. X/*
  78. X * finger.c -- output formatting for finger (main is in args.c)
  79. X *
  80. X * Copyright (C) 1986, 1990  Philip L. Budne
  81. X *
  82. X * This file is part of "Phil's Finger Program".
  83. X *
  84. X * This program is free software; you can redistribute it and/or modify
  85. X * it under the terms of the GNU General Public License as published by
  86. X * the Free Software Foundation; either version 1, or (at your option)
  87. X * any later version.
  88. X *
  89. X * UnixBBS support added by Charles Carlson, please let me know if you find
  90. X * and problems. mail to: umcarls9@ccu.umanitoba.ca or 
  91. X * charles@gremlin.muug.mb.ca
  92. X *
  93. X * You must define UnixBBS, and you must now run finger as setuid root,
  94. X * otherwise it will not be able to open the bbs files in /tmp.
  95. X *
  96. X */
  97. X
  98. X# ifndef lint
  99. Xstatic char *rcsid = "$Id: finger.c,v 3.0 90/07/06 13:10:35 budd Rel $";
  100. X# endif /* lint not defined */
  101. X
  102. X# include <sys/types.h>
  103. X# include <stdio.h>
  104. X# include "person.h"
  105. X# include "output.h"
  106. X# include "args.h"                     /* before luser.h */
  107. X# include "luser.h"
  108. X# include "finger.h"
  109. X# include "pr.h"
  110. X# include "inquire.h"                  /* for INQUIRE */
  111. X# include "ttylocfile.h"
  112. X
  113. X# define PID_COL               /* display /pid in seperate column */
  114. X
  115. X/*# define RELATION                    /* display REL if this is defined */
  116. X/*# define REL_SUP ""          /* (define as quoted string of relations */
  117. X                               /*  to supress display of) */
  118. X
  119. XFORWARD LOCAL void
  120. X# ifdef RELATION
  121. X    prelation(),
  122. X# endif /* RELATION defined */
  123. X    pusername(), pgroup(), pspace(), ppname(),
  124. X    pcmd(), pidle(), pbiff(), ptty(), pmesg(), plocation(), ppid(),
  125. X    pstr(), pchar(), togoal();
  126. X
  127. XLOCAL int outcol, goalcol;
  128. X
  129. X# define USER_WID 8
  130. X# define PROG_WID 7                    /* 6 prog + 1 flag */
  131. X
  132. X# ifndef TTY_WID
  133. X# ifdef AIX3
  134. X# define TTY_WID 6
  135. X# else  /* AIX3 not defined */
  136. X# if defined(UmaxV) || defined(PTS_PTY_NAMES)
  137. X# define TTY_WID 5                     /* rtAAPPS or ptsNN */
  138. X# else  /* not defined(UmaxV) || defined(PTS_PTY_NAMES) */
  139. X# define TTY_WID 3
  140. X# endif /* not defined(UmaxV) || defined(PTS_PTY_NAMES) */
  141. X# endif /* AIX3 not defined */
  142. X# endif /* TTY_WID not defined */
  143. X
  144. X# define BASE_PER_WID (22+3+3)         /* base person width */
  145. X
  146. Xtypedef void (*FPTR)();
  147. X
  148. XFPTR fields[] = {
  149. X    pusername,
  150. X    pspace,
  151. X    pgroup,
  152. X# ifdef RELATION
  153. X# define GRPREL_WID 3                  /* 2 + space */
  154. X    prelation,
  155. X# else  /* RELATION not defined */
  156. X# define GRPREL_WID 2                  /* 1 + space */
  157. X# endif /* RELATION not defined */
  158. X    pspace,
  159. X    ppname,
  160. X    NULL
  161. X}; /* fields */
  162. X
  163. X# define PER_WID (BASE_PER_WID-TTY_WID-GRPREL_WID)
  164. X
  165. X
  166. XFPTR fields2[] = {
  167. X# ifdef PID_COL
  168. X    ppid,
  169. X# endif /* PID_COL defined */
  170. X# ifndef SUPPRESS_WHAT
  171. X    pcmd,
  172. X# endif /* SUPPRESS_WHAT not defined */
  173. X    pidle,
  174. X    pbiff,
  175. X    ptty,
  176. X    pmesg,
  177. X    plocation,
  178. X    NULL
  179. X}; /* fields2 */
  180. X
  181. X/* display when program running from another uid */
  182. X# ifndef SUID_ROOT
  183. X# define SUID_ROOT '+'
  184. X# endif /* SUID_ROOT not defined */
  185. X
  186. X# ifndef SUID_OTHER
  187. X# define SUID_OTHER '!'
  188. X# endif /* SUID_OTHER not defined */
  189. X
  190. X/* when no command found */
  191. X# ifndef EMPTY_CMD
  192. X# define EMPTY_CMD "??"
  193. X# endif /* EMPTY_CMD not defined */
  194. X
  195. X# define NO_GROUP ' '
  196. X
  197. X# ifdef RELATION
  198. X# define REL_HEADER 'R'
  199. X# define GRP_HEADER 'G'
  200. X# else  /* RELATION not defined */
  201. X# define GRP_HEADER ' '                /* or 'G' */
  202. X# endif /* RELATION not defined */
  203. X
  204. X/****** what to show when there is no person structure ******/
  205. X# define NO_RELATION ' '
  206. X
  207. X# ifdef INQUIRE
  208. X# define NO_NAME "--No inquire entry--"
  209. X# else  /* INQUIRE not defined */
  210. X# define NO_NAME "--No password entry--" /* acucntrl locks?!*/
  211. X# endif /* INQUIRE not defined */
  212. X
  213. Xextern LTREE *maketree();              /* from getent.c */
  214. Xextern struct pr *getcommand();                /* from getcommand.c */
  215. Xextern char *getttyloc();              /* from gettyloc.c */
  216. Xextern int pwtree();                   /* from getperson.c */
  217. Xextern whois(), plan();                        /* from whois.c */
  218. Xextern char *gtname(), *intstr();      /* from output.c */
  219. X
  220. XLOCAL time_t now;                      /* current time */
  221. XLOCAL int personwidth;                 /* calculated at runtime! */
  222. X
  223. X#define UnixBBS
  224. X
  225. X#ifdef UnixBBS
  226. Xchar   bbsname[PLEN+1];
  227. Xchar   bbscity[32];
  228. X#endif
  229. X
  230. XLOCAL void                             /* forwards.. */
  231. X    finguser(),
  232. X    fingheader(),
  233. X    dogecos();
  234. X
  235. XGLOBAL void dofinger( t )
  236. XLTREE *t;
  237. X{
  238. X    int n;
  239. X
  240. X    personwidth = PER_WID;
  241. X# ifdef PID_COL
  242. X# define PID_WID 6
  243. X    if( sw_pid )
  244. X       personwidth -= PID_WID/2;
  245. X# endif /* PID_COL defined */
  246. X
  247. X# ifdef LASTLOG
  248. X    llopen();                          /* open lastlog file */
  249. X# endif /* LASTLOG defined */
  250. X
  251. X    time( &now );                      /* get current time */
  252. X    if( t == NULL )                    /* nothing? */
  253. X       pwtree( (t = maketree()) );     /* get tree of all logged in users */
  254. X
  255. X    n = treesize( t );                 /* count users */
  256. X    if( n == 0 )
  257. X       puts("No one logged in.");
  258. X    else {
  259. X# ifndef ALWAYS_PRINT_HEADER
  260. X       if( n > 1 )                     /* be like oz finger */
  261. X# endif /* ALWAYS_PRINT_HEADER not defined */
  262. X           fingheader();               /* print header */
  263. X
  264. X       ptree( t, finguser );           /* print tree */
  265. X    } /* n != 0 */
  266. X
  267. X# ifdef LASTLOG
  268. X    llclose();                         /* close lastlog file */
  269. X# endif /* LASTLOG defined */
  270. X} /* finger */
  271. X
  272. XLOCAL BOOL same;
  273. X
  274. XLOCAL void finguser(u)
  275. Xregister LUSER *u;
  276. X{
  277. X    static PERSON *person;
  278. X    static int incarnations;
  279. X    register FPTR *fp;
  280. X
  281. X    if( u->u_person != NULL ) {
  282. X       if( (u->u_person->p_flags & P_RC) != 0 ) { /* pw_gecos == "RC" ?*/
  283. X           dogecos( u );
  284. X           return;
  285. X       } /* RC hack */
  286. X    } /* run command */
  287. X
  288. X    if( u->u_flags & U_NLI ) {         /* not logged in */
  289. X       char location[ 50 ];
  290. X       time_t ltime;                   /* last login time */
  291. X       int host;
  292. X       PERSON *p;
  293. X
  294. X       p = u->u_person;
  295. X       same = FALSE;                   /* crock, pass as arg? *TODO* */
  296. X       for( fp = fields; *fp != NULL; fp++ )
  297. X           (*fp)( FALSE, u, p );
  298. X       goalcol++;                      /* space */
  299. X
  300. X       /* get last login time from lastlog */
  301. X       if( p == NULL || (p->p_flags & P_NOPWENT) )
  302. X           pstr( "NO PASSWORD ENTRY (EXPIRED ACCOUNT?)" ); /* no pw ent? */
  303. X# ifdef LASTLOG
  304. X       else if( !lltime( p->p_uid, location, <ime, &host ) || ltime == 0 )
  305. X           pstr( "Login Unknown" );    /* no login time */
  306. X       else {                          /* have login time. format it */
  307. X           int printed;
  308. X           TTYLOC *tp;
  309. X
  310. X           pstr( "Login " );
  311. X           pstr( nicetime( ltime ) );
  312. X
  313. X           /* TODO: if sw_its no "from...." */
  314. X           pstr( " from " );
  315. X           printed = FALSE;
  316. X           inittylocs();
  317. X           if( !host && (tp = findttyloc( location )) != NULL ) {
  318. X               char *s;
  319. X               if( tp->t_short != NULL )
  320. X                   s = tp->t_short;
  321. X               else if( tp->t_locn != NULL )
  322. X                   s = tp->t_locn;
  323. X               else
  324. X                   s = NULL;
  325. X               if( s != NULL ) {
  326. X                   printed = TRUE;
  327. X                   pstr( s );
  328. X                   pchar('{');
  329. X                   pstr( location );
  330. X                   pchar('}');
  331. X               }
  332. X           } /* foundttyloc */
  333. X           if( !printed )
  334. X               pstr( location );
  335. X       } /* have login time */
  336. X# endif /* LASTLOG defined */
  337. X       /* if sw_its check plan */
  338. X       pchar('\n');
  339. X       incarnations = 1;
  340. X    } /* not logged in */
  341. X    else {                             /* is logged in */
  342. X       termstat( u );                  /* get tty status (before getcommand) */
  343. X# ifndef SUPPRESS_WHAT
  344. X       getcommand( u );                /* get command/daemon procs */
  345. X# endif /* SUPPRESS_WHAT not defined */
  346. X
  347. X
  348. X# ifndef NEVER_SAME
  349. X       if( u->u_person != NULL && u->u_person == person ) /* same person */
  350. X           same = TRUE;                /* as before? */
  351. X       else
  352. X# endif /* NEVER_SAME not defined */
  353. X           same = FALSE;
  354. X
  355. X       person = u->u_person;
  356. X       if( !same )
  357. X           if( person != NULL )
  358. X               incarnations = person->p_count;
  359. X           else
  360. X               incarnations = 1;
  361. X
  362. X       for( fp = fields; *fp != NULL; fp++ )
  363. X           (*fp)( FALSE, u, person );
  364. X       goalcol++;                      /* blank space */
  365. X       for( fp = fields2; *fp != NULL; fp++ )
  366. X           (*fp)( FALSE, u, person );
  367. X       pchar( '\n' );
  368. X    } /* logged in */
  369. X
  370. X    if( incarnations-- == 1 ) {                /* final incarnation? */
  371. X       if( sw_whois ) {                /* do whois stuff */
  372. X           whois( u );
  373. X           blankline();
  374. X       }
  375. X
  376. X       if( u->u_sw.sw_mail || sw_whois || (u->u_flags & U_NLI) ) {
  377. X           mcheck( u );
  378. X           blankline();
  379. X       }
  380. X
  381. X       if( sw_whois ) {
  382. X           remarks( u );
  383. X           blankline();
  384. X       }
  385. X
  386. X       /*
  387. X        * show plan if asked for.  if user not logged in
  388. X        * show unless prohibited.
  389. X        */
  390. X       if( u->u_sw.sw_plan || (u->u_flags & U_NLI) && !u->u_sw.sw_noplan ) {
  391. X           plan( u );
  392. X           blankline();
  393. X       }
  394. X    } /* last incarnation */
  395. X} /* finguser */
  396. X
  397. XLOCAL void fingheader() {
  398. X    FPTR *fp;
  399. X
  400. X    for( fp = fields; *fp != NULL; fp++ )
  401. X       (*fp)( TRUE, NULL, NULL );
  402. X    goalcol++;                         /* blank space */
  403. X    for( fp = fields2; *fp != NULL; fp++ )
  404. X       (*fp)( TRUE, NULL, NULL );
  405. X    pchar( '\n' );
  406. X    fflush(OUTPUT);
  407. X} /* fingheader */
  408. X
  409. XLOCAL void dogecos( u )                        /* here if PNAME == "RC" */
  410. XLUSER *u;
  411. X{
  412. X    int pid, wpid;
  413. X
  414. X    pid = fork();                      /* no vfork uses stdio */
  415. X    if( pid == 0 ) {                   /* be childish */
  416. X       PERSON *p;
  417. X       p = u->u_person;
  418. X
  419. X       chdir(p->p_home);
  420. X       setuid(p->p_uid);
  421. X       setgid(p->p_gid);
  422. X       printf("%s/%s:\n", p->p_home, u->u_user);
  423. X       fflush( stdout );
  424. X       execl(u->u_user, u->u_user, 0);
  425. X       perror("Sorry");
  426. X       exit(1);
  427. X    }
  428. X    else if( pid < 0 )
  429. X       perror("fork");
  430. X
  431. X    while( (wpid = wait(0)) > 0 && wpid != pid ) /* lassie come home!! */
  432. X       ;
  433. X} /* dogecos */
  434. X
  435. XLOCAL void
  436. X_pchar( c )
  437. X    char c;
  438. X{
  439. X    static char linebuf[ 512 ], *lp = linebuf;
  440. X    if( c == '\n' ) {
  441. X       *lp = EOS;
  442. X       outline( linebuf );
  443. X       outcol = goalcol = 0;
  444. X       lp = linebuf;
  445. X    } /* newline */
  446. X    else {                             /* not newline */
  447. X       if( c == '\t' )
  448. X           outcol = (outcol + 8) & ~7;
  449. X       else
  450. X           outcol++;
  451. X       *lp++ = c;
  452. X    } /* not newline */
  453. X} /* _pchar */
  454. X
  455. XLOCAL void
  456. Xtogoal() {
  457. X    while( outcol < goalcol ) {
  458. X       int temp;
  459. X       temp = (outcol + 8) & ~7;
  460. X       if( temp <= goalcol )
  461. X           _pchar( '\t' );
  462. X       else
  463. X           _pchar( ' ' );
  464. X    }
  465. X    goalcol = outcol;
  466. X} /* togoal */
  467. X
  468. XLOCAL void
  469. Xpchar( c )
  470. X    char c;
  471. X{
  472. X    if( outcol < goalcol )             /* save extra calls */
  473. X       togoal();
  474. X    _pchar( c );
  475. X} /* pchar */
  476. X
  477. XLOCAL void
  478. Xpstr( s )
  479. X    register char *s;
  480. X{
  481. X    if( s == NULL )
  482. X       return;
  483. X    togoal();
  484. X    while( *s )
  485. X       _pchar( *s++ );
  486. X} /* pstr */
  487. X
  488. XLOCAL void
  489. Xpcount( c, s )
  490. X    register c;
  491. X    register char *s;
  492. X{
  493. X    if( s == NULL )
  494. X       return;
  495. X    togoal();
  496. X    while( c-- && *s )
  497. X       _pchar( *s++ );
  498. X} /* pcount */
  499. X
  500. XLOCAL void
  501. Xpusername( title, u, p )
  502. X    BOOL title;
  503. X    LUSER *u;
  504. X    PERSON *p;
  505. X{
  506. X    if( title )
  507. X       pstr( "-User-" );
  508. X    else if( !same )
  509. X       pcount( USER_WID, u->u_user );
  510. X    goalcol += USER_WID;
  511. X} /* pusername */
  512. X
  513. X# ifdef INQUIRE
  514. X# ifdef RELATION
  515. XLOCAL void
  516. Xprelation( title, u, p )
  517. X    BOOL title;
  518. X    LUSER *u;
  519. X    PERSON *p;
  520. X{
  521. X    char rel;
  522. X    if( title )
  523. X       pchar( REL_HEADER );            /* title */
  524. X    else if( !same )                   /* not same as last */
  525. X       if( p != NULL ) {               /* have person info */
  526. X           rel = p->p_relation;
  527. X# ifdef REL_SUP
  528. X           if( sw_whois || index(REL_SUP, rel) == NULL ) /* whois or */
  529. X# endif /* REL_SUP defined */
  530. X               pchar( rel );           /* not suppressed */
  531. X       } /* have person */
  532. X       else
  533. X           pchar( NO_REL );
  534. X    goalcol++;
  535. X} /* prelation */
  536. X# endif /* RELATION defined */
  537. X# endif /* INQUIRE defined */
  538. X
  539. XLOCAL void
  540. Xpgroup( title, u, p )
  541. X    BOOL title;
  542. X    LUSER *u;
  543. X    PERSON *p;
  544. X{
  545. X
  546. X    if( title )
  547. X       pchar( GRP_HEADER  );           /* title */
  548. X    else if( !same && p != NULL )      /* not same and have person */
  549. X       pchar( p->p_group );
  550. X
  551. X    goalcol++;
  552. X} /* pgroup */
  553. X
  554. XLOCAL void
  555. Xpspace( title, u, p )
  556. X    BOOL title;
  557. X    LUSER *u;
  558. X    PERSON *p;
  559. X{
  560. X    goalcol++;
  561. X} /* pspace */
  562. X
  563. XLOCAL void
  564. Xppname( title, u, p )
  565. X    BOOL title;
  566. X    LUSER *u;
  567. X    PERSON *p;
  568. X{
  569. X    if( title )
  570. X       pstr( "--Full name--" );
  571. X       else 
  572. X#ifdef UnixBBS
  573. X       {
  574. X       if(strcmp(u->u_user,"bbs")==0) {
  575. X               same=FALSE;
  576. X               get_bbsuser(u->u_line,bbsname,bbscity);
  577. X               strcpy(p->p_personal,bbsname);
  578. X       }
  579. X#endif /* UnixBBS */
  580. X    if( !same )
  581. X       if( p != NULL ) 
  582. X           pcount( personwidth, p->p_personal );
  583. X       else
  584. X           pstr( NO_NAME );
  585. X#ifdef UnixBBS
  586. X }
  587. X#endif /* UnixBBS */
  588. X    goalcol += personwidth;
  589. X} /* ppname */
  590. X
  591. XLOCAL void
  592. Xpcmd( title, u, p )
  593. X    BOOL title;
  594. X    LUSER *u;
  595. X    PERSON *p;
  596. X{
  597. X    struct pr *pr;
  598. X
  599. X    if( title ) {
  600. X       pstr( (sw_its ? "Jobnam" : "-What-") );
  601. X       goalcol += PROG_WID;
  602. X       return;
  603. X    }
  604. X
  605. X    pr = u->u_command;
  606. X    if( pr != NULL ) {
  607. X       char suid;
  608. X
  609. X       if( p == NULL || pr->pr_uid == p->p_uid ) /* same uid? */
  610. X           suid = ' ';                 /* no flag */
  611. X       else if( pr->pr_uid == 0 )      /* super user? */
  612. X           suid = SUID_ROOT;           /* flag it */
  613. X       else                            /* someone else */
  614. X           suid = SUID_OTHER;
  615. X
  616. X       pcount( PROG_WID-1, pr->pr_cmd ); /* leave one for suid */
  617. X       pchar( suid );
  618. X    } /* pr not null */
  619. X    else
  620. X       pstr( EMPTY_CMD );
  621. X
  622. X    goalcol += PROG_WID;
  623. X} /* pcmd */
  624. X
  625. X# ifdef PID_COL
  626. XLOCAL void
  627. Xppid( title, u, p )
  628. X    BOOL title;
  629. X    LUSER *u;
  630. X    PERSON *p;
  631. X{
  632. X    if( !sw_pid )
  633. X       return;                         /* takes no space!! */
  634. X
  635. X    if( title )
  636. X       pstr("  Pid");                  /* two leading spaces */
  637. X    else if( u->u_command != NULL ) {
  638. X       char tbuf[10];
  639. X       sprintf(tbuf, "%5d", u->u_command->pr_pid );
  640. X       pstr( tbuf );
  641. X    }
  642. X    goalcol += PID_WID;                        /* leave space after */
  643. X} /* ppid */
  644. X# endif /* PID_COL defined */
  645. X
  646. XLOCAL void
  647. Xpidle( title, u, p )
  648. X    BOOL title;
  649. X    LUSER *u;
  650. X    PERSON *p;
  651. X{
  652. X    if( title ) {
  653. X       if( sw_age )
  654. X           pstr( "-On-" );
  655. X       else if( sw_state )
  656. X           pstr( "Stat" );
  657. X# ifndef PID_COL
  658. X       else if( sw_pid )
  659. X           pstr( "  Pid" );            /* two spaces!! */
  660. X# endif /* PID_COL not defined */
  661. X       else
  662. X           pstr( "Idle" );
  663. X    } /* title */
  664. X    else {                             /* real thing */
  665. X       char idbuf[ 100 ];
  666. X       strcpy( idbuf, "??" );
  667. X
  668. X       if( sw_age )
  669. X           intstr(idbuf, now - u->u_time ); /* get time on */
  670. X       else if( sw_state ) {
  671. X           if( u->u_command != NULL )
  672. X               getstate( idbuf, u->u_command ); /* get state */
  673. X       }
  674. X# ifndef PID_COL
  675. X       else if( sw_pid ) {
  676. X           if( u->u_command != NULL )
  677. X               sprintf(idbuf, "%5d", u->u_command->pr_pid );
  678. X       }
  679. X# endif /* PID_COL not defined */
  680. X       else if( u->u_flags & U_BADTTY )
  681. X           strcpy( idbuf, "*:**" );
  682. X       else
  683. X           intstr(idbuf, u->u_idle );  /* get idle time */
  684. X       pstr( idbuf );
  685. X    }
  686. X
  687. X# ifndef PID_COL
  688. X    if( sw_pid )                       /* variable width!! */
  689. X       goalcol += 5;
  690. X    else
  691. X# endif /* PID_COL not defined */
  692. X       goalcol += 4;
  693. X} /* pidle */
  694. X
  695. XLOCAL void
  696. Xpbiff( title, u, p )
  697. X    BOOL title;
  698. X    LUSER *u;
  699. X    PERSON *p;
  700. X{
  701. X    /* alright, I lost control. C at its ugliest
  702. X     * nothing - space
  703. X     * biff    - dot
  704. X     * hungry  - comma
  705. X     * both    - semi
  706. X     */
  707. X    if( !title )
  708. X       pchar( " .,;"[ ((u->u_flags & U_BIFF)   ? 01 : 0) |
  709. X                      ((u->u_flags & U_HUNGRY) ? 02 : 0) ] );
  710. X    goalcol++;
  711. X} /* pbiff */
  712. X
  713. XLOCAL void
  714. Xptty( title, u, p )
  715. X    BOOL title;
  716. X    LUSER *u;
  717. X    PERSON *p;
  718. X{
  719. X    if( title )
  720. X       pstr("TTY");
  721. X    else
  722. X       pcount( TTY_WID, gtname( u->u_line ) ); /* get trimmed tty name */
  723. X    goalcol += TTY_WID;
  724. X} /* ptty */
  725. X
  726. XLOCAL void
  727. Xpmesg( title, u, p )
  728. X    BOOL title;
  729. X    LUSER *u;
  730. X    PERSON *p;
  731. X{
  732. X    if( !title && (u->u_flags & U_NOWRITE) )
  733. X       pchar( '*' );
  734. X    goalcol++;
  735. X} /* pmesg */
  736. X
  737. XLOCAL void
  738. Xplocation( title, u, p )
  739. X    BOOL title;
  740. X    LUSER *u;
  741. X    PERSON *p;
  742. X{
  743. X    if( title )
  744. X       pstr( "-Console Location-" );
  745. X    else
  746. X#ifdef UnixBBS
  747. X       {
  748. X       if(strcmp(u->u_user,"bbs")==0) {
  749. X/*             get_bbsuser(u->u_line,bbsname,bbscity); */
  750. X               pstr(bbscity);
  751. X       } else
  752. X#endif /* UnixBBS */
  753. X       pstr( getttyloc( u ) );         /* tty location */
  754. X#ifdef UnixBBS
  755. X    }
  756. X#endif /* UnixBBS */
  757. X    /* no new goal!! */
  758. X} /* plocation */
  759. X
  760. X/*
  761. X * Local variables:
  762. X * comment-column: 40
  763. X * End:
  764. X */
  765. SHAR_EOF
  766. if test    14601 -ne "`wc -c < 'finger.c'`"
  767. then
  768.         echo shar: "error transmitting 'finger.c'" '(should have been    14601 characters)'
  769. fi
  770. fi
  771. echo shar: "extracting 'ubbswho.c'" '(     756 characters)'
  772. if test -f 'ubbswho.c'
  773. then
  774.         echo shar: "will not over-write existing file 'ubbswho.c'"
  775. else
  776.         sed 's/^X//' << \SHAR_EOF > 'ubbswho.c'
  777. X/* Original uwho.c source by Ricardo Pizzi <pizzi@nervous.com>
  778. X *
  779. X * Modified for Phil's Finger by Charles Carlson
  780. X * charles@gremlin.muug.mb.ca or umcarls9@ccu.umanitoba.ca
  781. X *
  782. X*/
  783. X
  784. X#include <stdio.h>
  785. X#include <errno.h>
  786. X#include "bbsuser.h"
  787. X
  788. Xvoid get_bbsuser(tty, name,city)
  789. Xchar *tty;
  790. Xchar name[33];
  791. Xchar city[32];
  792. X{
  793. X       char bbs_rec[48];
  794. X       char names[65];
  795. X       struct User user;
  796. X       FILE *f;
  797. X
  798. X       sprintf(bbs_rec, "/tmp/bbs.%s", tty);                   
  799. X               if      ((f = fopen(bbs_rec, "r")) != NULL) {
  800. X                       fread(&user, sizeof(struct User), 1, f);
  801. X                       fclose(f);
  802. X                       strcpy(names,user.fname);
  803. X                       strcat(names," "); strcat(names,user.lname);
  804. X                       strncpy(name,names,32);
  805. X                       strcpy(city,user.city);
  806. X               } else {
  807. X                       strcpy(name, "[ login ]");
  808. X                       strcpy(city, "Unknown");
  809. X               }
  810. X
  811. X} /* end get_bbsuser */
  812. X
  813. SHAR_EOF
  814. if test      756 -ne "`wc -c < 'ubbswho.c'`"
  815. then
  816.         echo shar: "error transmitting 'ubbswho.c'" '(should have been      756 characters)'
  817. fi
  818. fi
  819. echo shar: "extracting 'ymakefile'" '(    7944 characters)'
  820. if test -f 'ymakefile'
  821. then
  822.         echo shar: "will not over-write existing file 'ymakefile'"
  823. else
  824.         sed 's/^X//' << \SHAR_EOF > 'ymakefile'
  825. X/*
  826. X * ymakefile -- cpp input file for real work makefile (xmakefile)
  827. X *
  828. X * Copyright (C) 1986, 1990  Philip L. Budne
  829. X *
  830. X * This file is part of "Phil's Finger Program".
  831. X *
  832. X * This program is free software; you can redistribute it and/or modify
  833. X * it under the terms of the GNU General Public License as published by
  834. X * the Free Software Foundation; either version 1, or (at your option)
  835. X * any later version.
  836. X *
  837. X */
  838. X
  839. X/*
  840. X * $Id: ymakefile,v 3.1 90/07/06 13:21:28 budd Exp $
  841. X */
  842. X
  843. X/* Needed under AIX_RT */
  844. XSHELL=/bin/sh
  845. X
  846. X# include "local.h"
  847. X
  848. X/* Used for make depend */
  849. X/* CCM=cc -M */
  850. XCCM=./cc-M
  851. X
  852. XETAGS=etags
  853. XDIST=/usr/public/users/budd/finger
  854. X
  855. X# ifdef C_COMPILER
  856. XCC=C_COMPILER
  857. X# else  /* C_COMPILER not defined */
  858. X# ifdef ibm032
  859. XCC=pcc
  860. X# endif /* ibm032 defined */
  861. X# endif /* C_COMPILER not defined */
  862. X
  863. X# ifdef C_FLAGS
  864. XCC_FLAGS=-O
  865. X# else  /* C_FLAGS not defined */
  866. XCC_FLAGS=-O
  867. X# endif /* C_FLAGS not defined */
  868. X
  869. X# ifdef LD_FLAGS
  870. X/* useful for -Bstatic on SunOS4 */
  871. XLDFLAGS=LD_FLAGS
  872. X# endif /* LD_FLAGS defined */
  873. X
  874. X# ifdef INQUIRE
  875. XLINQUIRE=./hakinq/libinq.a
  876. X# endif /* INQUIRE defined */
  877. X
  878. X# ifdef USG
  879. XTERM=-lcurses
  880. X# else  /* USG not defined */
  881. XTERM=-ltermcap
  882. X# endif /* USG not defined */
  883. X
  884. X# if SunOS >= 40
  885. X# ifdef i386
  886. XOSLIBS=-lkvm -lld
  887. X# else  /* i386 not defined */
  888. XOSLIBS=-lkvm
  889. X# endif /* i386 not defined */
  890. X# endif /* SunOS >= 40 */
  891. X
  892. X# ifdef sgi
  893. X/* -lsun for yp -- per spike@world.std.com */
  894. X# ifdef YELLOW_PAGES
  895. XOSLIBS=-lbsd -lmld -lsun
  896. X# else  /* YELLOW_PAGES not defined */
  897. XOSLIBS=-lbsd -lmld
  898. X# endif /* YELLOW_PAGES not defined */
  899. XINCLUDES=-I/usr/include/bsd
  900. X# endif /* sgi defined */
  901. X
  902. X# ifdef AIX3
  903. XOSLIBS=-lcfg -lodm
  904. X# endif /* AIX3 defined */
  905. X
  906. X# ifdef UmaxV
  907. X/* recent versions have /bsd/usr/include... /bsd/bin/cc... etc */
  908. XOSLIBS=-laux
  909. XINCLUDES=-I./include
  910. X# endif /* UmaxV defined */
  911. X
  912. X# ifdef SYSI86                         /* Interactive 386/ix */
  913. XOSLIBS=-linet
  914. X# endif /* SYSI86 defined */
  915. X
  916. X# if Umax == 43
  917. XOSLIBS=-lld
  918. X# endif /* Umax == 43 */
  919. X
  920. X# ifdef LIB_RESOLVE
  921. XRESOLVE=LIB_RESOLVE
  922. X# endif /* LIB_RESOLVE defined */
  923. X
  924. X# ifdef INCLUDE_PATH
  925. XINCLUDES=INCLUDE_PATH
  926. X# endif /* INCLUDE_PATH defined */
  927. X
  928. X# ifdef USG
  929. XOTHERS=uptime
  930. X# endif /* USG defined */
  931. X
  932. X# ifdef NO_STRINGS_H
  933. XOSINCLUDES=-I.
  934. X# endif /* NO_STRINGS_H defined */
  935. X
  936. XCFLAGS=$(CC_FLAGS) $(OSINCLUDES) $(INCLUDES) 
  937. X
  938. X/****************************************************************
  939. X */
  940. XALL=   xf fingerd ttyloc ttyask $(OTHERS)
  941. X
  942. X/* for cleanup */
  943. XALLBIN= $(ALL) symdate pversion newmanifest mywhoami
  944. X
  945. Xall:   $(ALL)
  946. X
  947. X.PRECIOUS: $(ALL)
  948. X
  949. X/****************************************************************
  950. X * (internet) finger daemon
  951. X */
  952. X
  953. X/* Add new files to MANIFEST!! */
  954. XFINGERD_O=fingerd.o string.o upper.o
  955. Xfingerd: $(FINGERD_O)
  956. X       $(CC) $(CFLAGS) -o fingerd $(FINGERD_O) $(RESOLVE) $(OSLIBS) $(LDFLAGS)
  957. X# ifdef IN_DOT_DAEMON
  958. X       -rm -f in.fingerd
  959. X       ln fingerd in.fingerd
  960. X# endif /* IN_DOT_DAEMON defined */
  961. X
  962. X/****************************************************************
  963. X * new finger!
  964. X */
  965. X/* Add new files to MANIFEST!! */
  966. XNF_O=  args.o daemon.o doremote.o conf.o ubbswho.o finger.o getcommand.o\
  967. X       getent.o getperson.o getttyloc.o getut.o global.o inquire.o\
  968. X       kmem.o lastlog.o locname.o mcheck.o names.o output.o readpr.o\
  969. X       ttylocfile.o read_vmunix.o select.o skip.o string.o switch.o\
  970. X       undomain.o upper.o ustruct.o whois.o whoj.o
  971. X
  972. XNF_C=  args.c daemon.c doremote.c conf.c ubbswho.c finger.c getcommand.c\
  973. X       getent.c getperson.c getttyloc.c getut.c global.c inquire.c\
  974. X       kmem.c lastlog.c locname.c mcheck.c names.c output.c readpr.c\
  975. X       ttylocfile.c read_vmunix.c select.c skip.c string.c switch.c\
  976. X       undomain.c upper.c ustruct.c whois.c whoj.c
  977. X
  978. XNFLIBS=        $(TERM) $(RESOLVE) $(LINQUIRE) $(OSLIBS)
  979. X
  980. Xxf:    $(NF_O) pversion mywhoami
  981. X       ./make-version > version.c
  982. X       $(CC) -c version.c
  983. X       $(CC) $(CFLAGS) -o xf $(NF_O) version.o $(NFLIBS) $(LDFLAGS)
  984. X
  985. Xpversion: pversion.c History.h
  986. X       $(CC) $(CFLAGS) -o pversion pversion.c
  987. X
  988. X/* whoami is a BSDism.  USG systems don't have it */
  989. Xmywhoami: mywhoami.c
  990. X       $(CC) $(CFLAGS) -o mywhoami mywhoami.c
  991. X
  992. X/* uptime replacement for USG systems */
  993. X# ifdef USG
  994. Xuptime:        uptime.c
  995. X       $(CC) $(CFLAGS) -o uptime uptime.c
  996. X# endif /* USG defined */
  997. X
  998. X# ifdef UmaxV
  999. X/* newer releases have /bsd/usr/include */
  1000. X$(NF_O): ./include
  1001. X
  1002. X./include:
  1003. X       mkdir include include/sys
  1004. X       (cd include; \
  1005. X        ln -s /usr/include/sys/arpa /usr/include/sys/netinet .; \
  1006. X        ln -s /usr/include/sys/aux/syslog.h /usr/include/sys/aux/netdb.h .; \
  1007. X        cd sys; ln -s /usr/include/sys/h/socket.h . )
  1008. X# endif /* UmaxV defined */
  1009. X
  1010. Xsymdate.h: symdate syms.h
  1011. X       ./symdate syms.h > symdate.h
  1012. X
  1013. Xsymdate: symdate.c
  1014. X       $(CC) -o symdate symdate.c
  1015. X
  1016. X/****************
  1017. X * create call graph.  (-c and -W are BU local switches)
  1018. X */
  1019. Xxf.calls: $(NF_C)
  1020. X       calls -W 4 -c -e -f main $(NF_C) > xf.calls
  1021. X
  1022. XTAGS:  $(NF_C)
  1023. X       $(ETAGS) $(NF_C) 
  1024. X
  1025. X/****************************************************************
  1026. X * Interactive ttyloc asker (front end for ttyloc)
  1027. X */
  1028. X
  1029. XTTYASK= ttyask.o skip.o getttytype.o ttylocfile.o string.o upper.o
  1030. Xttyask:        $(TTYASK)
  1031. X       $(CC) $(CFLAGS) -o ttyask $(TTYASK) $(OSLIBS) $(LDFLAGS)
  1032. X
  1033. X/****************************************************************
  1034. X * ttyloc setting program
  1035. X */
  1036. X
  1037. XTTYLOC=        ttyloc.o locname.o
  1038. Xttyloc:        $(TTYLOC)
  1039. X       $(CC) $(CFLAGS) -o ttyloc $(TTYLOC) $(OSLIBS) $(LDFLAGS)
  1040. X
  1041. X/****************************************************************
  1042. X * lint picking
  1043. X */
  1044. X
  1045. X/* removed -p -- not in SunOS anymore!! */
  1046. Xlint:  llib-lf.ln
  1047. X       lint -h llib-lf.ln *.c > LINT 2>&1
  1048. X
  1049. Xllib-lf.ln:
  1050. X       lint -Cf $(DEFS) *.c > /dev/null 2>&1
  1051. X
  1052. X/****************************************************************
  1053. X * household chores
  1054. X */
  1055. XKIT=Finger-part
  1056. X/*
  1057. X * be tidy (keeps .o files)
  1058. X *
  1059. X * kill myecho, pversion, and symdate as they are compiled
  1060. X * and don't port across achitectures!
  1061. X */
  1062. X
  1063. Xclean:
  1064. X       -rm -f core *~ \#* *.out finger.tar *.bak LOG *.s $(KIT)* \
  1065. X               MANIFEST.* myecho pversion symdate mywhoami getgroup checkmode
  1066. X
  1067. Xrealclean: clean
  1068. X       -rm -f $(ALLBIN) *.o version.c local.h \
  1069. X               xmakefile Install in.fingerd
  1070. X
  1071. X/*
  1072. X * pack up using tar or makekit
  1073. X */
  1074. X
  1075. X/* If you add here, you MUST add to MANIFEST too!! */
  1076. XSAMPLE=SAMPLE-local.h
  1077. XSAMPLE2=SAMPLE-flags
  1078. XSAMPLE3=SAMPLE-conf
  1079. XSAMPLES=$(SAMPLE) $(SAMPLE2) SAMPLE-nttyloc $(SAMPLE3)
  1080. XTAR=   VERSION* COPYRIGHT COPYING Cover README\
  1081. X       finger.1 ttyloc.1 nttyloc.5 finger.conf.5 fingerd.8c\
  1082. X       Makefile ymakefile Install.cpp autoconfig make-version\
  1083. X       TODO WISHES COUNT ORIG FINDDEFS DIFFALL COMDEFALL defs.awk cc-M\
  1084. X       MODES $(SAMPLES) Distfile\
  1085. X       `ls *.[ch] | egrep -v '^(local\.h|version\.c|symdate\.h)'`
  1086. X
  1087. X$(SAMPLE): local.h
  1088. X       rm -f $(SAMPLE)
  1089. X       cp local.h $(SAMPLE)
  1090. X
  1091. X$(SAMPLE2):
  1092. X       -cp local-flags $(SAMPLE2) || touch $(SAMPLE2)
  1093. X
  1094. X$(SAMPLE3):
  1095. X       -cp finger.conf $(SAMPLE3) || touch $(SAMPLE3)
  1096. X
  1097. Xfinger.tar tar: $(SAMPLES) pversion mywhoami
  1098. X       -rm -f VERSION*
  1099. X# ifndef USG
  1100. X       echo "`date` by `./mywhoami` on `hostname`" > VERSION-`pversion`
  1101. X# endif /* USG not defined */
  1102. X       tar cf finger.tar $(TAR) hungry
  1103. X
  1104. Xfinger.tar.Z: finger.tar
  1105. X       compress -v < finger.tar > finger.tar.Z
  1106. X
  1107. Xsplit: finger.tar.Z
  1108. X       uuencode finger.tar.Z < finger.tar.Z | split - finger.tar.Z.uu.
  1109. X
  1110. X/* utter crock to merge file list and MANIFEST! */
  1111. Xnewmanifest: newmanifest.c
  1112. X       $(CC) $(CFLAGS) -o newmanifest newmanifest.c
  1113. X
  1114. X/* note; hungry/?* to defeat cpp comment removal!! */
  1115. Xkit:   $(SAMPLES) pversion newmanifest
  1116. X       -rm -f VERSION* $(KIT)*
  1117. X       echo "version `pversion` packed `date` by `whoami` on `hostname`" > \
  1118. X               VERSION
  1119. X       cp MANIFEST MANIFEST.saved
  1120. X       ./newmanifest $(TAR) hungry hungry/?* MANIFEST > nMANIFEST
  1121. X       mv nMANIFEST MANIFEST
  1122. X       makekit -n $(KIT) -s 64k -m
  1123. X       rm -f MANIFEST.BAK
  1124. X
  1125. Xdist:  kit split
  1126. X       rm -rf $(DIST)
  1127. X       mkdir $(DIST) $(DIST)/shar $(DIST)/split
  1128. X       cp README COPYING $(DIST)
  1129. X       mv finger.tar finger.tar.Z VERSION* $(DIST)
  1130. X       mv $(KIT)* $(DIST)/shar
  1131. X       mv finger.tar.Z.uu.?? $(DIST)/split
  1132. X
  1133. Xdepend:
  1134. X       sed '/^# DO NOT DELETE THIS LINE/q' xmakefile > xmakefile.tmp
  1135. X       $(CCM) $(CFLAGS) *.c |\
  1136. X               egrep -v '(local\.h|finger\.h|/usr/include|.c:$$|.c$$)' |\
  1137. X               sed 's@[        ]*\./@ @' >> xmakefile.tmp
  1138. X       mv xmakefile.tmp xmakefile
  1139. X
  1140. X/* ugh.  cannot trust make depend the first time around */
  1141. Xnames.o: symdate.h
  1142. SHAR_EOF
  1143. if test     7944 -ne "`wc -c < 'ymakefile'`"
  1144. then
  1145.         echo shar: "error transmitting 'ymakefile'" '(should have been     7944 characters)'
  1146. fi
  1147. fi
  1148. exit 0
  1149. #       End of shell archive
  1150.  
  1151. -- 
  1152. / Charles Carlson  umcarls9@ccu.Umanitoba.CA  
  1153. \ This .sig now available on a limited edition 2 record set, for 4 easy 
  1154. / installments of $19.95 each. To order, please have your Visa or Mastercard
  1155. \ ready and phone: 1-800-555-1212, or send check or MO to 200-155 Carlton St.
  1156.