Commit graph

255 commits

Author SHA1 Message Date
Andrey A. Chernov 4f5129899a Parse ^? now, our termcap use it and some termcaps from other
systems use it too
1995-05-14 22:29:13 +00:00
Bill Paul 62967ca2b2 Cosmetic changes and paranoia checks:
ypbind.c:
Make fewer assumtions about the state of the dom_alive and dom_broadcasting
flags in roc_received().

If select() fails, use syslog() to report the error rather than perror().

Check that all our malloc()s succeed. Report malloc() failure in
ypbindproc_setdom_2() to callers.

yplib.c:

Use #defined constants in ypbinderr_string() rather than hard-coded values.
1995-05-03 18:33:10 +00:00
Andrey A. Chernov ff17906bc9 Fix bracket error for LogMask
Submitted by: Ruslan Belkin <rus@home2.UA.net>
1995-05-02 17:46:30 +00:00
Joerg Wunsch 85c30cfa12 Added function and man page for ftok(3), used in conjunction with
the so-called "System V IPC".

Submitted by:	jbeukema@HK.Super.Net (John Beukema)
Obtained from:  Th. Lockert <tholo@sigmasoft.com>, via NetBSD
1995-05-01 08:53:21 +00:00
Bill Paul 04adcdacbf Small fix for the following problems:
- If you take the wheel entry out of /etc/group and turn on NIS,
the '+:*::' line is incorrectly flagged as the entry for wheel (the
empty gid section is translated to 0), hence getgrgid() returns '+'
as the name of the group instead of 'wheel.'

- Using just '+:' as the 'turn on NIS' switch in /etc/group makes
getgrgid() dump core because of a null pointer dereference. (Last
time I was in here, I foolishly assumed that fixing the core dump
problems with getgrnam() and getgrent() would fix getgrgid() too.
Silly me.)
1995-04-29 17:14:50 +00:00
Bill Paul 456ebbf8f5 ypbind.c: Major overhaul.
- Moved to a more client-driven model. We aggressively attempt to keep
the default domain bound (as before) but we give up on non-default
domains if we lose contact with a server and fail to get a response
after one round of broadcasting. This helps drastically reduce the
amount of network bandwitdh that ypbind consumes: if a client references
the secondary domain at some later point, this will prod ypbind into
establishing a new binding anyway, so continuously broadcasting without
need is pointless.

Note that we still actively seek out a binding for our default domain
even if no client program has queried us yet. I'm not exactly sure if
this matches SunOS's behavior or not, but I decided to do it this way
since we can get into all sorts of trouble if our default domain comes
unbound. Even so, we're still much quieter than we used to be.

- Removed a bunch of no-longer pertinent comments and a couple of
chunks of #ifdef 0'ed code that no longer fit in to the new layout.

- Theo deRaadt must have become frustrated with the callback mechanism
in clnt_broadcast(), because he shamelessly stole the clnt_broadcast()
code right out of the RPC library and hacked it up to suit his needs.
(Comments and all! :)

I can understand why: clnt_broadcast() blocks while awaiting replies.
Changing this behavior requires surgery. However, you can work around
this: fork the broadcast into a child process and relay the results
back to the parent via a pipe. (Careful obervation has shown that the
SunOS ypbind forks children for broadcasting too, though I can only
guess what sort of interprocess communication it uses. pipe() seems to
do the job well enough.)

This may seem like the long way around, but it's not really that
hard to implement, and I'd prefer to use documented RPC library functions
wherever possible. We're careful to limit the number of simultaneous
broadcasters to avoid swamping the system (the current limit is 5).
Each clnt_broadcast() call only sends out a small number of packets
at increasing intervals. We're also careful not to spawn more than one
bradcaster for a given domain.

- Used clntudp_bufcreate() and clnt_call() to implement a ping()
function for directly querying a particular server so that we can
check if it's still alive. This lets me completely remove the old
bradcasting code and use actual RPC library calls instead, at the
cost of more than a few handfulls of torn-out hair. (Make no mistake
folks: I *HATE* RPC.) Currently, the ping interval is one minute.

- Fixed another potential 'nfds too big for select()' bug: use
_rpc_dtablesize() instead of getdtablesize().

- Quieted gcc -Wall a bit.

- Probably a bunch of other stuff that I've forgotten.

ypbind.8:

- Updated man page to reflect modifications.

ypwhich.c:

- Small mind-o fix from last time: decode error results from
ypbind correctly (*groan*)

yplib.c:

- same as above

- Change behavior of _yp_dobind() a little: if we get back a 'Domain
not bound' error for a given domain, retry a few times before giving
up and passing the error back to the caller. We have to sleep for a
few seconds between tries since the 'Domain not bound' error comes
back immediately (by repeatedly looping, we end up pounding on ypbind).
We retry at most 20 times at 5 second intervals. This gives us a full
minute to get a response. This seems to deviate a bit from SunOS
behavior -- it appears to wait forever -- but I don't like the idea
of perpetually hanging inside a library call.

Note that this should fix the problems some people have with bindings
not being established fast enough at boot time; sometimes amd is started
in /etc/rc after ypbind has run but before it gets a binding set up. The
automounter gets annoyed at this and tends to exit. By pausing ther YP
calls until a binding is ready, we avoid this situation.

- Another _yp_dobind() change: if we determine that our binding files
are unlocked or nonexistent, jump directly to code that pokes ypbind
into restablishing the binding. Again, if it fails, we'll time out
eventually and return.
1995-04-26 19:03:16 +00:00
Bruce Evans a87df1c4d5 Remove setre*id*. 1995-04-25 10:00:04 +00:00
Andrey A. Chernov 045aff38e6 Add setreuid/setregid to MAN section 1995-04-23 15:06:16 +00:00
Andrey A. Chernov b48757c256 Add setreuid/setregid 1995-04-23 12:34:48 +00:00
Andrey A. Chernov c6d8816ea8 Fix history info 1995-04-23 12:31:13 +00:00
Bill Paul 243ae8c754 in _freecaches(): strdup() allocates us memory -- remember to free it. 1995-04-22 17:28:04 +00:00
Bill Paul 644161688b small NIS binding fixes:
ypbind.c: if a client program asks ypbind for the name of the server
for a particular domain, and there isn't a binding for that domain
available yet, ypbind needs to supply a status value along with its
failure message. Set yprespbody.ypbind_error before returning from
a ypbindproc_domain request.

yplib.c: properly handle the error status messages ypbind now has the
ability to send us. Add a ypbinderr_string() function to decode the
error values.

ypwhich.c: handle ypbind errors correctly: yperr_string() can't handle
ypbind_status messages -- use ypbinderr_string instead.
1995-04-21 18:04:36 +00:00
Bruce Evans 55e2b2c608 Fix bugs in opendir():
- it succeeded on non-directories (see POSIX 5.1.2.4).
- it hung on (non-open) named pipes.
- it leaked memory if the second malloc() failed.
- it didn't preserve errno across errors in close().
1995-04-21 15:23:27 +00:00
Andrey A. Chernov db4dc2ff6e If locale not available, fallback to strcasecmp, not to strcmp 1995-04-16 22:43:45 +00:00
Bill Paul 8efe1172e2 Head off potential core dump in _havemaster() (we don't need to free any
memory here: the underlying YP routines handle this one for us).
1995-04-15 03:11:55 +00:00
Bill Paul c98fda6ec8 Better conformance to SunOS behavior: if we can't match a user to one
of the plus or minus lists at all, reject him. This lets you create
a +@netgroup list of users that you want to admit and reject everybody
else. If you end your +@netgroup list with the wildcard line
(+:::::::::) then you'll have a +@netgroup list that remaps the
specified people but leaves people not in any netgroup unaffected.
1995-04-14 14:56:28 +00:00
Garrett Wollman 3688be0eeb Add err_set_file() and err_set_exit() functions to make it possible for
programs which use err(3) to work nicely in a wider range of environments
(e.g., dialog).
1995-04-13 18:04:11 +00:00
Bill Paul 8b4709fa93 Add an ethers(3) man page. 1995-04-12 22:28:49 +00:00
Bill Paul b9729ac259 More of the same: we also need to handle multiple domains properly
even if /var/yp/binding/DOMAIN.VERS doesn't exist yet.
1995-04-09 21:52:31 +00:00
Bill Paul f067dfeabc Fix behavior of YP library routines in environments with multiple domains,
where one or more of the non-default domains are not yet bound.

