🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.programmer
10 messages
10 total messages Started by Rich Salz Thu, 27 Sep 1990 19:13
Re: how to put a program into a .plan file
#59
Author: Rich Salz
Date: Thu, 27 Sep 1990 19:13
119 lines
3346 bytes
>>% /etc/mknod ~/.plan p (Assuming that any existing .plan is not there)

In <978@bbt.UUCP> rgs@bbt.UUCP (steinbeiser) writes:
>Ok, how do you check the status of the file to see if it has
>been open by someone else?

/*  $Revision$
**
**  A process to create dynamic .plan files.  Creates a fifo, waits for
**  someone to connect to it.  Optional first argument is the directory
**  to chdir(2) to, as in "plan ~rsalz &"; default is value of $HOME.
**
**  Right now, this just keeps a count and runs fortune.  A neat hack
**  would be to replace /usr/etc/in.fingerd with code that does a
**  getpeername()/gethostbyaddr(), and goes back to the requesting
**  host to do a finger there.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>

#if	!defined(FD_SET)
    /* Some systems have it typedef'd wrong, so use #define. */
#define fd_set		int
#define	FD_SET(n, p)	(*(p) |= (1 << (n)))
#define	FD_CLR(n, p)	(*(p) &= ~(1 << (n)))
#define	FD_ISSET(n, p)	(*(p) & (1 << (n)))
#define	FD_ZERO(p)	(*(p) = 0)
#endif	/* !defined(FD_SET) */

extern int	errno;
extern char	*getenv();

static char	PLAN[] = ".plan";
static char	FORTUNE[] = "/usr/emacs/dist/etc/yow";
/*static char	FORTUNE[] = "/usr/games/fortune";*/


main(ac, av)
    int		ac;
    char	*av[];
{
    char	*p;
    int		Count;
    int		fd;
    FILE	*F;
    FILE	*In;
    fd_set	writers;
    char	buff[256];

    /* Go to the right directory. */
    if (ac == 2)
	p = av[1];
    else if ((p = getenv("HOME")) == NULL) {
	fprintf(stderr, "No $HOME.\n");
	exit(1);
    }
    if (chdir(p) < 0) {
	perror("Can't cd to $HOME");
	exit(1);
    }

    /* Remove any old one, create a new one. */
    if (unlink(PLAN) < 0 && errno != ENOENT) {
	perror("Can't unlink");
	exit(1);
    }
    (void)umask(0);
    if (mknod(PLAN, S_IFIFO | 0644, 0) < 0) {
	perror("Can't mknod");
	exit(1);
    }

    /* Enter the server loop. */
    for (Count = 0; ; ) {

	/* Open the fifo for writing. */
	if ((F = fopen(PLAN, "w")) == NULL) {
	    perror("Can't fopen");
	    (void)unlink(PLAN);
	    exit(1);
	}
	fd = fileno(F);

	/* Wait until someone else opens it for reading, so that we can
	 * write on it. */
	FD_ZERO(&writers);
	FD_SET(fd, &writers);
	if (select(fd + 1, (fd_set *)NULL, &writers, (fd_set *)NULL,
		(struct timeval *)NULL) < 0) {
	    if (errno != EINTR)
		perror("Can't select");
	    continue;
	}
	if (!FD_ISSET(fd, &writers))
	    /* "Can't happen" */
	    continue;

	/* Say hello to the nice stranger. */
	fprintf(F, "Well, hello there -- this is fortune #%d:\n", ++Count);
	if ((In = popen(FORTUNE, "r")) == NULL)
	    fprintf(F, "\tSorry, cookie jar is empty.\n");
	else {
	    while (fgets(buff, sizeof buff, In))
		fputs(buff, F);
	    (void)pclose(In);
	}

	/* Close it so they stop reading, and pause to make sure of it. */
	(void)fclose(F);
	(void)sleep(1);
    }

    /* NOTREACHED */
}
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.
Re: how to put a program into a .plan file
#922
Author: Dan Bernstein
Date: Fri, 28 Sep 1990 03:41
12 lines
1038 bytes
In article <2867@litchi.bbn.com> rsalz@bbn.com (Rich Salz) writes:
> **  Right now, this just keeps a count and runs fortune.  A neat hack
> **  would be to replace /usr/etc/in.fingerd with code that does a
> **  getpeername()/gethostbyaddr(), and goes back to the requesting
> **  host to do a finger there.

Neat hack? It's absolutely trivial. You just run fingerd under
attachport (-r) instead of inetd, and its environment will show a REMOTE
variable with the remote host (and authenticated username if the remote
host supports RFC 931).

