Commit Graph

120 Commits

Author SHA1 Message Date
Poul-Henning Kamp
d55ceee7a3 Document the getenv(PWD) feature. 1995-02-05 18:14:38 +00:00
Bill Paul
d66efc62bd Collapsed _masterpw_breakout_yp() and _pw_breakout_yp() into a
single function.
1995-02-05 02:12:49 +00:00
Poul-Henning Kamp
03cfe806a2 A cute hack to speed up things by Keith: if getenv("PWD") is the same
inode as ".", then just return that.  I added a check so it must start with
a '/'.

Reviewed by:	phk
Submitted by:	bostic@cs.berkeley.edu (Keith Bostic)
1995-02-04 19:29:22 +00:00
Bruce Evans
66a96c4ca4 Include <time.h> instead of <sys/time.h> to get CLK_TCK. Including
<sys/time.h> works because <sys/time.h> includes <time.h> if KERNEL
is not defined, but is ugly.
1995-02-03 22:28:34 +00:00
Bruce Evans
711fbb0afc Change CLK_TCK to CLOCKS_PER_SEC.
Add a missing apostrophe that suggests inverting the frequency to get
tick size.  It read better before because `CLK_TCK' suggests a tick
size although it is actually a frequency.
1995-02-03 22:09:56 +00:00
Bruce Evans
3652b5c25d Change CLK_TCK to CLOCKS_PER_SEC. (CLK_TCK is a deprecated POSIX feature
and is not necessarily related to the ANSI CLOCKS_PER_SEC).

Parenthesize macro args.
1995-02-03 21:59:45 +00:00
Bruce Evans
6231933da9 Fix previous change to preserve const'ness. 1995-02-03 21:54:03 +00:00
Bill Paul
a393cc06f5 Fixed a rather serious bug that presents itself when FreeBSD is configured
as an NIS client. The pw_breakout_yp routines that are used to populate the
_pw_passwd structire only do anything if the bits in the pw_fields member
_pw_passwd are cleared. Unfortunately, we can get into a state where
pw_fields has garbage in it right before the YP lookup functions are
called, which causes the breakout functions to screw up in a big way.
Here's how to duplicate the problem:

- Configure FreeBSD as an NIS client
- Log in as a user who's password database records reside only in
  the NIS passwd maps.
- Type ps -aux

Result: your processes appear to be owned by 'root' or 'deamon.'
/bin/ls can exhibit the same problem.

The reason this happens:

- When ps(1) needs to match a username to a UID, it calls getpwuid().

- root is in the local password file, so getpwuid() calls  __hashpw()
  and __hashpw() populates the _pw_passwd struct, including the pw_fields
  member. This happens before NIS lookups take place because, by coincidence,
  ps(1) tends to display processes owned by root before it happens upon
  a proccess owned by you.

- When your UID comes up, __hashpw() fails to find your entry in the
  local password database, so it bails out, BUT THE BITS IN THE pw_fields
  STRUCTURE OF _pw_passwd ARE NEVER CLEARED AND STILL CONTAIN INFORMATION
  FROM THE PREVIOUS CALL TO __hash_pw()!!

- If we have NIS enabled, the NIS lookup functions are called.

- The pw_breakout_yp routines see that the pw_fields bits are set and
  decline to place the data retrieved from the NIS passwd maps into the
  _pw_passwd structure.

- getpwuid() returns the results of the last __hashpw() lookup instead
  of the valid NIS data.

- Hijinxs ensue when user_from_uid() caches this bogus information and
  starts handing out the wrong usernames.

AAAARRRRRRRRRGGGGGGHHHHHHHHHH!!!

*Please* don't tell me I'm the only person to have noticed this.

Fixed by having __hashpw() check the state of pw_fields just before
bailing out on a failed lookup and clearing away any leftover garbage.
What a fun way to spend an afternoon.
1995-02-03 01:09:35 +00:00
Bill Paul
320ce7b758 Fix for that last fix... pass the hat. :) 1995-02-01 20:09:00 +00:00
Bill Paul
c768efa1a8 Small fix to _getyppass(): sometimes we can construct the wrong mapname
when looking for master.passwd.whatever.
1995-02-01 20:06:33 +00:00
Bill Paul
d0ef66889a Some changes for YP password map handling:
- FreeBSD's NIS server can supply a master.passwd map, which has
  more fields in it than a standard passwd map, so we need a
  _master_pw_breakout() fuction.

- When doing passwd map lookups, look for master.passwd.* by attempting
  a _yp_first() on master.passwd.byname. If it exists, we're being served
  by a FreeBSD NIS server and we should use this map.

- If we aren't the superuser, retrieve only the standard passwd maps.
  If we're being served by a FreeBSD system, then the passwd map has
  no passwords in it, and it won't serve us the master.passwd map unless
  we're superuser anyway.

There's a small speed hit for the superuser inherent in the check for
the master.passwd map, but this lets us dynamically decide what to do
rather than rely on a non-standard config file somewhere. Since all
of this is bypassed for normal users, they shouldn't notice the
difference.
1995-01-31 10:04:18 +00:00
David Greenman
cc6f628176 Be sure to properly fail if there are not enough fields. Problem
reported by MARC Giannoni <marc@cmc.eng.comsat.com>, this fix is by me.
1995-01-27 22:30:03 +00:00
Doug Rabson
6de86c13d8 Reclaim memory used for telldir cookies on closedir. 1995-01-27 13:51:18 +00:00
David Greenman
717d9cdd57 First round of changes to clean up the RCSID mess in libc:
1) Changed LIB_SCCS and SYSLIB_SCCS to LIB_RCS and SYSLIB_RCS.
2) Changed sccsid[] variables to rcsid[]
3) Moved all RCSID strings into .text
4) Converted all SCCSID's to RCS $Id$'s
5) Added missing $Id$'s after copyright.
1995-01-23 01:30:24 +00:00
David Greenman
b3c361e217 Changed LIB_SCCS and SYSLIB_SCCS #defines to LIB_RCS and SYSLIB_RCS. 1995-01-23 01:22:08 +00:00
David Greenman
1504cd6172 (Very) minor improvement from NetBSD/J.T.Conklin. 1995-01-22 22:03:45 +00:00
David Greenman
530eb0c1c4 Added leaner and meaner swab() function by J.T. Conklin. 1995-01-22 21:36:15 +00:00
Garrett Wollman
bb38a730ff Fix unbalanced #endif introduced by yesterday's change. 1995-01-19 19:01:50 +00:00
Doug Rabson
2cc220b6ed Fix handling of 'e' format floating point so that it prints trailing zeros
correctly.
1995-01-19 12:05:53 +00:00
Garrett Wollman
c7da24ddb6 Prevent sites from shooting themselves in the foot while enabling/disabling
YP by disallowing `+' entries as logins in all cases.  (This handles the
case of a `+' entry in the password file but YP not running, which should
never happen but is easy enough to check for so we'll apply some
prophylaxis.)
1995-01-17 23:17:38 +00:00
Andreas Schulz
02cb5cc4bf Add the sys/types.h include to the necessary documented includes for the
getrusage call.
1994-12-31 18:50:57 +00:00
Bruce Evans
75b6d64b84 fixunsdfsi.S:
Embalm.  Rewrite to do things much the same as gcc-2: use fistpq for speed
and elegance, and mishandle overflow consistently.  __fixunsdfsi() is no
longer called by gcc.
1994-12-27 13:37:38 +00:00
Bruce Evans
08747772a2 sigsetjmp.S:
Remove unnecessary .text statement.
1994-12-27 13:34:04 +00:00
Bruce Evans
1fe9751525 Remove unnecessary .align statement. 1994-12-27 13:33:03 +00:00
Bruce Evans
be0264b945 Fix a spelling error and add a comment about possible improvements. 1994-12-27 13:12:34 +00:00
Bruce Evans
6424ff77c2 Fix the bug reported by Torbjorn Granlund <tege@cygnus.com>:
The documentation for mrand48 and lrand48 is mixed up.
mrand48 returns a full 32 bit number, while lrand48 only returns
31 bits.
1994-12-25 15:33:39 +00:00
Guido van Rooij
4e32be0fb7 Add missing getdomainname manual page.
Reviewed by:
Submitted by:
Obtained from: 1.1.5.1 with a few modifictaions.
1994-12-18 14:06:39 +00:00
Bruce Evans
b01f0b7d76 Obtained from: 1.1.5
getcwd() has two off-by-one bugs in FreeBSD-2.0:

1. getcwd(buf, size) fails when the size is just large enough.
2. getcwd(buf + 1, 1) incorrectly succeeds when the current directory
   is "/".  buf[0] and buf[2] are clobbered.

(I modified Bruce's original patch to return the proper error code
[ERANGE] in the case of #2, but otherwise... -DG)

This program demonstrates the bug:

---
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>

int main(void)
{
    char buf[5];
    int errors;

    errors = 0;
    if (chdir("/tmp") != 0) {
        perror("chdir");
        abort();
    }
    if (getcwd(buf, 5) == NULL) {
        perror("oops, getcwd failed for buffer size = size required");
        ++errors;
    }
    if (chdir("/") != 0) {
        perror("chdir");
        abort();
    }
    buf[0] = 0;
    buf[2] = 1;
    if (getcwd(buf + 1, 1) != NULL) {
        fprintf(stderr,
                "oops, getcwd succeeded for buffer size = one too small\n");
        ++errors;
    }
    if (buf[0] != 0) {
        fprintf(stderr,
                "oops, getcwd scribbled on memory before start of buffer\n");
        ++errors;
    }
    if (buf[2] != 1) {
        fprintf(stderr,
                "oops, getcwd scribbled on memory after end of buffer\n");
        ++errors;
    }
    exit(errors == 0 ? 0 : 1);
}
1994-12-12 01:29:13 +00:00
Bruce Evans
a0d0470f49 Obtained from: 386BSD-0.1 patchkit; also fixed in 1.1.5
Compare unsigned chars.
Return the place after where the character was found and not the start
of the string.
1994-12-12 01:23:33 +00:00
Bruce Evans
a2c0622293 Fix execl[e]. Multiple execle's failed because of bogus caching of the
pointer returned by realloc().  All callers free the pointer if the
execve fails.  Nuke the caching.  This essentially restores buildargv()
to the 1.1.5 version.  Also fix a memory leak if realloc() fails.  Also
nuke similar but non-broken caching in execvp().  malloc() should be
efficient enough.
1994-12-12 01:15:01 +00:00
Andreas Schulz
3cefada244 Comment out the man page of rstat.1 from Makefile.inc. There is no rstat
command available yet.
Changed an entry in getprcent.3 from rpcinfo(8C) to rpcinfo(8).
Changed an entry in getrpcport.3 from 3R to 3.
Changed two entries in rpc.3 from 3N to 3.
1994-12-11 22:08:10 +00:00
Andreas Schulz
75f0ecb284 Added the mpool.3 manpage to the installed manpages. It is referred from the
other manpages and there is no conflict.
1994-12-11 22:03:05 +00:00
Garrett Wollman
40569757cc In _gethostbydnsaddr(), force RES_RECURSE into _res.options. This is
incredibly obnoxious, but also makes inverse mappings work when the local
resolver is in a cache-only configuration.  (Maybe this is actually
a bug in BIND?)
1994-12-01 22:25:38 +00:00
David Greenman
7e20f2848c Go back to Bruce's fix with a minor change that will allow a NULL string
pointer if len is 0. I should have looked at the revision history - I would
have found that Bruce already fixed the bug with len=0 over a month ago.
Whoever said that the bug was in 2.0 was wrong.
1994-11-25 08:58:53 +00:00
David Greenman
40598ff428 Fixed bugs related to returning NULL if length is zero. 1994-11-25 04:11:19 +00:00
Doug Rabson
72012b54d0 Added sysarch system call which is used my i386_get/set_ltd.c and is needed
for Wine support.  The current snapshot of wine works fine with this.

This should go into the beta as the code which it calls in the kernel is
already there, and works fine.
1994-11-17 10:50:55 +00:00
Poul-Henning Kamp
2a7b3781fc Added routines to read the canonical UNIX configuration file. This will
later be applied to a number of programs (inetd for instance) to clean
out the bogus code doing the same thing, modulus all the bugs.

If you need to read a '#'-is-a-comment-file, please use these routines.

I realize that the shlib# should be bumped (for the non-US world:
increased by something), but will defer this until something significant
happens.
1994-11-13 20:47:44 +00:00
Nate Williams
692a99c012 Date: Wed, 26 Oct 1994 15:44:49 -0600
From: Chris Torek <torek@bsdi.com>
Here is a semi-official patch (apply to /usr/src/lib/libc/stdio/fseek.c,
rebuild libc, install).  The current code fails when the seek:

  - is optimized, and
  - is to just past the end of the block currently in the buffer, and
  - is followed by another seek with no intervening read operation, and
  - the destination of subsequent seek is within the block left in the
    buffer (seeking to the beginning of a block does not force a read,
    so the buffer still contains the previous block)

so it is indeed rather obscure.

I may have a different `final' fix, as this one `loses' the buffer
contents on a seek that goes just past the end of the current block.

[Footnote: seeks are optimized only on read-only opens of regular
files that are buffered by the file's optimal I/O size.  This is
what you get with fopen(path, "r") and no call to setvbuf().]

Obtained from: [ BSDI mailing list ]
1994-11-05 18:49:34 +00:00
Rodney W. Grimes
3573df98f1 >Description:
While trying to figure out why rlogind wasn't working right for root,
	I noticed that man wouldn't come back with a man page for iruserok, but
	it would for ruserok.  Checking the lib/net directory's Makefile.inc
	file shows that the link to the rcmd man page just isn't getting
	created.
>How-To-Repeat:
	Do a 'man iruserok' and notihing will come back, where a 'man ruserok'
	will.

Submitted by:	Brian Moore <ziff@houdini.eecs.umich.edu>
Obtained from:	NetBSD-bugs mailing list
1994-10-27 16:33:49 +00:00
Bruce Evans
b5281b4b2a Fix memchr(p, 0, 0) to return NULL instead of p. 1994-10-27 11:36:11 +00:00
Bruce Evans
1a4206dd85 Reenable sigsetjmp.S. Preserve the FP state. Rearrange offsets
to match setjmp.S.
1994-10-25 14:08:13 +00:00
Bruce Evans
2ff9d55483 Nuke sigsetjmp.c. sigsetjmp() can't be implemented as a C function
that calls setjmp(), since returning from the function usually
clobbers the saved environment.
1994-10-25 14:04:32 +00:00
Andrey A. Chernov
780bd8bd41 cfmakeraw(): set IGNBRK, clear IXOFF, INPCK per Bruce suggestion
Set IGNPAR, clear NOFLSH, PENDIN, TOSTOP, ECHOE, ECHOK
1994-10-22 18:12:17 +00:00
Andrey A. Chernov
4ceeaa06a8 makeraw(): forget to clear IMAXBEL, set VMIN/VTIME 1994-10-22 01:49:27 +00:00
Andrey A. Chernov
37b28ca421 Remove CPU_COLORDISP, GIO_COLOR now exists 1994-10-18 03:42:18 +00:00
Andrey A. Chernov
fb46136e56 Add new machdep variables 1994-10-17 20:50:41 +00:00
Garrett Wollman
b938dc2407 sysctl(3) can return an error (setting errno to ENOMEM) when the
fields in the utsname structure are too small to hold their
corresponding MIB variables.  Don't return an error in this case.
1994-10-13 20:31:19 +00:00
Andrey A. Chernov
bac719f599 Sync with ctype.h (remove EOF handling) 1994-10-09 11:20:55 +00:00
Andrey A. Chernov
4c02aebe2f Sync with ctype.h (EOF, sign extention fixes) 1994-10-08 17:42:45 +00:00
Garrett Wollman
f64c928f58 Use same configuration file, /etc/host.conf, for both gethost* and
getnet* configuration.  (It's highly unlikely that you'd want to do
something different, and network lookups aren't common enough to justify
their own configuration file.)
1994-09-26 22:45:10 +00:00