If we make a YP request for a domain other than the default domain,
and there is no binding for the new domain yet, _yp_dobind() sees
that the /var/yp/binding/DOMAIN.VERS file for the unbound domain is
not locked (by ypbind) and from this it concludes that the NIS system
is dead, so it gives up.

This behavior has been changed: before giving up in this case, we now
make a second check to see if the binding file for the *default* domain
is also not locked. Only if the default domain binding file is also
unlocked to we now assume that ypbind has bought the farm and bail out.
(Note: this assumes that the user hasn't changed the default domain
while ypbind is running.)

With this change, _do_ypbind() is allowed to proceed into the next
section of code wherein it prods ypbind into establishing a binding
for the new domain. This first call times out after ten seconds,
after which it should retry and succeed. From then on, the binding
for the second domain should be handled normally.
1995-04-09 19:26:23 +00:00
Andrey A. Chernov 929fb7fedd Add missing header reference 1995-04-09 04:59:40 +00:00
Bruce Evans 980f2abdb8 Reviewed by: ache and wollman (long ago)
isctype.c:
o The tolower() and toupper() functions duplicated too much code
  and were out of date (surprise).  This didn't matter because
  it was difficult to call them.
o Change formatting to be more like that in <ctype.h> (with
  extra parentheses as in the macros).  Perhaps this file should
  be machine generated or everything should be handled like
  __tolower() so that no code is repeated.

nomacros.c:
o Instead of looking at _USE_CTYPE_INLINE_ to see what <ctype.h>
  has done, set _EXTERNALIZE_CTYPE_INLINES_ to tell <ctype.h>
  what to do, so that we don't have anything left to do.  Note
  that code is now generated even if inlines are used by default.
  This allows users to switch to non-inline versions.
1995-04-07 11:52:17 +00:00
Bruce Evans ffe57f1a20 Obtained from: 1.1.5 (originally by jtc)
Fix printf("%g", 0.0) - print "0", not "0.".  The previous fixes in this
area had one non-cosmetic (non-)change that caused this bug.

Bruce
1995-04-06 16:28:15 +00:00
Joerg Wunsch d108492508 The man page setmode(3) declares `void setmode' when it should be
declared `void *setmode'.

Submitted by:	kargl@troutmask.apl.washington.edu
1995-04-05 22:56:45 +00:00
Andrey A. Chernov ffe8306afd Add "before inclusion of any header which ... "
Suggested by: bde
1995-04-04 11:29:51 +00:00
Bill Paul ef8f52ad53 'Fix' for esoteric misfeature discovered while searching for another bug:
select() returns EINVAL if you try to feed it a value of FD_SETSIZE greater
that 256. You can apparently adjust this by specifying a larger value of
FD_SETSIZE when configuring your kernel. However, if you set the maximum
number of open file descriptors per process to some value greater than
the FD_SETSIZE value that select() expects, many selects() within the RPC
library code will be botched because _rpc_dtablesize() will return
invalid numbers. This is to say that it will return the upper descriptor
table size limit which can be much higher than 256. Unless select() is
prepared to expect this 'unusually' high value, it will fail. (A good
example of this can be seen with NIS enabled: if you type 'unlimit' at
the shell prompt and then run any command that does NIS calls, you'll
be bombarded with errors from clnttcp_create().)

A temporary fix for this is to clamp the value returned by _rpc_dtablesize()
at FD_SETSIZE (as defined in <sys/types.h> (256)). I suppose the Right
Thing would be to provide some mechanism for select() to dynamically
adjust itself to handle FD_SETSIZE values larger than 256, but it's a
bit late in the game for that. Hopefully 256 file descriptors will be enough
to keep RPC happy for now.
1995-04-04 05:53:22 +00:00
Bill Paul 958f4e365d getpwent.c: fix problem with emacs dumping core when NIS is enabled. Also
add #includes for YP headers when compiling with -DYP to avoid some implicit
declarations.

getgrent.c & getnetgrent.c: add some #includes to avoid implicit declarations
of YP functions.
1995-04-04 05:36:16 +00:00
Andrey A. Chernov 05e2ed0de3 Properly describe how to expand default limit of handled descriptors 1995-04-04 01:27:54 +00:00
Bill Paul f9dde4e78c Submitted by: Sebastian Strollow
Obtained from: Casper H. Dik (by vay of Usenet)

Small patch to help improve NIS rebinding times (among other things):


