From owner-svn-src-all@freebsd.org Fri Dec 22 18:14:57 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 15BD6E811FD; Fri, 22 Dec 2017 18:14:57 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0F431C5A; Fri, 22 Dec 2017 18:14:56 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vBMIEtmQ071795; Fri, 22 Dec 2017 18:14:55 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vBMIEtUL071794; Fri, 22 Dec 2017 18:14:55 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201712221814.vBMIEtUL071794@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Fri, 22 Dec 2017 18:14:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r327090 - stable/11/usr.sbin/pw X-SVN-Group: stable-11 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/11/usr.sbin/pw X-SVN-Commit-Revision: 327090 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Dec 2017 18:14:57 -0000 Author: eugen Date: Fri Dec 22 18:14:55 2017 New Revision: 327090 URL: https://svnweb.freebsd.org/changeset/base/327090 Log: MFC r326872: fix expiration arithmetic after r326738 and MFC. Approved by: mav (mentor) Modified: stable/11/usr.sbin/pw/pw_user.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/pw/pw_user.c ============================================================================== --- stable/11/usr.sbin/pw/pw_user.c Fri Dec 22 17:53:27 2017 (r327089) +++ stable/11/usr.sbin/pw/pw_user.c Fri Dec 22 18:14:55 2017 (r327090) @@ -1383,11 +1383,12 @@ pw_user_add(int argc, char **argv, char *arg1) pwd->pw_uid = pw_uidpolicy(cmdcnf, id); pwd->pw_gid = pw_gidpolicy(cnf, grname, pwd->pw_name, (gid_t) pwd->pw_uid, dryrun); - + + /* cmdcnf->password_days and cmdcnf->expire_days hold unixtime here */ if (cmdcnf->password_days > 0) - pwd->pw_change = now + cmdcnf->password_days * 86400L; + pwd->pw_change = cmdcnf->password_days; if (cmdcnf->expire_days > 0) - pwd->pw_expire = now + cmdcnf->expire_days * 86400L; + pwd->pw_expire = cmdcnf->expire_days; pwd->pw_dir = pw_homepolicy(cmdcnf, homedir, pwd->pw_name); pwd->pw_shell = pw_shellpolicy(cmdcnf); @@ -1521,9 +1522,9 @@ pw_user_mod(int argc, char **argv, char *arg1) bool quiet, createhome, pretty, dryrun, nis, edited; bool precrypted; mode_t homemode = 0; - time_t expire_days, password_days, now; + time_t expire_time, password_time, now; - expire_days = password_days = -1; + expire_time = password_time = -1; gecos = homedir = grname = name = newname = skel = shell =NULL; passwd = NULL; class = nispasswd = NULL; @@ -1559,10 +1560,10 @@ pw_user_mod(int argc, char **argv, char *arg1) homedir = optarg; break; case 'e': - expire_days = parse_date(now, optarg); + expire_time = parse_date(now, optarg); break; case 'p': - password_days = parse_date(now, optarg); + password_time = parse_date(now, optarg); break; case 'g': group_from_name_or_id(optarg); @@ -1697,13 +1698,13 @@ pw_user_mod(int argc, char **argv, char *arg1) } - if (password_days >= 0) { - pwd->pw_change = now + password_days * 86400L; + if (password_time >= 0 && pwd->pw_change != password_time) { + pwd->pw_change = password_time; edited = true; } - if (expire_days >= 0) { - pwd->pw_expire = now + expire_days * 86400L; + if (expire_time >= 0 && pwd->pw_expire != expire_time) { + pwd->pw_expire = expire_time; edited = true; }