Commit Graph

859 Commits

Author SHA1 Message Date
Stefan Eßer
b5fd1704b2 Bruce pointed out, that a misleading warning would be issued
in an (unlikely) border case (maxgroups==1 and the user is on
an /etc/group line for the same group and that group only ...).

Now this case is dealt with as before ...
1995-02-17 19:45:21 +00:00
Stefan Eßer
f067e922a9 Protect against duplicate gids in group list (as could be the
result of being a member of some group in both /etc/group and YP).
1995-02-17 17:36:09 +00:00
David Greenman
16be381004 Backed out Keith Bostic's getcwd/$PWD hack. It is causing things to break
all over the place.
1995-02-07 05:52:57 +00:00
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
Garrett Wollman
bb38a730ff Fix unbalanced #endif introduced by yesterday's change. 1995-01-19 19:01:50 +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
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
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
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
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
Garrett Wollman
d3ae7f1266 Document getvfsent() and kin. 1994-09-25 01:38:30 +00:00
Garrett Wollman
07ef895025 Fix so that people who don't have LKMs compiled in their kernels don't
get hosed: vfsisloadable() always returns false if /dev/lkm cannot be
opened for writing.
1994-09-25 00:48:27 +00:00
David Greenman
89730b290a Added $Id$ 1994-09-24 02:59:15 +00:00
Garrett Wollman
a2647fcdec If sysctl() fails, return "/kernel" so as not to screw people who haven't
updated their kernels yet.
1994-09-24 00:10:13 +00:00
Garrett Wollman
53d733f050 Added getbootfile(3), for an easy C interface to the kern.bootfile MIB
variable.  This one's even documented!
1994-09-23 20:22:01 +00:00
Garrett Wollman
4b4b7d0556 Added *ran48 functions, and put them in the correct place this time.
Obtained from:	1.1.5
1994-09-23 00:37:55 +00:00
Garrett Wollman
d5ebbcdf85 Pass -q and -u flags to modload so that it shuts up and doesn't leave
modules lying around.
1994-09-22 22:36:57 +00:00
Garrett Wollman
5ba34297b9 Fix stupid memory-allocation error. 1994-09-22 02:17:26 +00:00
Garrett Wollman
8e2331ca34 Added VFS functions: getvfsvbyname, getvfsbytype, getvfsent, setvfsent,
endvfsent, vfsisloadable, vfsload.
Someday these will even be documented.
1994-09-22 01:07:37 +00:00
Garrett Wollman
6af9798fed Document YP support. 1994-09-20 22:02:20 +00:00
Garrett Wollman
9486c394b4 My implementation of YP group file support, modeled after the
password file support done yesterday.
1994-09-20 21:43:27 +00:00
Garrett Wollman
468bb86a7d Second half of YP security hole fix. Needs updated password
database in order to operate.
1994-09-20 21:42:12 +00:00
Garrett Wollman
d5b7518d9c Re-implement YP password file support from scratch. This implementation
correctly handles +user entries and + entries with local overrides.
1994-09-20 01:23:45 +00:00
Garrett Wollman
28ca30918a Maintain pw_fields, and output same to password database.
!!!!!!!!
NB
!!!!!!!!
You MUST pwd_mkdb /etc/master.passwd before attempting to use the new
libc, or things may go wrong.  (I doubt anything actually /will/ go
wrong, but the actual behavior is undefined.  YOU HAVE BEEN WARNED.)
The database format is, however, backwards-compatible, so old executables
will still work.
1994-09-20 01:15:08 +00:00
Andrey A. Chernov
0b00772e37 Function in this module bloodly called 'gethostname' and linked
with all pgms, you can imagine results!
Change 'gethostname' -> 'ntp_gettime', I don't know what real name
must be here but try to guess.
1994-09-19 22:04:28 +00:00
Garrett Wollman
69f5174d9a Redo kernel NTP PLL support, user-mode interface. 1994-09-18 20:29:55 +00:00
Garrett Wollman
a040910f9b Use latest Arthur Olson timezone code rather than that supplied with
4.4.  The code is almost identical to the 4.4 versions, but this organization
should make it easier to merge new versions in the future.
1994-09-13 21:26:08 +00:00
Doug Rabson
5b65bca24e Added SYSV ipc system calls. 1994-09-13 14:52:45 +00:00
Geoff Rehmet
49f037bca9 document libcrypt and libcipher.
Submitted by:	Geoff
1994-09-08 19:46:57 +00:00
Jordan K. Hubbard
2d4ee3eaf6 Make errors in /etc/fstab print the line numbers where they occured.
Also be more tolerant of blank lines and comments in the file.
Submitted by:	jkh
1994-09-08 09:21:00 +00:00
Garrett Wollman
01697c8ddb Oops, forgot to cvs add this file. 1994-08-10 06:27:35 +00:00
Garrett Wollman
9ae159169a Make it easier for programs to figure out what revision of FreeBSD they
are running under.  Here's how to bootstrap (order is important):

1) Re-compile gcc (just the driver is all you need).
2) Re-compile libc.
3) Re-compile your kernel.  Reboot.
4) cd /usr/src/include; make install

You can now detect the compilation environment with the following code:

#if !defined(__FreeBSD__)
#define __FreeBSD_version 199401
#elif __FreeBSD__ == 1
#define __FreeBSD_version 199405
#else
#include <osreldate.h>
#endif

You can determine the run-time environment by calling the new C library
function getosreldate(), or by examining the MIB variable kern.osreldate.

For the time being, the release date is defined as 199409, which we have
already established as our target.
1994-08-10 06:25:07 +00:00
Jordan K. Hubbard
b10e56dadd Add a missing backslash to get this to work again.
Reviewed by:
Submitted by:	jkh
1994-08-08 15:17:41 +00:00
Garrett Wollman
2e18dcd969 Added YP domain name getting/setting support, for SunOS/old program
compatibility.
1994-08-08 00:40:24 +00:00
Garrett Wollman
2ceb2ce9ee First crack at making libc work with the new make macros. It compiles on
my machine, and a simple static (genassym) and shared (sysctl) executable
both work.  Still to be done: RPCand YP merge.
1994-08-05 01:19:12 +00:00
Geoff Rehmet
1f80968a0b Rewrite nlist to mmap the whole a.out file (at Davidg's suggestion).
This means that we don't have to do rounding calculations for page
boundaries.  (We do all our accesses via the mmapped area now.)
Reviewed by:
1994-07-22 12:22:51 +00:00
Rodney W. Grimes
58f0484fa2 BSD 4.4 Lite Lib Sources 1994-05-27 05:00:24 +00:00
Rodney W. Grimes
4b88c807ea BSD 4.4 Lite bin Sources 1994-05-26 06:18:55 +00:00
Rodney W. Grimes
dea673e932 BSD 4.4 Lite usr.sbin Sources 1994-05-26 05:23:31 +00:00
Rodney W. Grimes
59deaec541 BSD 4.4 Lite Include Sources 1994-05-24 09:57:34 +00:00