Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Mar 2002 19:46:42 +1100 (EST)
From:      "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/36041: mount_smbfs can't cope without password database
Message-ID:  <200203180846.g2I8kgg04914@descent.robbins.dropbear.id.au>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203180846.g2I8kgg04914>