HDTenEightyP/NetNews huggingface dataset:
From: bzs@ussr.std.com (Barry Shein)
Newsgroups: comp.unix.wizards
Subject: Re: A few UNIX questions
Date: 7 Sep 92 06:50:40 GMT
Organization: The World


>> Can *anyone* tell me why the file size is a signed integer.  Surely there
>> is no need for negative sized files!!
>
>Because lseek() needs to be able to return -1 on error, and not have it
>look like a valid file offset.

That assumes that you need to test (lseek() < 0), one probably should
test (lseek() == -1) which steals only one value from the entire
address space. Granted that has to be casted if it were unsigned to
something more like (lseek() == ((unsigned long)-1)) but no great
problem.

This situation already exists with the brk() system call and shmget()
(probably others) which can both return the same bit patterns as
appear to be negative values on most machines Unix runs on, but
exactly -1 on return is magic.

If there's any concern one can of course set errno = 0 and then check
it after the call so still, with some care, distinguish the peculiar
legal -1 case (as these are all system calls.)

Sort of a botch, but there ya have it.

--
        -Barry Shein

Software Tool & Die    | bzs@world.std.com          | uunet!world!bzs
Purveyors to the Trade | Voice: 617-739-0202        | Login: 617-739-WRLD
Newsgroups: comp.unix.wizards
From: forrie@morwyn.uucp (Forrie Aldrich)
Subject: /bin/rm security issue(s)
Organization: Vision Graphics
Date: Thu, 10 Sep 1992 01:57:05 GMT
X-Newsreader: Tin 1.1 PL5

I am aware that when a file is deleted, the blocks are made 'free' for
writing, but the files contents can still linger about on the disk; and
as such can be effectively retrieved with a good program.  I've a couple
of programs (which have saved my life :) that do this.

However:  I'm concerned about being able really _eradicate_ a file,
for various reasons including security.

Does anyone have a program that will do this?  A friend suggested that 
I get a program that will open the file and write 'zeros' or something
to the end of it and then close it. _Then_ /bin/rm the file.

I could see adding this 'feature' to /bin/rm or perhaps writing a
program called /bin/rrm (_really-remove_) to do this.  Hmmm... I wonder
how government contracts manage this issue...

Thank you.



-- 
	   -----------	      Forrest Aldrich	      -----------
	   -------     morwyn!forrie@unhtel.unh.edu	  -------
	   ----						     ----
	   --	     VISION GRAPHICS --	Dover, NH - USA	       --
	   ------------------------------------------------------
Newsgroups: comp.unix.wizards
From: cavers@menudo.uh.edu (Chris M. Cavers)
Subject: need info on some system calls
Organization: University of Houston
Date: Thu, 10 Sep 1992 19:10:46 GMT

In reading the text on the design of the 3.2bsd system (the one
with the demon on the cover), I ran across the following system calls.
bmap (page 207), namei, and rwip.  I could not find these using the man
command.  I suspect they are kernel only calls.  Could someone 
point me to a reference/description of them?

Thanks in advance.
Chris
From: bhoughto@sedona.intel.com (Blair P. Houghton)
Subject: Re: MAXFRAG
Organization: Intel Corp., Chandler, Arizona
Date: Tue, 15 Sep 1992 17:41:56 GMT

In article <1992Sep15.024803.26176@menudo.uh.edu> cavers@menudo.uh.edu (Chris M. Cavers) writes:
>In which file is MAXFRAG defined?  MAXFRAG is used in fs.h.

Try grep(1).  Try 'grep include fs.h'.

				--Blair
				  "grep, user, grep!"
From: clone@alliant.snu.ac.kr
Newsgroups: comp.unix.wizards
Subject: Help needed on Unix-standard Speaker Sound ...
Date: 7 Sep 92 03:17:56 GMT

Dear Netters ...

I have simple implementation with the architecture of Alliant system.
And just the beep sound of the speakers...
I just want to hear another sound on my system
at least C,D,E,F-like melody.

Is anybody out there who knows and are willing to let me know 
how to generate sound on the standard Unix speaker and environment ?