---Dan
Re: how to put a program into a .plan file
#926
Author: Johan Pensar RT
Date: Fri, 28 Sep 1990 08:28
25 lines
1462 bytes
In article <2867@litchi.bbn.com> rsalz@bbn.com (Rich Salz) writes:
>/*  $Revision$
>**
>**  A process to create dynamic .plan files.  Creates a fifo, waits for
>**  someone to connect to it.  Optional first argument is the directory
>**  to chdir(2) to, as in "plan ~rsalz &"; default is value of $HOME.
...

We have here a couple of machines (suns) using the same userdisks.
If I start the program on one machine, and try to finger myself from 
another, the finger program locks up. It doesn't matter if i finger
myself on the current machine, or the machine i started plan from.
eg
        aton% finger jpensar@ra
        aton% finger jpensar

both locks up if i started the program on ra. The same happens if I finger 
myself from a VAX.

It doesnt work, but I guess it doesn't matters anyway.
--------------------------------------------------------------------------
Johan Pensar                                     Email: jpensar@ra.abo.fi
Process Control Laboratory
Abo Akademi University
FINLAND 
Re: how to put a program into a .plan file
#933
Author: Thomas Truscott
Date: Fri, 28 Sep 1990 18:31
15 lines
1029 bytes
> >**  A process to create dynamic .plan files.  Creates a fifo, waits for
> >**  someone to connect to it.  
> 
> We have here a couple of machines (suns) using the same userdisks.
> If I start the program on one machine, and try to finger myself from 
> another, the finger program locks up. ...

That is because NFS does not support remote named pipes.
(Or if you prefer, each client gets a "non-interfering"
instance of the named pipe!)

If you want this to work I suggest you get Freedomnet,
which also supports supports remote devices, program execution, etc.

	Tom Truscott
Re: how to put a program into a .plan file
#928
Author: hao zhou
Date: Fri, 28 Sep 1990 22:53
8 lines
744 bytes
A further question:
	Is it possible to figure out who have fingered you?

	-- Hao Zhou

-- 
Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET
UUCP: uunet!acsu.buffalo.edu!haozhou
Re: how to put a program into a .plan file
#938
Author: Matthew Farwell
Date: Sat, 29 Sep 1990 14:11
24 lines
1580 bytes
In article <38200@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>A further question:
>       Is it possible to figure out who have fingered you?

You could:- 

1) Search the process table looking for the keyword 'finger'. All this would
   alt this would require would just starting ps. However this method
   isn't very reliable in that it would catch other people who were
   fingering at that time + the process might not have an argv[0] of
   finger anyway.

2) Perhaps a more reliable method would be to go and get the active
   inode information from a program like pstat. (On Xenix, the option would
   be pstat -i). This gives you the device, the inode number and the uid
   of all currently active inodes. Therefore you can work out who is
   fingering you.

Dylan.
-- 
Matthew J Farwell                 | Email: dylan@ibmpcug.co.uk
The IBM PC User Group, PO Box 360,|        ...!uunet!ukc!ibmpcug!dylan
Harrow HA1 4LQ England            | CONNECT - Usenet Access in the UK!!
Phone: +44 81-863-1191            | Sun? Don't they make coffee machines?
Re: how to put a program into a .plan file
#939
Author: Jeremy J Starcher
Date: Sat, 29 Sep 1990 19:20
14 lines
1041 bytes
In article <38200@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>A further question:
>	Is it possible to figure out who have fingered you?
>
>	-- Hao Zhou
>
>-- 
>Internet:haozhou@acsu.buffalo.edu BITNET:haozhou%acsu.buffalo.edu@UBVM.BITNET
>UUCP: uunet!acsu.buffalo.edu!haozhou


We are doing a `w | grep finger $USER` and assuming only one person is 
fingering us at a time..  I can't rember the needed cut construct to extract
the other person's USER ID..
Who's fingering me? (was Re: how to put a program into a .plan file)
#944
Author: Jamie Zawinski
Date: Sun, 30 Sep 1990 06:19
48 lines
3326 bytes
In article <1990Sep29.141154.3546@ibmpcug.co.uk> dylan@ibmpcug.co.uk (Matthew Farwell) writes:
> In article <38200@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>> A further question:
>>       Is it possible to figure out who have fingered you?
>
> You could:- 
>
> 1) Search the process table looking for the keyword 'finger'. All this would

This only works if the person fingering you is doing so from your machine.
It is far more interesting to know the identity of someone out on the net
who is fingering you.  I believe this is impossible, because the finger
protocol requires no authentication - all you can know is the address of the
machine on whch the finger request originated, and the port to reply to.  I
once hacked the finger daemon on TI Explorer Lisp Machines to finger back -
when a finger request came in, it fingered @that-machine to get a list of
all users and what they were doing.  It then cached this away for me to look
at later, and use the excellent pattern matcher inside my head to decide who
was responsible :-).  Also, if the foreign machine did not accept finger
connections (as is too often the case these days) it would respond with
"Your machine, <machine name here> does not accept finger connections; this
is antisocial.  Go away."

It also detected loops, in case the foreign machine also had a fingerback
hack.

> 2) Perhaps a more reliable method would be to go and get the active
>    inode information from a program like pstat. (On Xenix, the option would
>    be pstat -i). This gives you the device, the inode number and the uid
>    of all currently active inodes. Therefore you can work out who is
>    fingering you.

I don't follow - are you looking for the user who has your .plan file open?
This will be /etc/fingerd.  Or maybe you're looking for the user who has
/bin/finger open.  Again, this only works when being fingered locally.

By the way, I highly recommend GNU Finger, available on expo.lcs.mit.edu.
It has lots of bells and whistles.  One machine is the finger server, and
periodically consults finger clients on all the machines on the local net,
to maintain a database of who is logged on where, and which machines are
idle.  Fingering a user at any machine at a site will tell you which machine
they are logged on and how long they have been idle (and also the last
machine they were logged on if they are logged out now.)  It also has a
"face" feature built in, with an X11 and SunView interface - "finger -face"
transmits a bitmap instead of text.  Also it can talk to and be talked to by
standard BSD finger servers and clients.

		-- Jamie
Re: Who's fingering me? (was Re: how to put a program into a .plan file
#946
Author: Matthew Farwell
Date: Sun, 30 Sep 1990 13:26
28 lines
2137 bytes
In article <JWZ.90Sep29231908@kolyma.lucid.com> jwz@lucid.com (Jamie Zawinski) writes:
>In article <1990Sep29.141154.3546@ibmpcug.co.uk> dylan@ibmpcug.co.uk (Matthew Farwell) writes:
>> In article <38200@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>>> A further question:
>>>       Is it possible to figure out who have fingered you?
>> You could:- 
>> 1) Search the process table looking for the keyword 'finger'. All this would
>This only works if the person fingering you is doing so from your machine.

Ok. I admit it. My solutions only work if there is one machine. You're
right that one way to do it would be to hack fingerd. I've got an excuse
in that I haven't got fingerd running on my machine(s).

>> 2) Perhaps a more reliable method would be to go and get the active
>>    inode information from a program like pstat. (On Xenix, the option would
>>    be pstat -i). This gives you the device, the inode number and the uid
>>    of all currently active inodes. Therefore you can work out who is
>>    fingering you.
>I don't follow - are you looking for the user who has your .plan file open?

Yes.

Dylan.
-- 
Matthew J Farwell                 | Email: dylan@ibmpcug.co.uk
The IBM PC User Group, PO Box 360,|        ...!uunet!ukc!ibmpcug!dylan
Harrow HA1 4LQ England            | CONNECT - Usenet Access in the UK!!
Phone: +44 81-863-1191            | Sun? Don't they make coffee machines?
Re: how to put a program into a .plan file
#958
Author: Michael A. Petonic
Date: Tue, 02 Oct 1990 03:55
23 lines
1691 bytes
In article <1990Sep29.141154.3546@ibmpcug.co.uk> dylan@ibmpcug.co.uk (Matthew Farwell) writes:
>In article <38200@eerie.acsu.Buffalo.EDU> haozhou@acsu.buffalo.edu (hao zhou) writes:
>>A further question:
>>       Is it possible to figure out who have fingered you?
>
>You could:- 
>
>1) Search the process table looking for the keyword 'finger'. All this would
>alt this would require would just starting ps. However this method
>isn't very reliable in that it would catch other people who were
>fingering at that time + the process might not have an argv[0] of
>finger anyway.
>
>2) Perhaps a more reliable method would be to go and get the active
>inode information from a program like pstat. (On Xenix, the option would
>be pstat -i). This gives you the device, the inode number and the uid
>of all currently active inodes. Therefore you can work out who is
>fingering you.

This is assuming, of course, that the initiator of the finger command
did so on your local machine.  Don't you guys have networks??? :-)

-MikeP
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads