From owner-freebsd-bugs Mon Mar 18 0:51:14 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B39CE37B4A5 for ; Mon, 18 Mar 2002 00:50:05 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2I8o1V97173; Mon, 18 Mar 2002 00:50:01 -0800 (PST) (envelope-from gnats) Received: from descent.robbins.dropbear.id.au (060.c.001.mel.iprimus.net.au [203.134.131.60]) by hub.freebsd.org (Postfix) with ESMTP id 5DAE437B404 for ; Mon, 18 Mar 2002 00:47:50 -0800 (PST) Received: (from tim@localhost) by descent.robbins.dropbear.id.au (8.11.6/8.11.6) id g2I8kgg04914; Mon, 18 Mar 2002 19:46:42 +1100 (EST) (envelope-from tim) Message-Id: <200203180846.g2I8kgg04914@descent.robbins.dropbear.id.au> Date: Mon, 18 Mar 2002 19:46:42 +1100 (EST) From: "Tim J. Robbins" Reply-To: "Tim J. Robbins" To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/36041: mount_smbfs can't cope without password database Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36041 >Category: bin >Synopsis: mount_smbfs can't cope without password database >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Mar 18 00:50:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Tim J. Robbins >Release: FreeBSD 4.5-STABLE i386 >Organization: >Environment: System: FreeBSD descent.robbins.dropbear.id.au 4.5-STABLE FreeBSD 4.5-STABLE #7: Mon Mar 18 16:43:16 EST 2002 tim@descent.robbins.dropbear.id.au:/usr/obj/usr/src/sys/DESCENT i386 >Description: mount_smbfs assumes an entry for the current effective user id exists in the password database, and proceeds to deference a NULL pointer if there is not one. This stops mount_smbfs working from an install disk without password databases and is also sloppy coding practice. >How-To-Repeat: Try to use mount_smbfs without a password database, or check ctx.c. Credit goes to David Yeske for discovering this bug. >Fix: This patch causes it to fail gracefully if there isn't a password database entry for the current user. The superuser is a special case, and it uses the name "root" when an entry does not exist. Index: ctx.c =================================================================== RCS file: /home/ncvs/src/contrib/smbfs/lib/smb/ctx.c,v retrieving revision 1.1.1.2 diff -u -r1.1.1.2 ctx.c --- ctx.c 2001/12/26 15:35:09 1.1.1.2 +++ ctx.c 2002/03/18 08:35:45 @@ -64,7 +64,9 @@ int minlevel, int maxlevel, int sharetype) { int opt, error = 0; + uid_t euid; const char *arg, *cp; + struct passwd *pwd; bzero(ctx,sizeof(*ctx)); error = nb_ctx_create(&ctx->ct_nb); @@ -92,8 +94,14 @@ ctx->ct_sh.ioc_group = SMBM_ANY_GROUP; nb_ctx_setscope(ctx->ct_nb, ""); - smb_ctx_setuser(ctx, getpwuid(geteuid())->pw_name); - endpwent(); + euid = geteuid(); + if ((pwd = getpwuid(euid)) != NULL) { + smb_ctx_setuser(ctx, pwd->pw_name); + endpwent(); + } else if (euid == 0) + smb_ctx_setuser(ctx, "root"); + else + return 0; if (argv == NULL) return 0; for (opt = 1; opt < argc; opt++) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message