Any comments would be very helpful to me.
Including shell commands or C-source ....

Thanks for reading me and in advance .
Sincerely Rhee Hwan-Seokj
Seoul KOREA
e-mail : clone@alliant.snu.ac.kr
From: urlichs@smurf.sub.org (Matthias Urlichs)
Newsgroups: comp.unix.wizards,comp.unix.programmer,comp.unix.internals
Subject: Re: Implementation of Sys V. based message queues
Date: 9 Sep 1992 15:55:41 +0200
Organization: University of Karlsruhe, FRG
NNTP-Posting-Host: 127.0.0.1

In comp.unix.wizards, article <1992Sep8.171014.21414@dickens.com>,
  lpc@dickens.com (Luis P Caamano) writes:
> In article <1992Sep3.232807.18181@noao.edu> rstevens@noao.edu (W. Richard Stevens) writes:
> >
> >Believe it or not, I just found out that AIX on the RS/6000 actually
> >provides a function named select() with a different interface that
> >actually lets you multiplex both descriptors and message queues.
> >When I saw their interface I almost barfed.
> 
> Why? Is the implementation so awful?  I remember I almost barfed too but 
> just because it was a new, strange select() that wasn't what I was used
> to see.
> 
It's awful because it's nonstandard. The Right Thing to do is to make open
message queues behave like standard Unix file descriptors, including read()/
/write()/select(), not to invent another totally nonstandard function and
naming it in the way that will confuse people the most.  :-/

> At least they did something ...

Does anybody use message queues anyway? For something that can't be done
just as easily with named pipes or Unix-domain sockets?

-- 
Real computer scientists only write specs for languages that might run
on future hardware.  Nobody trusts them to write specs for anything homo
sapiens will ever be able to fit on a single planet.
-- 
Matthias Urlichs  --  urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de   /(o\
Humboldtstrasse 7 -- 7500 Karlsruhe 1 -- Germany  --  +49-721-9612521     \o)/
Newsgroups: comp.unix.wizards
From: dstewart+@cs.cmu.edu (David B Stewart)
Subject: Question on COFF Format (Summary)
Cc: dstewart
Organization: The Robotics Institute, Carnegie Mellon University
Date: Tue, 8 Sep 1992 21:39:53 GMT

In article <Bu2AJL.43K.1@cs.cmu.edu> I wrote:
> 
> I am writing a program which must read in an i860 COFF file.
> 
> Is there any way of knowing the size of the string table before
> the table is read in?

Several responses said to get the file size (using fstat()) and
subtract (symbol_table_offset + symbol_table_size) from it, and
that is the size of the string table.  That is what I was doing,
and I was looking for a better solution.  It turns out, the size
of the string table IS stored in the file.  The first 4 bytes
of the string table is the size of the table, in bytes.

Therefore I can do the following to dynamically allocate my string table
using the following code segment (var declarations omitted):

    lseek(fd,fhdr->f_symptr+fhdr->f_nsyms*sizeof(struct syment),SEEK_SET);
    read(fd,&size,4);
    strtable = malloc(size)
    *(int *)strtable = size;
    read(fd,strtable+4,size);

Thanks for your responses.

~dave

-------------------------------------------------------------------------------
David B. Stewart  - email: <dstewart@cmu.edu>            The Robotics Institute
snail mail:       - ECE Dept., Carnegie Mellon University, Pittsburgh, PA 15213
Current Projects: - Chimera 3.0 Real-Time Operating System
		  - Reconfigurable Sensor-Based Control Systems
From: duane@anasazi.com (Duane Morse)
Subject: Selecting a "safe" socket/port for a server - HELP!
Organization: Anasazi Inc, Phoenix AZ USA
Date: Fri, 4 Sep 1992 23:47:15 GMT

We have a number of server programs which listen on sockets/ports
to perform various transaction processing functions.  We'd rather
not make these programs have super-user privileges in order to
use privileged, low-numbered sockets/ports, because it's an adminstrative
nuisance.

