Wizard-level questions

Barry Shein bzs at world.std.com
Mon Jan 28 08:44:51 AEST 1991


From: cs163wcr at sdcc10.ucsd.edu (I support the U.N.)
>[1] Can you access a file by its i-node number?  Something like
>	(for C code) FILE *iopen (int inode, char *mode) ?

No, although NFS servers would find this handy and often have to
simulate about the same thing. Well, let me modify that "no" with
pointing out that of course you can do anything if you can access the
raw disk and getting at the contents of a file given its inode number
is a short afternoon's exercise, I've done it. So you could write a
library routine, but only someone with the proper privs to open the
raw disk could use it.

The problem is security. Although all the permissions on the file
itself are stored in the inode, you also have to verify that the path
to the file is accessible by the process doing the open(). At the
inode level all this information is non-existant and very hard to
recreate.

>[2] With Internet sockets, how does a machine accept()ing a
>	socket connection know what machine is calling it?  Does
>	it rely on the calling program to tell it?

Yes, essentially, the information is in the packets being sent. Some
tiny amount of spoofing can be avoided if hardware addresses can be
compared (e.g. via ARP caches), but basically that's all there is w/o
adding authorization code. Of course, if the protocol is two-way the
other side better be able to receive at that address also, which
provides some security against spoofing by simply whacking packet
addresses.

>[3] I have a server program that reads my mail and does various
>	functions.  One thing I would like it to do is send a "write"
>	message to other users when it gets a letter with subject
>	"WRITE user", sending the letter body as the message, but I
>	can't get write to work unless the output is a tty.  How do
>	I fool write into thinking my pipe is a tty?

Hmm, it's possible that you want to look at syslog(), depends on what
you're really trying to do. You could also craft your own program to
do this fairly easily, there's nothing magical about write (unless
tty's are all protected on your system, in which case you'll need
privilege.)

>[4] How did you become a Unix Wizard?  I'm learning various
>	features as I go, as I think of a use for them and/or
>	learn about them.  Is there a more organized/better way?

The easiest way is to have started with V6 and work hard for 15+
years...heh heh.
-- 
        -Barry Shein

Software Tool & Die    | bzs at world.std.com          | uunet!world!bzs
Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD



More information about the Comp.unix.internals mailing list