diff options
author | sheldonh <sheldonh@FreeBSD.org> | 2002-04-22 16:15:20 +0000 |
---|---|---|
committer | sheldonh <sheldonh@FreeBSD.org> | 2002-04-22 16:15:20 +0000 |
commit | fbe39dfcc2387a913e094ebed61c7f53fe59ee38 (patch) | |
tree | 30fb08f9467b786671737c5383f47fef7a800d4e /contrib/smbfs/lib | |
parent | e408bb58567fc1081f8fefb21b5fc64aac4b8548 (diff) | |
download | FreeBSD-src-fbe39dfcc2387a913e094ebed61c7f53fe59ee38.zip FreeBSD-src-fbe39dfcc2387a913e094ebed61c7f53fe59ee38.tar.gz |
Import smbfs-1.4.4.
Diffstat (limited to 'contrib/smbfs/lib')
-rw-r--r-- | contrib/smbfs/lib/smb/ctx.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/contrib/smbfs/lib/smb/ctx.c b/contrib/smbfs/lib/smb/ctx.c index a934210..588185f 100644 --- a/contrib/smbfs/lib/smb/ctx.c +++ b/contrib/smbfs/lib/smb/ctx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Boris Popov + * Copyright (c) 2000-2002, Boris Popov * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ctx.c,v 1.22 2001/12/26 04:10:52 bp Exp $ + * $Id: ctx.c,v 1.24 2002/04/13 14:35:28 bp Exp $ */ #include <sys/param.h> #include <sys/sysctl.h> @@ -64,7 +64,9 @@ smb_ctx_init(struct smb_ctx *ctx, int argc, char *argv[], 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 @@ smb_ctx_init(struct smb_ctx *ctx, int argc, char *argv[], 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++) { @@ -564,7 +572,7 @@ smb_ctx_gethandle(struct smb_ctx *ctx) char buf[20]; /* - * First try to open as clone + * First, try to open as cloned device */ fd = open("/dev/"NSMB_NAME, O_RDWR); if (fd >= 0) { |