From fbe39dfcc2387a913e094ebed61c7f53fe59ee38 Mon Sep 17 00:00:00 2001 From: sheldonh Date: Mon, 22 Apr 2002 16:15:20 +0000 Subject: [PATCH] Import smbfs-1.4.4. --- contrib/smbfs/CREDITS | 1 + contrib/smbfs/HISTORY | 7 +- contrib/smbfs/Makefile.inc | 4 +- contrib/smbfs/examples/dot.nsmbrc | 7 +- contrib/smbfs/lib/smb/ctx.c | 18 +++-- contrib/smbfs/mount_smbfs/mount_smbfs.8 | 79 ++++++++++---------- contrib/smbfs/mount_smbfs/mount_smbfs.c | 4 +- contrib/smbfs/smbutil/smbutil.1 | 99 ++++++++++++++----------- contrib/smbfs/smbutil/view.c | 18 +++-- 9 files changed, 135 insertions(+), 102 deletions(-) diff --git a/contrib/smbfs/CREDITS b/contrib/smbfs/CREDITS index e9228afccf31..9d2431bf04b6 100644 --- a/contrib/smbfs/CREDITS +++ b/contrib/smbfs/CREDITS @@ -2,6 +2,7 @@ In the development process next sources were used: Various documents from the Microsoft ftp site. + HTML docs published by Thursby Software. Special thanks to the Samba team for permission to use their source diff --git a/contrib/smbfs/HISTORY b/contrib/smbfs/HISTORY index 1395345f88b8..4de0e7b17291 100644 --- a/contrib/smbfs/HISTORY +++ b/contrib/smbfs/HISTORY @@ -1,4 +1,9 @@ -26.12.2001 1.4.3 +16.04.2002 1.4.4 + - Workaround for W2K bug in resource listing. + - Minor bug fixes. + - Manual pages updated. Thanks to Ruslan Ermilov. + +26.12.2001 1.4.3 (interim) - Additional cleanups for FreeBSD builds. - Charset specifications now accepted in the [default] section. diff --git a/contrib/smbfs/Makefile.inc b/contrib/smbfs/Makefile.inc index d83356e7a0c7..643c9754e849 100644 --- a/contrib/smbfs/Makefile.inc +++ b/contrib/smbfs/Makefile.inc @@ -1,4 +1,4 @@ -# $Id: Makefile.inc,v 1.10 2001/05/03 10:05:47 bp Exp $ +# $Id: Makefile.inc,v 1.11 2002/04/16 02:57:46 bp Exp $ .ifmake !clean && !cleandepend .if !defined(PREFIX) @@ -26,6 +26,8 @@ CFLAGS += -I../kernel CFLAGS += -I${SYSDIR} .endif +CFLAGS += -I../include + .if defined(SMBGDB) CFLAGS+= -ggdb .endif diff --git a/contrib/smbfs/examples/dot.nsmbrc b/contrib/smbfs/examples/dot.nsmbrc index b630fa8bda40..052c718646f3 100644 --- a/contrib/smbfs/examples/dot.nsmbrc +++ b/contrib/smbfs/examples/dot.nsmbrc @@ -1,4 +1,4 @@ -# $Id: dot.nsmbrc,v 1.6 2000/07/16 01:52:06 bp Exp $ +# $Id: dot.nsmbrc,v 1.7 2002/04/10 04:21:11 bp Exp $ # # Example for .nsmbrc file # @@ -20,7 +20,8 @@ # where 'key' represents parameter name and 'value' a value assigned # to this parameter. # -# SMB library uses next forms of section names: +# SMB library uses next forms of section names (please note that the section +# name should be in upper case when it refers to server, user or share): # A) [default] # B) [SERVER] # C) [SERVER:USER] @@ -31,7 +32,7 @@ # keyword/section A B C D Comment # # addr - + - - IP or IPX address of SMB server -# charsets - + + + local:remote charset pair +# charsets + + + + local:remote charset pair # nbns + + - - address of NetBIOS name server (WINS) # nbscope + + - - NetBIOS scope # nbtimeout + + - - timeout for NetBIOS name servers diff --git a/contrib/smbfs/lib/smb/ctx.c b/contrib/smbfs/lib/smb/ctx.c index a9342105fc57..588185f99452 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 #include @@ -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) { diff --git a/contrib/smbfs/mount_smbfs/mount_smbfs.8 b/contrib/smbfs/mount_smbfs/mount_smbfs.8 index 4a522595603d..ba69b39fd9fa 100644 --- a/contrib/smbfs/mount_smbfs/mount_smbfs.8 +++ b/contrib/smbfs/mount_smbfs/mount_smbfs.8 @@ -1,18 +1,18 @@ -.\" $Id: mount_smbfs.8,v 1.9 2001/12/20 15:11:45 bp Exp $ -.Dd Mar 10, 2000 +.\" $Id: mount_smbfs.8,v 1.10 2002/04/16 02:47:41 bp Exp $ +.Dd March 10, 2000 .Dt MOUNT_SMBFS 8 -.Os FreeBSD +.Os .Sh NAME .Nm mount_smbfs -.Nd mounts a shared resource from an SMB file server +.Nd "mount a shared resource from an SMB file server" .Sh SYNOPSIS -.Nm mount_smbfs -.Op Fl E Ar cs1:cs2 +.Nm +.Op Fl E Ar cs1 : Ns Ar cs2 .Op Fl I Ar host .Op Fl L Ar locale -.Op Fl M Ar crights:srights +.Op Fl M Ar crights : Ns Ar srights .Op Fl N -.Op Fl O Ar cowner:cgroup/sowner:sgroup +.Op Fl O Ar cowner : Ns Ar cgroup Ns / Ns Ar sowner : Ns Ar sgroup .Op Fl R Ar retrycount .Op Fl T Ar timeout .Op Fl W Ar workgroup @@ -22,20 +22,22 @@ .Op Fl g Ar gid .Op Fl n Ar opt .Op Fl u Ar uid -.Ar //user@server/share +.Sm off +.No // Ar user No @ Ar server No / Ar share +.Sm on .Ar node .Sh DESCRIPTION The .Nm command mounts a share from a remote server using SMB/CIFS protocol. .Pp -The options are: +The options are as follows: .Bl -tag -width indent -.It Fl E Ar cs1:cs2 +.It Fl E Ar cs1 : Ns Ar cs2 Specifies local -.Ar (cs1) +.Pq Ar cs1 and server's -.Ar (cs2) +.Pq Ar cs2 character sets. .It Fl I Ar host Do not use NetBIOS name resolver and connect directly to @@ -46,12 +48,12 @@ Use .Ar locale for lower/upper case conversion routines. Set the locale for case conversion. -By default +By default, .Nm tries to use an environment variable -.Ev LC_* +.Ev LC_* to determine it. -.It Fl M Ar crights:srights +.It Fl M Ar crights : Ns Ar srights Assign access rights to the newly created connection. See .Xr nsmb 8 @@ -63,10 +65,10 @@ At run time, reads the .Pa ~/.nsmbrc file for additional configuration parameters and a password. -If no password is found the +If no password is found, .Nm prompts for it. -.It Fl O Ar cowner:cgroup/sowner:sgroup +.It Fl O Ar cowner : Ns Ar cgroup Ns / Ns Ar sowner : Ns Ar sgroup Assign owner/group attributes to the newly created connection. See .Xr nsmb 8 @@ -80,34 +82,34 @@ Timeout in seconds for each request. This option specifies the workgroup to be used in the authentication request. .It Fl c Ar case Set a -.Ar case +.Ar case option which affects name representation. -.Ar case +.Ar case can be one of the following: -.Bl -tag -width "ValueXX" +.Bl -tag -width ".Em Value" .It Em Value .Em Meaning -.It l -All existing file names converted to lower case. +.It Cm l +All existing file names are converted to lower case. Newly created file gets a lower case. -.It u -All existing file names converted to upper case. -Newly created file gets an upper case unde. +.It Cm u +All existing file names are converted to upper case. +Newly created file gets an upper case. .El .It Fl f Ar mode , Fl d Ar mode Specify permissions that should be assigned to files and directories. The values must be specified as octal numbers. Default value for the file mode -is taken from mount point, default value for the dir mode adds execute +is taken from mount point, default value for the directory mode adds execute permission where the file mode gives read permission. .Pp Note that these permissions can differ from the rights granted by SMB -server. +server. .It Fl u Ar uid , Fl g Ar gid -User id and group id assigned to files. -The default is owner and group id from -directory where the volume is mounted. -.It Ar //user@server/share +User ID and group ID assigned to files. +The default are owner and group IDs from +the directory where the volume is mounted. +.It No // Ns Ar user Ns @ Ns Ar server Ns / Ns Ar share The .Nm command will use @@ -121,7 +123,7 @@ as the resource name on a remote server. Path to mount point. .El .Sh FILES -.Bl -tag -width /var/log/wtmp -compact +.Bl -tag -width ".Pa ~/.nsmbrc" -compact .It Pa ~/.nsmbrc Keeps static parameters for connections and other information. See @@ -129,10 +131,10 @@ See for details. .El .Sh EXAMPLES -The following examples illustrate how to connect to a SMB server +The following example illustrates how to connect to SMB server .Em SAMBA as user -.Em GUEST +.Em GUEST , and mount shares .Em PUBLIC and @@ -145,11 +147,10 @@ mount_smbfs -I 192.168.20.3 -E koi8-r:cp866 //guest@samba/tmp /smb/tmp It is possible to use .Xr fstab 5 for smbfs mounts: -.Bd -literal -offset indent -//guest@samba/public /smb/public smbfs rw,noauto 0 0 -.Ed +.Pp +.Dl "//guest@samba/public /smb/public smbfs rw,noauto 0 0" .Sh BUGS Please report bugs to the author. .Sh AUTHORS .An Boris Popov Aq bp@butya.kz , -.Aq bp@freebsd.org +.Aq bp@FreeBSD.org diff --git a/contrib/smbfs/mount_smbfs/mount_smbfs.c b/contrib/smbfs/mount_smbfs/mount_smbfs.c index f8295e7a5eaf..6c81f0845beb 100644 --- a/contrib/smbfs/mount_smbfs/mount_smbfs.c +++ b/contrib/smbfs/mount_smbfs/mount_smbfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2001, 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: mount_smbfs.c,v 1.16 2001/12/26 04:09:57 bp Exp $ + * $Id: mount_smbfs.c,v 1.17 2002/04/10 04:17:51 bp Exp $ */ #include #include diff --git a/contrib/smbfs/smbutil/smbutil.1 b/contrib/smbfs/smbutil/smbutil.1 index 529e4cf8368a..eec61937c7de 100644 --- a/contrib/smbfs/smbutil/smbutil.1 +++ b/contrib/smbfs/smbutil/smbutil.1 @@ -1,51 +1,57 @@ -.\" $Id: smbutil.1,v 1.4 2001/12/20 15:11:34 bp Exp $ -.Dd Feb 14, 2000 +.\" $Id: smbutil.1,v 1.5 2002/04/16 02:48:16 bp Exp $ +.Dd February 14, 2000 .Dt SMBUTIL 1 .Os .Sh NAME .Nm smbutil -.Nd Interface to SMB requester +.Nd "interface to the SMB requester" .Sh SYNOPSIS -.Nm smbutil +.Nm .Op Fl hv .Ar command -.Op Fl options +.Op Fl Ar options .Op Ar args .Sh DESCRIPTION The .Nm -command used to control SMB requester and issue various commands. +command is used to control SMB requester and issue various commands. .Pp -There are two types of options - global and local to specified command. +There are two types of options \(em global and local to the specified +.Ar command . .Pp -The global options are: +Global options are as follows: .Bl -tag -width indent .It Fl h -Print short help message. +Print a short help message. .It Fl v Verbose output. .El .Pp The commands and local options are: .Bl -tag -width indent -.It Em crypt Op password -Slightly encrypt clear text password to use it in the +.It Cm crypt Op Ar password +Encrypt clear text password for use in the .Pa ~/.nsmbrc -file. The encrypted password starts with '$$1' symbols. -Warning: the encryption function is very weak and intented only to hide +file. +The encrypted password starts with the +.Ql $$1 +symbols. +Warning: the encryption function is very weak and intended only to hide clear text password. If .Ar password -is ommited from command line, program will prompt for one. -.It Em help Ar command +is omitted from the command line, +.Nm +will prompt for one. +.It Cm help Ar command Print usage information about .Ar command . -.It Em lc +.It Cm lc List active connections and their parameters. .It Xo -.Em login -.Op Fl connection\ options -.Ar //user@server Ns Op Ar /share +.Cm login +.Op Fl Ar connection_options +.No // Ns Ar user Ns @ Ns Ar server Ns Op / Ns Ar share .Xc Login/attach to the specified .Ar server @@ -55,17 +61,17 @@ as .Ar user . This command will create and authenticate connection to an SMB server, and will leave it active after exit. -Thus, one can login only once and then +Thus, it is possible to login only once and then use other SMB commands without authentication procedure and additional connections. For the description of -.Op Fl connection\ options -see +.Fl Ar connection_options +refer to the .Xr mount_smbfs 8 -command (all uppercase options are connection options). +manpage (all uppercase options are connection options). .It Xo -.Em logout -.Ar //user@server Ns Op Ar /share +.Cm logout +.No // Ns Ar user Ns @ Ns Ar server Ns Op / Ns Ar share .Xc Logout/detach from the specified .Ar server @@ -73,53 +79,56 @@ and/or .Ar share as .Ar user . -This command will destroy connection created by -.Ar login -command. A connection may not be closed immediately if it used by other +This command will destroy a connection created by the +.Cm login +command. +A connection may not be closed immediately if it is used by other programs. .It Xo -.Em lookup +.Cm lookup .Op Fl w Ar host .Ar name .Xc -Resolve given +Resolve the given .Ar name -to IP address. -NetBIOS name server can be directly specified via -.Op Fl w +to an IP address. +The NetBIOS name server can be directly specified via the +.Fl w option. .It Xo -.Em print -.Op Fl connection\ options -.Ar //user@server/share +.Cm print +.Op Fl Ar connection_options +.No // Ns Ar user Ns @ Ns Ar server Ns / Ns Ar share .Ar file .Xc -Send given +Send the given .Ar file to the specified queue on the remote server. If .Ar file -is '-', then standard input will be used. +is +.Pa - , +then standard input will be used. .It Xo -.Em view -.Op Fl connection\ options -.Ar //user@server +.Cm view +.Op Fl Ar connection_options +.No // Ns Ar user Ns @ Ns Ar server .Xc -List resources avaliable on the specified +List resources available on the specified .Ar server for the user .Ar user . .El .Sh FILES -.Bl -tag -width /var/log/wtmp -compact +.Bl -tag -width ".Pa ~/.nsmbrc" -compact .It Pa ~/.nsmbrc -keeps description for each connection. +Keeps description for each connection. See .Pa ./examples/dot.nsmbrc for details. .El .Sh AUTHORS .An Boris Popov Aq bp@butya.kz , -.Aq bp@freebsd.org +.Aq bp@FreeBSD.org .Sh BUGS Please report any bugs to the author. diff --git a/contrib/smbfs/smbutil/view.c b/contrib/smbfs/smbutil/view.c index e3e600f57e4d..42450df26593 100644 --- a/contrib/smbfs/smbutil/view.c +++ b/contrib/smbfs/smbutil/view.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: view.c,v 1.8 2001/08/22 03:33:38 bp Exp $ + * $Id: view.c,v 1.9 2002/02/20 09:26:42 bp Exp $ */ #include #include @@ -44,6 +44,8 @@ #include +#include + #include #include #include @@ -53,8 +55,8 @@ static char *shtype[] = { "disk", "printer", - "pipe", - "comm", + "comm", /* Communications device */ + "pipe", /* IPC Inter process communication */ "unknown" }; @@ -64,7 +66,9 @@ cmd_view(int argc, char *argv[]) struct smb_ctx sctx, *ctx = &sctx; struct smb_share_info_1 *rpbuf, *ep; char *cp; + u_int16_t type; int error, opt, bufsize, i, entries, total; + if (argc < 2) view_usage(); @@ -100,7 +104,7 @@ cmd_view(int argc, char *argv[]) } printf("Share Type Comment\n"); printf("-------------------------------\n"); - bufsize = 65535; + bufsize = 0xffe0; /* samba notes win2k bug with 65535 */ rpbuf = malloc(bufsize); error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total); if (error && @@ -109,9 +113,11 @@ cmd_view(int argc, char *argv[]) exit(1); } for (ep = rpbuf, i = 0; i < entries; i++, ep++) { + type = letohs(ep->shi1_type); + cp = (char*)rpbuf + ep->shi1_remark; printf("%-12s %-10s %s\n", ep->shi1_netname, - shtype[ep->shi1_type], + shtype[min(type, sizeof shtype / sizeof(char *) - 1)], ep->shi1_remark ? nls_str_toloc(cp, cp) : ""); } printf("\n%d shares listed from %d available\n", entries, total);