History log of /freebsd-9.3-release/usr.sbin/rpc.yppasswdd/yppasswdd_server.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 267654 19-Jun-2014 gjb

Copy stable/9 to releng/9.3 as part of the 9.3-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 225736 22-Sep-2011 kensmith

Copy head to stable/9 as part of 9.0-RELEASE release cycle.

Approved by: re (implicit)


# 188766 18-Feb-2009 imp

yppasswdd assumed that a struct x_master_passwd is type punable to a
struct passwd. This is not the case when sizeof(unsigned long) !=
sizeof(time_t). Write a dinky function to do the assignment instead
of relying on the punning. This does slow things down a little (1
extra function call, 11 pointer or int assignments), but is much safer
and machines have been fast enough since the mid 1990s that nobody
will notice the difference.

time_t is a 64-bits int on arm and mips. Before this change, arm was
silently broken. I guess there aren't that many ARM machines running
master YP domain servers. :)

The client side doesn't assume this type punning, so it doesn't need
to be fixed.


# 116421 15-Jun-2003 mbr

Fix yppasswdproc_update_master_1_svc() too.

Only call pw_mkdb if passfile == _PATH_MASTERPASSWD.
Otherwise, rename master.passwd to a temp filename, rename
the new passwd to master.passwd, and let yppwupdate update
passwd as it sees fit.

Reviewed by: phk
Tested by: genesys


# 116392 15-Jun-2003 mbr

Only call pw_mkdb if passfile == _PATH_MASTERPASSWD.
Otherwise, rename master.passwd to a temp filename, rename
the new passwd to master.passwd, and let yppwupdate update
passwd as it sees fit.

PR: 52601, 7968
Reviewed by: des
Submitted by: Dan Nelson <dnelson@allantgroup.com>


# 114601 03-May-2003 obrien

Use __FBSDID over rcsid[]. Protect copyright[] where needed.


# 96644 15-May-2002 des

Unbreak Alpha build.


# 96389 11-May-2002 alfred

unbreak build: ditch multi-line string literals


# 96222 08-May-2002 des

Use libutil instead of pw_{copy,util}.c. Clean up a little. Warnsify.

Sponsored by: DARPA, NAI Labs


# 90298 06-Feb-2002 des

ANSIfy and remove some dead code.

Sponsored by: DARPA, NAI Labs


# 90297 06-Feb-2002 des

Apply the following mechanical transformations in preparation for
ansification and constification:

s{\s+__P\((\(.*?\))\)}{$1}g;
s{\(\s+}{\(}g;
s{\s+\)}{\)}g;
s{\s+,}{,}g;
s{(\s+)(for|if|switch|while)\(}{$1$2 \(}g;
s{return ([^\(].*?);}{return ($1);}g;
s{([\w\)])([!=+/\*-]?=)([\w\(+-])}{$1 $2 $3}g;
s{\s+$}{\n};g

Also add $FreeBSD$ where needed.

MFC after: 1 week


# 90253 05-Feb-2002 alfred

Fix the breakage in rpc.yppasswd. Readded the svc_create() and
the registering of the "unix" transport, now it is fixed.

Everywhere, rq_cred is taken to look what authentification we have.
We can not be sure that transp>xp_verf.oa_flavor is also filled in.
This seems to be the same for all sun source. they take the flavor
of rq_cred, instead of transp.

Submitted by: mbr


# 79452 09-Jul-2001 brian

Fix the type of the NULL arg to execl()

Idea from: Theo de Raadt <deraadt@openbsd.org>


# 78369 16-Jun-2001 dd

Correct a typo in an error message.


# 74660 22-Mar-2001 alfred

Remove struct cmessage from sys/socket.h and reintroduce the private
definitions.

Requested by: wollman


# 74657 22-Mar-2001 ache

Unbreak world by removing struct cmessage already define in sys/socket.h


# 50479 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 36639 04-Jun-1998 wpaul

Protect errno in signal handlers, like in portmap.


# 30377 13-Oct-1997 charnier

Remove multiply defined Id string. Hide sccsid string.


# 27758 29-Jul-1997 wpaul

Modify rpc.yppasswdd to use the new AF_LOCAL transport in the RPC library
instead of its own kludged up version. This makes the special 'superuser-only'
update procedure work just like a real RPC service.


# 22997 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 19778 15-Nov-1996 peter

Fix harmless bugs found while hunting for chpass nis failure


# 19138 23-Oct-1996 wpaul

Add extra sanity checking to the in-place update routine. Sometimes you
find two users with the same UID (i.e. root and toor), but yp_mkdb(8)
forbits duplicate keys, so only one of them will end up in the *.byuid
maps (probably toor, since it comes after root in the template file).
If I asked rpc.yppasswdd(8) to change toor's password, it would update
the *.byname maps correctly, but incorrectly modify root's entry in
the *.byuid maps since the only matching record with UID=0 in those
maps belongs to root.

To fix this, we check that both the name and UID are correct before trying
to write new entries to the maps.


# 18047 05-Sep-1996 wpaul

When updating a password via the standard RPC handler, reset the password
change time (pw_change) to zero.


# 17431 04-Aug-1996 wpaul

Fix a couple of bogons. The first two were brought to my attention
by Peter Wemm:

- In yppasswdproc_update_1_svc(), I wasn't paying attention and put
a couple of lines of code _after_ a return() instead of before.
(*blush*)

- The removal of certain temp files didn't always work (this showed
up mostly if you were using /etc/master.passwd as your NIS passwd
template instead of /var/yp/master.passwd). This is because the
whole temp file creation mechanism I was using was tragically
broken (you can't rename across filesystems).

This problem I found myself:

- If you have a very large password database (30,000 or more entries),
there can be a delay of several seconds while pw_copy() copies the
ASCII template file and subsitutes in the modified/new entry. During
this time, the clnt_udp() code in the RPC library may get impatient
and retry its request. This will get queued at the server and be
treated as a second request. By then the password change will have
been completed and the second request will fail (the old password is
no longer valid). To attempt to fix this, we save the IP address and
port of each request and ignore any subsequent requests from the
same IP and same port that arrive within five minutes of each other.


# 16876 01-Jul-1996 guido

Implement incremental passwd database updates. This is done by ading a '-u'
option to pwd_mkdb and adding this option to utilities invoking it.
Further, the filling of both the secure and insecure databases has been
merged into one loop giving also a performance improvemnet.
Note that I did *not* change the adduser command. I don't read perl
(it is a write only language anyway).
The change will drastically improve performance for passwd and
friends with large passwd files. Vipw's performance won't change.
In order to do that some kind of diff should be made between the
old and new master.passwd and depending the amount of changes, an
incremental or complete update of the databases should be agreed
upon.


# 16649 23-Jun-1996 wpaul

Whoops: had a couple of hardcoded instances of '/var/yp/' that shouldn't
have been there. Fixed to use yp_dir, which can be set on the command line.


# 16134 05-Jun-1996 wpaul

Added support for in-place updates:

If rpc.yppasswdd is invoked with the -i flag, password changes will
be made to the master.passwd template file and the hash map files
in-place, which means it won't have to run a complete map update.
Instead, it calls /var/yp/Makefile with the 'pushpw' target, which
just pushes the maps to the slaves and runs yp_mkdb -c to tell the
local ypserv to flush its database cache.

The server will check the passwd.byname and passwd.byuid maps to see
if they were built in 'insecure' or 'secure' mode (i.e. with real
encrypted passwords in them or without) and update them accordingly.

This combined with rpc.ypxfrd greatly reduces the amount of time it
takes to complete an NIS password change, especially with very large
passwd databases.


# 15687 08-May-1996 wpaul

Fix 'multidomain' code. It returns a pointer to memory that it doesn't
really own (and which can end up being mangled later). The manifestation
of this bug is that the first attempt by a user to change their NIS password
succeeds, but all subsequent attempts fail. rpc.yppasswdd also logs
a message about not being able to find a file called
'/var/yp/<some garbage string>/master.passwd.' (Note that for some
bizarre reason, this doesn't happen with the malloc() from FreeBSD 2.1.0.
I suppose this means we can chalk up another victory for phkmalloc. :)

This bug only occurs if you use the -m flag with rpc.yppasswdd.

Fix this by copying the domain name to a static buffer and returning
a pointer to that instead.

Reported by: Jian-Da Li (jdli@csie.nctu.edu.tw)


# 14241 24-Feb-1996 wpaul

Add securenets support (uses same access control mechanism as ypserv,
also controlled by /var/yp/securenets).

Add -u flag to turn off the privileged port check done by yp_access();
some commercial systems (IRIX, Solaris 2.x, HP-UX, and probably others)
don't use a reserved port for submitting yppasswd updates. If we always
enforce the check, these client systems will be unable to submit updates
to us.

Document securenets support and -u flag in man page.

Like ypserv, you can compile rpc.yppasswdd to use the tcpwrapper package
instead of securenets if you want to.


# 14063 12-Feb-1996 wpaul

This commit was generated by cvs2svn to compensate for changes in r14062,
which included commits to RCS files with non-trunk default branches.


# 14062 12-Feb-1996 wpaul

Import new rpc.yppasswdd. (Note: accompanying changes to passwd(1) and
chpass(1) are on the way too.) This version supports all the features
of the old one and adds several new ones:

- Supports real multi-domain operation (optional, can be turned
on with a command-line flag). This means you can actually have
several different domains all served from one NIS server and
allow users in any of the supported domains to change their passwords.
The old yppasswdd only allowed changing passwords in the domain
that was set as the system default domain name on the NIS master
server. The new one can change passwords in any domain by trying
to match the user information passed to it against all the passwd
maps it can find. This is something of a hack, but the yppasswd.x
protocol definiton does not allow for a domain to be passwd as an
argument to rpc.yppasswdd, so the server has no choice but to
grope around for a likely match. Since this method can fail if
the same user exists in two domains, this feature is off by default.
If the feature is turned on and the server becomes confused by
duplicate entries, it will abort the update.

- Does not require NIS client services to be available. NIS servers do
_NOT_ necessarily have to be configured as NIS clients in order to
function: the ypserv, ypxfr and yppush programs I've written recently
will operate fine even if the system domain name isn't set, ypbind isn't
running and there are no magic '+' entries in any of the /etc files.
Now rpc.yppasswdd is the same way. The old yppasswdd would not work
like this because it depended on getpwent(3) and friends to look up
users: this will obviously only work if the system where yppasswdd is
running is configured as an NIS client. The new rpc.yppasswdd doesn't
use getpwent(3) at all: instead it searches through the master.passwd
map databases directly. This also makes it easier for it to handle
multiple domains.

- Allows the superuser on the NIS master server to change any user's
password without requiring password authentication. rpc.yppasswdd
creates a UNIX domain socket (/var/run/ypsock) which it monitors
using the same svc_run() loop used to handle incoming RPC requests.
It also clears all the permission bits for /var/run/ypsock; since
this socket is owned by root, this prevents anyone except root from
successfully connect()ing to it. (Using a UNIX domain socket also
prevents IP spoofing attacks.) By building code into passwd(1) and
chpass(1) to take advantage of this 'trusted' channel, the superuser
can use them to send private requests to rpc.yppasswdd.

- Allows the superuser on the NIS master to use chpass(1) to update _all_
of a user's master.passwd information. The UNIX domain access point
accepts a full master.passwd style structure (along with a domain
name and other information), which allows the superuser to update all
of a user's master.passwd information in the NIS master.passwd maps.
Normal users on NIS clients are still only allowed to change their full
name and shell information with chpass.

- Allows the superuser on the NIS master to _add_ records to the NIS
master.passwd maps using chpass(1). This feature is also switchable
with a command-line flag and is off by default.