>From: casper@fwi.uva.nl (Casper H.S. Dik)
>Newsgroups: comp.sys.sun.misc,comp.sys.sun.admin
>Subject: FIX for slow rebinding of NIS.
>Summary: a small change in libc makes life with NIS a lot easier.
>Message-ID: <1992Jan17.173905.11727@fwi.uva.nl>
>Date: 17 Jan 92 17:39:05 GMT
>Sender: news@fwi.uva.nl
>Organization: FWI, University of Amsterdam
>Lines: 138
>Nntp-Posting-Host: halo.fwi.uva.nl

Have you been plagued by long waits when your NIS server is rebooted?
READ ON!

Sun has a patch, but the README says:

********************* WARNING ******************************

  This is a new version of ypbind that never uses the NIS
  binding file to cache the servers binding. This will have
  the effect of fixing the current symptom. However, it might
  degrade the overall performance of the system when the
  server is available. This is most likely to happen on an
  overloaded server, which will cause the network to produce
  a broadcast storm.

*************************************************************

Therefor, I have produced another fix.

o What goes wrong.

When the NIS server is rebooted, ypserv will obtain different ports
to listen for RPC requests. All clients will continue to use the old
binding they obtained earlier. The NIS server will send ICMP dst unreachable
messages for the RPC requests that arrive at the old port. These ICMPs
are dropped on the floor and the client code will continue sending the
requests until the timer has expired. The small fix at the end of this
message will pick up these ICMP messages and deliver them to the RPC layer.

o Before and after.

I've tested this on some machines and this is the result:

	(kill and restart ypserv on the server)

original% time ypmatch user passwd
user:....
0.040u 0.090s 2:35.64 0.0% 0+126k 0+0io 0pf+0w (155 seconds elapsed time)

fixedhost% time ypmatch user passwd
user:....
0.050u 0.050s 0:10.20 0.9% 0+136k 0+0io 0pf+0w (10 seconds elapsed time)

Rebinding is almost instantaneous.

o Other benefits.
	RPC calls that use UDP as transport will no longer time out but
	will abort much sooner. (E.g., the remote host is unreachable or
	111/udp is filtered by an intermediate router)
