Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!world!bzs From: bzs@world.std.com (Barry Shein) Newsgroups: comp.unix.internals Subject: Re: Wizard-level questions Message-ID: Date: 27 Jan 91 21:44:51 GMT References: <16048@sdcc6.ucsd.edu> Sender: bzs@world.std.com (Barry Shein) Organization: The World Lines: 55 In-Reply-To: cs163wcr@sdcc10.ucsd.edu's message of 26 Jan 91 09:26:49 GMT From: cs163wcr@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@world.std.com | uunet!world!bzs Purveyors to the Trade | Voice: 617-739-0202 | Login: 617-739-WRLD