From owner-svn-src-head@FreeBSD.ORG Wed Feb 18 22:27:46 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D559910658D6; Wed, 18 Feb 2009 22:27:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A879E8FC22; Wed, 18 Feb 2009 22:27:46 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1IMRk3B076794; Wed, 18 Feb 2009 22:27:46 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1IMRkZ5076793; Wed, 18 Feb 2009 22:27:46 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200902182227.n1IMRkZ5076793@svn.freebsd.org> From: Warner Losh Date: Wed, 18 Feb 2009 22:27:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188766 - head/usr.sbin/rpc.yppasswdd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Feb 2009 22:27:49 -0000 Author: imp Date: Wed Feb 18 22:27:46 2009 New Revision: 188766 URL: http://svn.freebsd.org/changeset/base/188766 Log: 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. Modified: head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c Modified: head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c ============================================================================== --- head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c Wed Feb 18 22:17:48 2009 (r188765) +++ head/usr.sbin/rpc.yppasswdd/yppasswdd_server.c Wed Feb 18 22:27:46 2009 (r188766) @@ -70,6 +70,22 @@ struct dom_binding; static struct passwd yp_password; static void +xlate_passwd(struct x_master_passwd *xpwd, struct passwd *pwd) +{ + pwd->pw_name = xpwd->pw_name; + pwd->pw_passwd = xpwd->pw_passwd; + pwd->pw_uid = xpwd->pw_uid; + pwd->pw_gid = xpwd->pw_gid; + pwd->pw_change = xpwd->pw_change; + pwd->pw_class = xpwd->pw_class; + pwd->pw_gecos = xpwd->pw_gecos; + pwd->pw_dir = xpwd->pw_dir; + pwd->pw_shell = xpwd->pw_shell; + pwd->pw_expire = xpwd->pw_expire; + pwd->pw_fields = xpwd->pw_fields; +} + +static void copy_yp_pass(char *p, int x, int m) { char *t, *s = p; @@ -709,6 +725,7 @@ yppasswdproc_update_master_1_svc(master_ char passfile_hold_buf[MAXPATHLEN + 2]; struct sockaddr_in *rqhost; SVCXPRT *transp; + struct passwd newpasswd; result = 1; transp = rqstp->rq_xprt; @@ -820,7 +837,8 @@ allow additions to be made to the passwo yp_error("pw_tmp() failed"); return &result; } - if (pw_copy(pfd, tfd, (struct passwd *)&argp->newpw, NULL) == -1) { + xlate_passwd(&argp->newpw, &newpasswd); + if (pw_copy(pfd, tfd, &newpasswd, NULL) == -1) { pw_fini(); yp_error("pw_copy() failed"); return &result; @@ -858,8 +876,8 @@ allow additions to be made to the passwo pw_fini(); if (inplace) { - if ((rval = update_inplace((struct passwd *)&argp->newpw, - argp->domain))) { + xlate_passwd(&argp->newpw, &newpasswd); + if ((rval = update_inplace(&newpasswd, argp->domain))) { yp_error("inplace update failed -- rebuilding maps"); } }