1995-04-02 20:05:20 +00:00
Bill Paul 6cc65caedb Fix xdr_ypmap_parms() so that it agrees with xdr_domainname(), xdr_peername()
and friends.
1995-04-02 19:58:29 +00:00
Andrey A. Chernov b97843726d Fix manpage rule 1995-04-02 19:35:40 +00:00
Bill Paul 7680d1b004 Add ether_addr functions to libc. This seems to be the logical place
to put them. A man page is in the works.
1995-04-02 01:31:17 +00:00
Bill Paul 97fd4ecfb6 Add some missing xdr functions needed for server-side implementations.
(This is to help me reduce yppush a bit: it has its own copy of yp_xdr.c
right now, but I can get rid of it now that this stuff is here.)
1995-04-02 01:02:17 +00:00
Jordan K. Hubbard 6eaef61813 Add the nls code for XPG3-style message catalogs to libc.
Obtained from: NetBSD
1995-03-30 12:47:27 +00:00
Jordan K. Hubbard c7e6130943 Add nls include to Makefile. 1995-03-30 12:46:36 +00:00
Andrey A. Chernov 3437da9391 Clear IGNPAR in cfmakeraw() instead of set it. 1995-03-29 19:28:35 +00:00
Jordan K. Hubbard 71e60921ff Fix a missing _hash() to prevent namespace pollution with the db/hash routines.
Grrr.  If the dbhash routines weren't grossly overengineered I wouldn't
even need to do this! :-(

Also now export the hash_stats routine.  Manpage coming RSN - I promise.
1995-03-28 08:41:02 +00:00
Bill Paul b38bb6d374 Use yp_order() instead of yp_first() in _havemaster() to check for the
presence of the master.passwd.byname map, and remember to free the
returned order value before exiting.
1995-03-27 20:46:40 +00:00
Nate Williams 6fc818e63f Bump the shared library minor # because of the additions of the
strhash() functions.
1995-03-27 20:23:11 +00:00
Andrey A. Chernov d030a0729f Hash 8bit chars without sign extension 1995-03-26 19:32:24 +00:00
Andrey A. Chernov 626da9c8ba Update info about LC_COLLATE implementation 1995-03-26 18:57:19 +00:00
Jordan K. Hubbard 4796867161 Add the strhash family of routines. They provide a number of features
that the db/hash functions don't, and they're much simpler to use for
low-overhead string hashing.
1995-03-26 10:21:55 +00:00
David Greenman eb0bc8709b Updated manual page to indicate flags argument; added return value and
errors section.
1995-03-25 17:24:47 +00:00
Poul-Henning Kamp e169c6670b scandir(3) didn't transfer d_type, and d_ino is called d_fileno now. 1995-03-25 07:39:02 +00:00
Bill Paul f05daed916 Add calls to endgrent() and endnetgrent() to the end of _createcaches(). 1995-03-25 00:30:35 +00:00
Bill Paul 06643071e5 Add more sanity checks. *Lots* of sanity checks. Huge tracts of sanity checks.
Make sure all arguments to the yp_*() functions are valid before sending
them off to the server. This is somewhat distressing: once again my
FreeBSD box brought down my entire network because of NIS bogosities.
I *think* the poor argument checking in this module is the cause, but
I still haven't been able to reproduce the exact series of events that
lead to the ypserv crashes. For now I've resorted to sticking my FreeBSD
box in a seprate domain. Hopefully a weekend of heavy testing will
uncover the problem.
1995-03-24 21:21:37 +00:00
Bill Paul 0ffe27f544 Make sanity checks saner: don't let setnetgrent() or innetgr() swallow
any bogus arguments.
1995-03-24 20:42:28 +00:00
Andrey A. Chernov bee5b8efe8 Change strtok() to strsep(), using strtok() can cause memory corruption
if user program use it too in the same time.
1995-03-24 16:33:44 +00:00
Andrey A. Chernov 3330823cc3 Sicnce this code shares the same fragment as gethostnamaddr:
Change strtok() to strsep(), cause memory corruption for all
programs which use strtok() too in the same time.
Fix potential NULL reference, depends of /etc/hosts.conf format
Fix the bug when service name fetched always from beginning of the line,
not from parsed token.
1995-03-24 15:51:30 +00:00
Andrey A. Chernov 3d1513bdeb Change strtok() to strsep(), cause memory corruption for all
programs which use strtok() too in the same time.
Fix potential NULL reference, depends of /etc/hosts.conf format
Fix the bug when service name fetched always from beginning of the line,
not from parsed token.
1995-03-24 15:38:54 +00:00
Bill Paul 828447008a Yikes! Fix stupid mistake I made in last commit that made getpwent() ignore
local password entries when YP was enabled. (How the heck did that
get by me!?)
1995-03-24 08:01:01 +00:00
Bill Paul d34ef3d62b As per Justin T. Gibbs's request, agument the +@netgroup/-@netgroup
remapping mechanism in the following manner: if given an entry +@foo
and there is no netgroup named 'foo,' try searching for a regular
user group called 'foo' and build the cache using the members of
group 'foo' instead. If both a netgroup 'foo' and a user group 'foo'
exist, the 'foo' netgroup takes precedence, since we're primarily
interested in netgroup matching anyway.

This allows access control schemes based on ordinary user groups
(which are also available via NIS) rather than netgroups, since
netgroups on some systems are limited in really brain-damaged ways.
1995-03-24 05:46:47 +00:00
Bill Paul e17334c329 Don't let yp_match() or yp_next() operate on null or empty keys: asking
ypserv to do a yp_match() with an a null or empty key causes much havok.
(Note that this could be construed as a denial of service attack if used
maliciously.)
1995-03-23 22:23:15 +00:00
Bill Paul 62a771700f Don't let setnetgrent() operate on a null or empty group name: it can
tickle a bug in ypserv and make a serious mess of things.
1995-03-23 22:21:16 +00:00
Bill Paul 353fefe325 Very important sanity checks: today I clobbered all four NIS servers on
my network because setnetgrent() was trying to do a lookup on group "".
It seems that an attempt to do a yp_match() (and possible yp_next())
on a null or empty key causes Sun's ypserv in SunOS 4.1.3 to exit
suddenly (and without warning). Our ypserv behaves badly in this
situation too, thoush it doesn't appear to crash. In any event, getpwent,
getnetgrent and yp_match() and yp_next() are now extra careful not to
accidentally pass on null or empty arguments.

Also made a small change to getpwent.c to allow +::::::::: wildcarding,
which I had disabled previously.
1995-03-23 22:18:00 +00:00
Bill Paul 5f115c9d15 Lots of fixes/improvements in the +user substitution handling:
- Have the +@netgroup/-@netgroup caches handle the +user/-user cases too.
- Clean up getpwent() to take advantage of the improved +user/-user handling.
1995-03-23 17:33:19 +00:00
Bill Paul 89395683ea Small cleanups:
- Prepend a '_' to a couple of things
- Make sure YP is enabled in _createcaches()
- Remove a couple of unused/uneeded variables from _createcaches()
1995-03-23 04:04:01 +00:00
Bill Paul 9531ca9353 Phew! Done at last: getpwent now understands +@netgroup/-@netgroup directives
in addition to the existing NIS substitutions. I may tweak this a bit in
the future, but the important stuff is all here.
1995-03-23 00:59:15 +00:00
Bill Paul 8516cd0fa5 Use better/stronger/faster NIS lookup code: by using yp_match() instead of
the yp_first()/yp_next() combo, we let the database code in ypserv do some
of the work for us.
1995-03-21 19:47:12 +00:00
Bill Paul 2943bd1c53 Reviewed by: Bill Paul <wpaul@freebsd.org>
Submitted by:	Sebastian Strollo <seb@erix.ericsson.se>

- In /usr/src/lib/libc/yp/yplib.c, function yp_first when clnt_call
fails with (r != RPC_SUCCESS) ysd->dom_vers should be set to 0! This
ensures that /var/yp/bindings/dom.vers will be read again on retry.
What happens now is that when our server is down and someone tries to
use yp they will continue to try until kingdom come. So:
        if(r != RPC_SUCCESS) {
                clnt_perror(ysd->dom_client, "yp_first: clnt_call");
                ysd->dom_vers = -1;
                               ^^^^ change to 0
                goto again;
        }
1995-03-21 00:48:55 +00:00
Bill Paul 8538335f21 At last! Modified __ivaliduser() to do the same kind of user/host validation
that everyone else does: you can now use +host/-host, +user,-user and
+@netgroup/-@netgroup in /etc/hosts.equiv, /.rhosts, /etc/hosts.lpd and
~/.rhosts. Previously, __ivaliduser would only do host/user matches,
which was lame. This affects all the r-commands, lpd, and any other
program/service that uses ruserok().

An example of the usefullness of this feature would be a hosts.equiv
file that looks like this:

+@equiv-hosts

Since the netgroup database can now be accessed via NIS, this lets you
set up client machines once and then never have to worry about them
again: all hosts.equiv changes can now be done through NIS. Once I
finish with getpwent.c, we'll be able to do similar wacky things
with login authentication too. (Our password field substitution
will finally be on par with everyone else's, and I'll finally be
able to fully integrate my FreeBSD machine into my network without
having to worry about the grad students sneaking into it when I'm
not looking. :)

Danger Will Robinson! I tested this thing every which way I could, but
Murphy's Law applies! If anybody spots a potential security problem with
the way my matching algorithm works, tell me immediately! I don't want
crackers snickering and calling me names behind my back. :)
1995-03-20 07:29:55 +00:00
Bill Paul e80307946b Whoops: expanding netgroups that reference multiple netgroups doesn't
work because parse_netgrp() doesn't recurse properly. Fixed by
changing