Is it a safe strategy to use high-end port numbers for the listeners
in order to avoid having client programs possibly grab the
socket/port before the server?  If so, what is considered "high-end"?
If not, is there an alternate strategy?
-- 

Duane Morse	e-mail: duane@anasazi.com
(602) 861-7609
Newsgroups: comp.unix.wizards
From: lpc@dickens.com (Luis P Caamano)
Subject: Re: Selecting a "safe" socket/port for a server - HELP!
Date: Wed, 9 Sep 1992 15:45:14 GMT
Organization: Dickens Data Systems, Inc.

In article <1992Sep4.234715.23719@anasazi.com> duane@anasazi.com (Duane Morse) writes:
>We have a number of server programs which listen on sockets/ports
>to perform various transaction processing functions.  We'd rather
>not make these programs have super-user privileges in order to
>use privileged, low-numbered sockets/ports, because it's an adminstrative
>nuisance.
>
>Is it a safe strategy to use high-end port numbers for the listeners
>in order to avoid having client programs possibly grab the
>socket/port before the server?  If so, what is considered "high-end"?
>If not, is there an alternate strategy?

"high-end" is over 5000.

From W. R. Stevens, "Unix Network Programming," pg. 303-304
-----
reserved ports                             1-1023
ports automatically assigned by system  1024-5000
ports assigned by rresvport()            512-1023
-----
"The system doesn't automatically assign an Internet port greater than
5000.  It leaves these ports for user-developed, nonprivileged servers."

Now, that's what the books says.  Most implementations follow this 
scheme, but that's not the law.
-- 
---------------------------------------------------------------------------
Luis P. Caamano                    |         lpc@dickens.com
Dickens Data Systems, Inc.         |         uunet!dickens.com!lpc
Atlanta, GA                        |         (404) 475-8860
---------------------------------------------------------------------------
If I think I know it all, I'll stop learning. -myself
The more I learn, the more I know I know nothing. -somebody else
Newsgroups: comp.unix.wizards
From: norm@bnr.ca (Norm MacNeil)
Subject: Re:    /etc/utmp trouble
Originator: norm@bcrks122
Reply-To: norm@bnr.ca
Organization: Bell-Northern Research Ltd.
Date: Tue, 15 Sep 1992 19:02:55 GMT


