From owner-freebsd-stable@FreeBSD.ORG Wed Jun 16 13:55:04 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D9F5D16A4CE; Wed, 16 Jun 2004 13:55:04 +0000 (GMT) Received: from mail.teledes.ru (host241-net53-vved7.miran.ru [213.221.53.241]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1F19143D46; Wed, 16 Jun 2004 13:54:59 +0000 (GMT) (envelope-from DAntrushin@mail.ru) Received: from [10.1.1.31] ([10.1.1.31]) (authenticated bits=0) by mail.teledes.ru (8.12.11/8.12.11) with ESMTP id i5GDnG4s029513; Wed, 16 Jun 2004 17:49:17 +0400 (MSD) Message-ID: <40D050B4.2070907@mail.ru> Date: Wed, 16 Jun 2004 17:52:52 +0400 From: Denis Antrushin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040609 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Richard Caley References: <200406160912.i5G9CoDe059562@pele.r.caley.org.uk> In-Reply-To: <200406160912.i5G9CoDe059562@pele.r.caley.org.uk> Content-Type: multipart/mixed; boundary="------------020900000207070408050305" cc: freebsd-current@freebsd.org cc: freebsd-stable@freebsd.org Subject: Re: Bug in PW X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jun 2004 13:55:05 -0000 This is a multi-part message in MIME format. --------------020900000207070408050305 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Richard Caley wrote: > I thin this exists in both -STABLE and -CURRENT, but I don't have a > bang up to date instalation of either, so appologies if it has been > fixed. No, it still present in current version (pw_user.c, as of ver. 1.55) > Tested on 5.2.1 and 4.8. may have some security implications in that > someone may think they have changed a shell (eg to /nonexistant) but > they haven't really. > > Apparently, supplying -d EXITING_HOME_DIR stops -s from setting the > shell. Well, it cause some other option to work as well. :-) This is because 'edited' flags which shows whether something has changed is set this way in -d option handling: edited = strcmp(pwd->pw_dir, arg->val) != 0; so it sets 'edited' to false, if home directory not changed regardless of its previous value. Attached patch should fix this bug (untested) --------------020900000207070408050305 Content-Type: text/plain; name="pw_user.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="pw_user.diff" *** pw_user.c Wed Jun 16 17:38:22 2004 --- pw_user.c.new Wed Jun 16 17:41:37 2004 *************** *** 537,543 **** } if ((arg = getarg(args, 'd')) != NULL) { ! edited = strcmp(pwd->pw_dir, arg->val) != 0; if (stat(pwd->pw_dir = arg->val, &st) == -1) { if (getarg(args, 'm') == NULL && strcmp(pwd->pw_dir, "/nonexistent") != 0) warnx("WARNING: home `%s' does not exist", pwd->pw_dir); --- 537,544 ---- } if ((arg = getarg(args, 'd')) != NULL) { ! if (strcmp(pwd->pw_dir, arg->val) != 0) ! edited = 1; if (stat(pwd->pw_dir = arg->val, &st) == -1) { if (getarg(args, 'm') == NULL && strcmp(pwd->pw_dir, "/nonexistent") != 0) warnx("WARNING: home `%s' does not exist", pwd->pw_dir); --------------020900000207070408050305--