if (parse_netgrp(spos))
	return(1);
to

if (parse_netgrp(spos))
	continue;

inside parse_netgrp(). (Lucky for me I happen to have a fairly complex
'live' netgroup database to test this stuff with.)
1995-03-19 22:19:52 +00:00
Bill Paul 409495f6c7 Two major changes:
- Added support for reading netgroups from NIS/YP in addition to the
local /etc/netgroups file. (Note that SunOS and many other systems only
support reading netgroups via NIS, which is a bit odd.)

- Fix Evil Null Pointer Dereferences From Hell (tm) that caused
parse_netgrp() to SEGV when expanding netgroups that include
references to other netgroups. Funny how nobody else noticed this.

This is the first step in implimenting +@netgroup substitution in
getpwent.c and any other places that could use it and don't already
support it (which is probably everywhere).
1995-03-19 06:16:03 +00:00
Andrey A. Chernov 798563cdfb Fix authunix_maxgrouplist test
Submitted by: Scott Hazen Mueller <scott@zorch.sf-bay.org>
1995-03-18 17:55:03 +00:00
Bill Paul 89047c9c7c Fix 'putting +: in /etc/group causes many programs to dump core' bug
by heading off possible null pointer dereferences in grscan(). Also
change getgrnam() slightly to properly handle the change: if grscan()
returns an rval of 1 and leaves a '+' in the gr_name field and YP is
enabled, poll the YP group.byname map before giving up. This should
insure that we make every effort to find a match in the local and
YP group databases before bailing out.
1995-03-18 05:03:10 +00:00
Bruce Evans 918bed7582 Remove `|| flags & ALT == 0' which was an obscure no-op, not a
parenthesization/precedence bug.
1995-03-12 13:53:51 +00:00
Bruce Evans d26be6f09d Obtained from: 1.1.5. Originally by jtc. Cosmetically changed for this
commit by bde.

Fix bugs in floating point formatting.  The 4.4lite version is similar
to revision 1.3 in old-cvs and is missing all of jtc's fixes in revision
1.4 in old-cvs.  Revision 1.2 in ncvs fixed one of the old bugs but
introduced at least one new one (for %.0e).

old-cvs log:
revision 1.4
date: 1993/11/04 19:38:22;  author: jtc;  state: Exp;  lines: +33 -20
My work from NetBSD to make printf() & friends ANSI C compliant.
Fixes several bugs in floating point formatting:
  1. Trailing zeros were being stripped with %e format.
  2. %g/%G formats incorrect.
  3. Lots of other nits.
1995-03-12 13:26:49 +00:00
Andrey A. Chernov b76cc0f831 stdio.h --> unistd.h 1995-03-09 17:45:23 +00:00
Bruce Evans 553e72d902 Don't build swab.o here. It gets built in libc/i386/string. Previously
the copy built from here was overwritten by the other copy and the other
copy was put in library-building command lines twice.  ld now objects to
duplicated modules.
1995-03-07 04:19:11 +00:00
Joerg Wunsch be7f0d04fe On snap 950210, format %s (print seconds from the epoch) is missing
from the code in strftime.c . This affects both the library code
and all the commands using it (e.g. date +%s).

Note that %s is not required by ANSI, but we've already got it in 1.1.5.1.

Suggested by: luigi@labinfo.iet.unipi.it (Luigi Rizzo)
1995-03-01 23:08:40 +00:00
Bruce Evans 5dddb8148b Don't attempt to lstat() the POSIXLY invalid empty pathname.
realpath() still accepts "" as an arg and converts it to a canonical
pathname for the current directory.
1995-02-25 16:06:07 +00:00
Poul-Henning Kamp 728736c058 Explain the full story, and make it understandable too. 1995-02-25 04:43:20 +00:00
Poul-Henning Kamp 888bbd45f9 fix the synopsis to show
|     void
|    *signal(int sig, void (*func)(int))

instead of

|     void
|     *signal(sig, func())
|
|     void
|     (*func)()
1995-02-24 07:35:49 +00:00
Andrey A. Chernov 977e8ea0c9 Add missing #include <time.h> with time() prototype 1995-02-24 01:02:59 +00:00
Andrey A. Chernov e96a21509f Minor optimization. 1995-02-18 11:36:33 +00:00
Andrey A. Chernov 3d4c9a4bd7 Minor optimization 1995-02-18 01:42:02 +00:00
Andrey A. Chernov 7b7aeeccde Copyrights cleanup 1995-02-18 01:39:00 +00:00
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
Andrey A. Chernov 926f20c973 Don't pick _warn module now 1995-02-17 16:36:12 +00:00
Andreas Schulz 2c0529005c Correct the parameters for the fchown. The third was erroneously
specified as uid_t but should be gid_t.
1995-02-17 00:41:30 +00:00
Andrey A. Chernov a4d5d0cbde Add 8bit collate stuff
Submitted by: alex@elvisti.kiev.ua
1995-02-16 17:01:11 +00:00
Andrey A. Chernov c3d0cca4e9 Add 8-bit collate stuff
Submitted by: alex@elvisti.kiev.ua
1995-02-16 04:24:39 +00:00
Garrett Wollman bae74debca Document Transaction TCP extensions to generic system calls. 1995-02-15 22:53:04 +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
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