In article <92259.131154KLAWITT@DMSWWU1A.UNI-MUENSTER.DE>, Holger Klawitter, Informatik <KLAWITT@DMSWWU1A.UNI-MUENSTER.DE> writes:
> Hi!
> 
> Since nobody in comp.unix.questions dared to answer my question ill try
> this group. I am looking for a program to edit the /etc/utmp file
> in order to change the ownership of the tty('s ?) of xdm.
> (A patch into xdm would be even better.)
> This tty should be given to the user; otherwise programs like printtool,
> xlock(the MIT-one) or xvnews believe to belong to xdm.
> 

Well, to read the tty file, you would use something like the following:
/*--------------------------------------*/
/* Given you've included the appropriate headers & defined:
 * char *TTYName;
   FILE *F;
   struct utmp *UP;
 */
  TTYName = (char *) ttyname(0);
  if ((F = fopen("/etc/utmp", "r")) != NULL) {
    if ((UP = (struct utmp *) malloc(sizeof(struct utmp))) != NULL) {
      while ((fread(UP, sizeof(struct utmp), 1, F) == 1)
          && (strcmp(UP->ut_line, TTYName) != 0));
      if (UP != NULL) {
#if defined(SUN) || defined(SUNOS)
  printf("Username is %s\n", UP->ut_name);
#else
  printf("Username is %s\n", UP->ut_user);
#endif
  printf("Hostname is %s\n", UP->ut_host);
/* etc... */
/*--------------------------------------*/

  So, given the above to read the file, you could write the records to a new file
  and subsequently replace the above file with the new file after closing
  /etc/utmp.  I'm not sure if this would work and not sure if it would royally
  screw things up but this is how you find info from utmp.

  BTW, I am aware of the getutmp() routines however, not every platform has them
  so I use the above for portability.

    Storm.
  
-- 
+-----------------------------------------------------------------------+
 Norm MacNeil                     Phone: (613) 763-7497
 CAD Operation                      Fax: (613) 763-3317
 Bell-Northern Research Ltd.      EMail: norm@bnr.ca (INTERNET)
 #include <disclaimer.std>       "Roller bladers do it in-line!"
Xref: sparky comp.unix.wizards:3891 comp.unix.questions:10964
From: ws@tools.de (Wolfgang Solfrank)
Newsgroups: comp.unix.wizards,comp.unix.questions
Subject: Re: reliable signals under BSD / SVR4
Date: 11 Sep 92 18:33:01
Organization: TooLs GmbH, Bonn, Germany
	<acourtny.715556934@unix1.tcd.ie>
NNTP-Posting-Host: kurt.tools.de
In-reply-to: acourtny@unix1.tcd.ie's message of 3 Sep 92 21:48:54 GMT

In article <acourtny.715556934@unix1.tcd.ie> acourtny@unix1.tcd.ie (Antony A. Courtney) writes:

>   Since signals are
>   meant to be analogous to interrupts, wouldn't it be useful to guarantee that
>   all signals sent are processed?  I would think this would be particularly
>   useful for programs that request async. I/O on a descriptor.

But interrupts aren't counted either (at least on no machine I've come across).

>   Come to think of it, doesn't it make it somewhat "tricky" to use async. I/O at
>   all?
>
(pseudo source deleted)
>
>   This code has an obvious race condition, since the check for EWOULDBLOCK and
>   the return from the signal handler is non-atomic.  If data arrives on the
>   descriptor between the time of checking for EWOULDBLOCK and returning from
>   the signal handler, the SIGIO will not be delivered since there is already
>   one pending.  This will leave unprocessed data pending in the buffer for the
>   descriptor.

No, there is no race condition envolved. If data arrives on the descriptor
after the handler was entered, the signal is (re-)scheduled for delivery at
the next possibility. If the read sets errno to EWOULDBLOCK, the handler
returns and is immediately recalled. You see, no problem. Just the same
as with hardware interrupts.
--
ws@tools.de     (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
Newsgroups: comp.unix.wizards,comp.unix.internals
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: core dump on 4.1.2 SunOS / why?
Organization: Weber State University  (Ogden, UT)
Distribution: usa
Date: Fri, 11 Sep 92 01:39:24 GMT

In article <1992Sep10.223808.354@BofA.com> jeff@BofA.COM (Jeff Tate) writes:
>I have just done something very strange to my Sparc2 and am at a loss to recover.  Help is requested.
>
>For irrelevenat reasons, I needed to make space on my /usr partition.  I
>therefore moved share, diag, and kvm to a /local partition via tar pipe.
>After I had finished the experiment that required the space, I attempted
>to restore these directories.  Unfortunately, I had forgotten to remove
>the new symbolic links (i chchanged the link from boot->./kvm/boot to
>boot->/local/usr/boot) and so the return pipe was doing something really
>wierd.  Anyway, I got messages to th effect that 'warning:  libraries 
>changed'.  Crash, panic, death, ... and after a dirty recovery, commands
>such as ps, vmstat, adb core dump.
>
>I discovered that /usr/kvm/libkvm.a and /usr/lib/libkvm_p.a where garbaged
>(ranlib reported this) and replaced them with copies from another 4.1.2 2
>machine, but the behaviour persists.  I can operate most of the rest of the
>machine, but cannot get a ps or an adb to work.

The path to the libraries is fixed.  You need to put them back or tell
everything where you hid them.

1.	If you can get a shell up, set your LDPATH to point to the libraries
	new location.  Check your Sun manual on 'ld' if you are unsure of
	how to set LDPATH.

2.	Boot from CDROM and mount your disk(s) to do the work instead of
	installing.

It is also possible that the crash garbaged ps and/or adb, and that you
should pull these from another machine as well.  This is highly unlikely
and is provided only to be completionist (nasty habit I have).

Hope this helps.  Reminds me of the time a friend compressed his shared
libraries on a NeXT to make more space and found that *EVERYTHING* used
them, including sh and uncompress.


					Terry Lambert
					terry_lambert@gateway.novell.com
					terry@icarus.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-- 
-------------------------------------------------------------------------------
                                        "I have an 8 user poetic license" - me
 Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
-------------------------------------------------------------------------------
Xref: sparky comp.unix.wizards:3887 comp.unix.programmer:4630 comp.unix.internals:1794
From: pcg@aber.ac.uk (Piercarlo Grandi)
Newsgroups: comp.unix.wizards,comp.unix.programmer,comp.unix.internals
Subject: Re: Implementation of Sys V. based message queues
Date: 10 Sep 92 18:40:15 GMT
	<acourtny.715558246@unix1.tcd.ie>
Reply-To: pcg@aber.ac.uk (Piercarlo Grandi)
Organization: Prifysgol Cymru, Aberystwyth

On 3 Sep 92 22:10:46 GMT, acourtny@unix1.tcd.ie (Antony A. Courtney) said:

acourtny> All the system V IPC mechanisms are completely inconsistent
acourtny> with the rest of the i/o facilities provided by Unix.

And for a damn good reason! They do not come from Unix, really. The
reason for which they exist at all, when named pipes would have been
sufficient, is that a particular group within AT&T used a particular
version of something that looked like Unix, and they needed for their
real time application (switching) an especially fast, if crude, IPC
mechanism, so they came up with a set of interfaces that were custom
designed for their application and nothing else.

Then they lobbied hard the internal AT&T Unix Support Group so that the
specs for their custom IPC were added to the standard interfaces so they
did not have to port their implementation to each new release of Unix,
but USG did it for them.
--
Piercarlo Grandi                   | JNET: pcg@uk.ac.aber
Dept of CS, University of Wales    | UUCP: ...!aber-cs!pcg
Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@aber.ac.uk
Newsgroups: comp.unix.wizards
From: cavers@menudo.uh.edu (Chris M. Cavers)
Subject: MAXFRAG
Summary: in which file is MAXFRAG (used in fs.h) defined?
Organization: University of Houston
Date: Tue, 15 Sep 1992 02:48:03 GMT

In which file is MAXFRAG defined?  MAXFRAG is used in fs.h.
Thanks
From: lm@slovax.Eng.Sun.COM (Larry McVoy)
Newsgroups: comp.unix.wizards
Subject: Re: Disk decoding
Date: 9 Sep 1992 02:29:12 GMT
Organization: Sun Microsystems, Inc.  Mt. View, Ca.
NNTP-Posting-Host: slovax

To solve this, and other problems, I've always wanted to keep *a* name
of the file in the inode/vnode.  By a name, I mean the last name by
which the file was looked up.  My debugging kernels always have this
but I've been unsuccessful at getting it integrated into the mainstream.

terry@thisbe.Eng.Sandy.Novell.COM (Terry Lambert) writes:
: In article <1992Sep8.183206.248@menudo.uh.edu> cavers@menudo.uh.edu (Chris M. Cavers) writes:
: >I would like to decode the information on a unix disk.
: >I am using Sun OS 4.1.2.
: >I am intercepting the block i/o calls at the device driver level.
: >Given a byte offset and a number of bytes to move, I would like to be
: >able to determine which file contains the data. 
: 
: If you are truly intercepting them, then the blocks should be in a cache
: hung off the vnode (your interception is taking place before they are
: removed from this cache).
: 
: You may either traverse the system open file table or the dnlc table to
: identify the inode whose vnode contains a pointer to the block being written.
: The inode will have to be looked up using an ncheck type process, which
: you may do at the device driver level (in an extremely ugly fashion) by
: traversing the directory tree.
: 
: I will probably be flamed for suggesting that this be done in the device
: driver; however, using the normal interface will kill you by making those
: blocks show up as well.
: 
: Alternately, you can assemble an in core inode/name resoloution list and
: traverse it (assembling it prior to attempting logging of disk I/O).
: 
: In any case, there is no pretty way to do this.
: 
: 					Terry Lambert
: 					terry_lambert@gateway.novell.com
: 					terry@icarus.weber.edu
: 
: ---
: Disclaimer:  Any opinions in this posting are my own and not those of
: my present or previous employers.
---
Larry McVoy			(415) 336-7627			 lm@sun.com
Newsgroups: comp.unix.wizards
From: asu@panther4.panther.mot.com (ASU Student)
Subject: Stevens Book/ Passing File descriptors 
Organization: Motorola Panther Project, Chandler, AZ
Date: Thu, 10 Sep 1992 16:13:35 GMT



I've got a few questions for those who have tried the file descriptor
passing example in R. Stevens UNIX Network Programming.  I've been having
problems getting this to work reliably, 
In his example, he had a structure similar to this:

			struct iovec iov;
			iov.iov_base = (char *)0; iov.iov_len = 0;
		
			int fd;	
			struct msghdr msg;
			msg.msg_name = (caddr_t)0; msg.msg_namelen = 0;
			msg.msg_iov = iov; msg.msg_iovlen = 1;
			msg.msg_accrights = &fd; msg.msg_accrightslen = sizeof(int); 

Now my first question...is the msg.msg_iov field required to be non-NULL?
I was trying this:

			msg.msg_iov = (struct iovec *)0; msg.msg_iovlen = 0;

But, it's unclear if this is the problem.   Has anyone tried passing
file descriptors and gotten it to work reliably?  My system is SunOS 4.1.2. 

BTW, when I mean reliably, I mean that sometimes I get garbage messages
with invalid descriptors.  But, the sendmsg()/recvmsg() would return no
error in this case.

Thanks!

Russ
			
Newsgroups: comp.unix.wizards
From: hawkeye@glia.biostr.washington.edu (Ken Keys - TF Dude)
Subject: Re: Stevens Book/ Passing File descriptors 
Organization: University of Washington
Date: Fri, 11 Sep 1992 14:45:22 GMT

In <1992Sep10.161335.26883@panther.mot.com> asu@panther4.panther.mot.com (ASU Student) writes:

>I've got a few questions for those who have tried the file descriptor
>passing example in R. Stevens UNIX Network Programming.  I've been having
>problems getting this to work reliably, 
>In his example, he had a structure similar to this:

>			struct iovec iov;
>			iov.iov_base = (char *)0; iov.iov_len = 0;
>		
>			int fd;	
>			struct msghdr msg;
>			msg.msg_name = (caddr_t)0; msg.msg_namelen = 0;
>			msg.msg_iov = iov; msg.msg_iovlen = 1;

The way you defined iov, that last line should be:
			msg.msg_iov = &iov; msg.msg_iovlen = 1;

>			msg.msg_accrights = &fd; msg.msg_accrightslen = sizeof(int); 

>Now my first question...is the msg.msg_iov field required to be non-NULL?
>I was trying this:

>			msg.msg_iov = (struct iovec *)0; msg.msg_iovlen = 0;

It should be non-null.  If you don't need it, just define a dummy
struct iovec, and use a iovlen of 0.

>But, it's unclear if this is the problem.   Has anyone tried passing
>file descriptors and gotten it to work reliably?  My system is SunOS 4.1.2. 

>BTW, when I mean reliably, I mean that sometimes I get garbage messages
>with invalid descriptors.  But, the sendmsg()/recvmsg() would return no
>error in this case.

Remember that open descriptor passing only works for *open* descriptors.
The descriptor is an index into the process' open file table.  So if you 
give an invalid (e.g., closed) descriptor, it will cause a reference to
an invalid portion of that table.  When passing descriptors like this,
I suggest first passing a flag indicating the success or failure of the
opening procedure.  If the flag indicate sucess, the receiving process
should recvmsg() for the fd; otherwise, it should expect some error
indication (errno would be useful) from the sender.

-- 
--
Ken Keys, aka Hawkeye
Master of the Fugue
kkeys@ucsd.edu or hawkeye@ucsd.edu
Newsgroups: comp.unix.wizards,comp.unix.programmers