Import smbfs-1.4.4.

This commit is contained in:
Sheldon Hearn 2002-04-22 16:15:20 +00:00
parent 8d4076f081
commit 34ffbc80d6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/smbfs/dist/; revision=95267
svn path=/vendor/smbfs/1.4.4/; revision=95269; tag=vendor/smbfs/1.4.4
9 changed files with 135 additions and 102 deletions

View File

@ -2,6 +2,7 @@
In the development process next sources were used: In the development process next sources were used:
Various documents from the Microsoft ftp site. Various documents from the Microsoft ftp site.
HTML docs published by Thursby Software. HTML docs published by Thursby Software.
Special thanks to the Samba team for permission to use their source Special thanks to the Samba team for permission to use their source

View File

@ -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. - Additional cleanups for FreeBSD builds.
- Charset specifications now accepted in the [default] section. - Charset specifications now accepted in the [default] section.

View File

@ -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 .ifmake !clean && !cleandepend
.if !defined(PREFIX) .if !defined(PREFIX)
@ -26,6 +26,8 @@ CFLAGS += -I../kernel
CFLAGS += -I${SYSDIR} CFLAGS += -I${SYSDIR}
.endif .endif
CFLAGS += -I../include
.if defined(SMBGDB) .if defined(SMBGDB)
CFLAGS+= -ggdb CFLAGS+= -ggdb
.endif .endif

View File

@ -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 # Example for .nsmbrc file
# #
@ -20,7 +20,8 @@
# where 'key' represents parameter name and 'value' a value assigned # where 'key' represents parameter name and 'value' a value assigned
# to this parameter. # 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] # A) [default]
# B) [SERVER] # B) [SERVER]
# C) [SERVER:USER] # C) [SERVER:USER]
@ -31,7 +32,7 @@
# keyword/section A B C D Comment # keyword/section A B C D Comment
# #
# addr - + - - IP or IPX address of SMB server # 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) # nbns + + - - address of NetBIOS name server (WINS)
# nbscope + + - - NetBIOS scope # nbscope + + - - NetBIOS scope
# nbtimeout + + - - timeout for NetBIOS name servers # nbtimeout + + - - timeout for NetBIOS name servers

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, Boris Popov * Copyright (c) 2000-2002, Boris Popov
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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/param.h>
#include <sys/sysctl.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 minlevel, int maxlevel, int sharetype)
{ {
int opt, error = 0; int opt, error = 0;
uid_t euid;
const char *arg, *cp; const char *arg, *cp;
struct passwd *pwd;
bzero(ctx,sizeof(*ctx)); bzero(ctx,sizeof(*ctx));
error = nb_ctx_create(&ctx->ct_nb); 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; ctx->ct_sh.ioc_group = SMBM_ANY_GROUP;
nb_ctx_setscope(ctx->ct_nb, ""); nb_ctx_setscope(ctx->ct_nb, "");
smb_ctx_setuser(ctx, getpwuid(geteuid())->pw_name); euid = geteuid();
endpwent(); 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) if (argv == NULL)
return 0; return 0;
for (opt = 1; opt < argc; opt++) { for (opt = 1; opt < argc; opt++) {
@ -564,7 +572,7 @@ smb_ctx_gethandle(struct smb_ctx *ctx)
char buf[20]; char buf[20];
/* /*
* First try to open as clone * First, try to open as cloned device
*/ */
fd = open("/dev/"NSMB_NAME, O_RDWR); fd = open("/dev/"NSMB_NAME, O_RDWR);
if (fd >= 0) { if (fd >= 0) {

View File

@ -1,18 +1,18 @@
.\" $Id: mount_smbfs.8,v 1.9 2001/12/20 15:11:45 bp Exp $ .\" $Id: mount_smbfs.8,v 1.10 2002/04/16 02:47:41 bp Exp $
.Dd Mar 10, 2000 .Dd March 10, 2000
.Dt MOUNT_SMBFS 8 .Dt MOUNT_SMBFS 8
.Os FreeBSD .Os
.Sh NAME .Sh NAME
.Nm mount_smbfs .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 .Sh SYNOPSIS
.Nm mount_smbfs .Nm
.Op Fl E Ar cs1:cs2 .Op Fl E Ar cs1 : Ns Ar cs2
.Op Fl I Ar host .Op Fl I Ar host
.Op Fl L Ar locale .Op Fl L Ar locale
.Op Fl M Ar crights:srights .Op Fl M Ar crights : Ns Ar srights
.Op Fl N .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 R Ar retrycount
.Op Fl T Ar timeout .Op Fl T Ar timeout
.Op Fl W Ar workgroup .Op Fl W Ar workgroup
@ -22,20 +22,22 @@
.Op Fl g Ar gid .Op Fl g Ar gid
.Op Fl n Ar opt .Op Fl n Ar opt
.Op Fl u Ar uid .Op Fl u Ar uid
.Ar //user@server/share .Sm off
.No // Ar user No @ Ar server No / Ar share
.Sm on
.Ar node .Ar node
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
command mounts a share from a remote server using SMB/CIFS protocol. command mounts a share from a remote server using SMB/CIFS protocol.
.Pp .Pp
The options are: The options are as follows:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl E Ar cs1:cs2 .It Fl E Ar cs1 : Ns Ar cs2
Specifies local Specifies local
.Ar (cs1) .Pq Ar cs1
and server's and server's
.Ar (cs2) .Pq Ar cs2
character sets. character sets.
.It Fl I Ar host .It Fl I Ar host
Do not use NetBIOS name resolver and connect directly to Do not use NetBIOS name resolver and connect directly to
@ -46,12 +48,12 @@ Use
.Ar locale .Ar locale
for lower/upper case conversion routines. for lower/upper case conversion routines.
Set the locale for case conversion. Set the locale for case conversion.
By default By default,
.Nm .Nm
tries to use an environment variable tries to use an environment variable
.Ev LC_* .Ev LC_*
to determine it. 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. Assign access rights to the newly created connection.
See See
.Xr nsmb 8 .Xr nsmb 8
@ -63,10 +65,10 @@ At run time,
reads the reads the
.Pa ~/.nsmbrc .Pa ~/.nsmbrc
file for additional configuration parameters and a password. file for additional configuration parameters and a password.
If no password is found the If no password is found,
.Nm .Nm
prompts for it. 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. Assign owner/group attributes to the newly created connection.
See See
.Xr nsmb 8 .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. This option specifies the workgroup to be used in the authentication request.
.It Fl c Ar case .It Fl c Ar case
Set a Set a
.Ar case .Ar case
option which affects name representation. option which affects name representation.
.Ar case .Ar case
can be one of the following: can be one of the following:
.Bl -tag -width "ValueXX" .Bl -tag -width ".Em Value"
.It Em Value .It Em Value
.Em Meaning .Em Meaning
.It l .It Cm l
All existing file names converted to lower case. All existing file names are converted to lower case.
Newly created file gets a lower case. Newly created file gets a lower case.
.It u .It Cm u
All existing file names converted to upper case. All existing file names are converted to upper case.
Newly created file gets an upper case unde. Newly created file gets an upper case.
.El .El
.It Fl f Ar mode , Fl d Ar mode .It Fl f Ar mode , Fl d Ar mode
Specify permissions that should be assigned to files and directories. Specify permissions that should be assigned to files and directories.
The values must be specified as octal numbers. The values must be specified as octal numbers.
Default value for the file mode 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. permission where the file mode gives read permission.
.Pp .Pp
Note that these permissions can differ from the rights granted by SMB Note that these permissions can differ from the rights granted by SMB
server. server.
.It Fl u Ar uid , Fl g Ar gid .It Fl u Ar uid , Fl g Ar gid
User id and group id assigned to files. User ID and group ID assigned to files.
The default is owner and group id from The default are owner and group IDs from
directory where the volume is mounted. the directory where the volume is mounted.
.It Ar //user@server/share .It No // Ns Ar user Ns @ Ns Ar server Ns / Ns Ar share
The The
.Nm .Nm
command will use command will use
@ -121,7 +123,7 @@ as the resource name on a remote server.
Path to mount point. Path to mount point.
.El .El
.Sh FILES .Sh FILES
.Bl -tag -width /var/log/wtmp -compact .Bl -tag -width ".Pa ~/.nsmbrc" -compact
.It Pa ~/.nsmbrc .It Pa ~/.nsmbrc
Keeps static parameters for connections and other information. Keeps static parameters for connections and other information.
See See
@ -129,10 +131,10 @@ See
for details. for details.
.El .El
.Sh EXAMPLES .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 .Em SAMBA
as user as user
.Em GUEST .Em GUEST ,
and mount shares and mount shares
.Em PUBLIC .Em PUBLIC
and 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 It is possible to use
.Xr fstab 5 .Xr fstab 5
for smbfs mounts: for smbfs mounts:
.Bd -literal -offset indent .Pp
//guest@samba/public /smb/public smbfs rw,noauto 0 0 .Dl "//guest@samba/public /smb/public smbfs rw,noauto 0 0"
.Ed
.Sh BUGS .Sh BUGS
Please report bugs to the author. Please report bugs to the author.
.Sh AUTHORS .Sh AUTHORS
.An Boris Popov Aq bp@butya.kz , .An Boris Popov Aq bp@butya.kz ,
.Aq bp@freebsd.org .Aq bp@FreeBSD.org

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000-2001, Boris Popov * Copyright (c) 2000-2002, Boris Popov
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>

View File

@ -1,51 +1,57 @@
.\" $Id: smbutil.1,v 1.4 2001/12/20 15:11:34 bp Exp $ .\" $Id: smbutil.1,v 1.5 2002/04/16 02:48:16 bp Exp $
.Dd Feb 14, 2000 .Dd February 14, 2000
.Dt SMBUTIL 1 .Dt SMBUTIL 1
.Os .Os
.Sh NAME .Sh NAME
.Nm smbutil .Nm smbutil
.Nd Interface to SMB requester .Nd "interface to the SMB requester"
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm smbutil .Nm
.Op Fl hv .Op Fl hv
.Ar command .Ar command
.Op Fl options .Op Fl Ar options
.Op Ar args .Op Ar args
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm .Nm
command used to control SMB requester and issue various commands. command is used to control SMB requester and issue various commands.
.Pp .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 .Pp
The global options are: Global options are as follows:
.Bl -tag -width indent .Bl -tag -width indent
.It Fl h .It Fl h
Print short help message. Print a short help message.
.It Fl v .It Fl v
Verbose output. Verbose output.
.El .El
.Pp .Pp
The commands and local options are: The commands and local options are:
.Bl -tag -width indent .Bl -tag -width indent
.It Em crypt Op password .It Cm crypt Op Ar password
Slightly encrypt clear text password to use it in the Encrypt clear text password for use in the
.Pa ~/.nsmbrc .Pa ~/.nsmbrc
file. The encrypted password starts with '$$1' symbols. file.
Warning: the encryption function is very weak and intented only to hide The encrypted password starts with the
.Ql $$1
symbols.
Warning: the encryption function is very weak and intended only to hide
clear text password. clear text password.
If If
.Ar password .Ar password
is ommited from command line, program will prompt for one. is omitted from the command line,
.It Em help Ar command .Nm
will prompt for one.
.It Cm help Ar command
Print usage information about Print usage information about
.Ar command . .Ar command .
.It Em lc .It Cm lc
List active connections and their parameters. List active connections and their parameters.
.It Xo .It Xo
.Em login .Cm login
.Op Fl connection\ options .Op Fl Ar connection_options
.Ar //user@server Ns Op Ar /share .No // Ns Ar user Ns @ Ns Ar server Ns Op / Ns Ar share
.Xc .Xc
Login/attach to the specified Login/attach to the specified
.Ar server .Ar server
@ -55,17 +61,17 @@ as
.Ar user . .Ar user .
This command will create and authenticate connection to an SMB server, and This command will create and authenticate connection to an SMB server, and
will leave it active after exit. 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 use other SMB commands without authentication procedure and additional
connections. connections.
For the description of For the description of
.Op Fl connection\ options .Fl Ar connection_options
see refer to the
.Xr mount_smbfs 8 .Xr mount_smbfs 8
command (all uppercase options are connection options). manpage (all uppercase options are connection options).
.It Xo .It Xo
.Em logout .Cm logout
.Ar //user@server Ns Op Ar /share .No // Ns Ar user Ns @ Ns Ar server Ns Op / Ns Ar share
.Xc .Xc
Logout/detach from the specified Logout/detach from the specified
.Ar server .Ar server
@ -73,53 +79,56 @@ and/or
.Ar share .Ar share
as as
.Ar user . .Ar user .
This command will destroy connection created by This command will destroy a connection created by the
.Ar login .Cm login
command. A connection may not be closed immediately if it used by other command.
A connection may not be closed immediately if it is used by other
programs. programs.
.It Xo .It Xo
.Em lookup .Cm lookup
.Op Fl w Ar host .Op Fl w Ar host
.Ar name .Ar name
.Xc .Xc
Resolve given Resolve the given
.Ar name .Ar name
to IP address. to an IP address.
NetBIOS name server can be directly specified via The NetBIOS name server can be directly specified via the
.Op Fl w .Fl w
option. option.
.It Xo .It Xo
.Em print .Cm print
.Op Fl connection\ options .Op Fl Ar connection_options
.Ar //user@server/share .No // Ns Ar user Ns @ Ns Ar server Ns / Ns Ar share
.Ar file .Ar file
.Xc .Xc
Send given Send the given
.Ar file .Ar file
to the specified queue on the remote server. to the specified queue on the remote server.
If If
.Ar file .Ar file
is '-', then standard input will be used. is
.Pa - ,
then standard input will be used.
.It Xo .It Xo
.Em view .Cm view
.Op Fl connection\ options .Op Fl Ar connection_options
.Ar //user@server .No // Ns Ar user Ns @ Ns Ar server
.Xc .Xc
List resources avaliable on the specified List resources available on the specified
.Ar server .Ar server
for the user for the user
.Ar user . .Ar user .
.El .El
.Sh FILES .Sh FILES
.Bl -tag -width /var/log/wtmp -compact .Bl -tag -width ".Pa ~/.nsmbrc" -compact
.It Pa ~/.nsmbrc .It Pa ~/.nsmbrc
keeps description for each connection. Keeps description for each connection.
See See
.Pa ./examples/dot.nsmbrc .Pa ./examples/dot.nsmbrc
for details. for details.
.El .El
.Sh AUTHORS .Sh AUTHORS
.An Boris Popov Aq bp@butya.kz , .An Boris Popov Aq bp@butya.kz ,
.Aq bp@freebsd.org .Aq bp@FreeBSD.org
.Sh BUGS .Sh BUGS
Please report any bugs to the author. Please report any bugs to the author.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, Boris Popov * Copyright (c) 2000-2002, Boris Popov
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * 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 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * 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 <sys/param.h> #include <sys/param.h>
#include <sys/errno.h> #include <sys/errno.h>
@ -44,6 +44,8 @@
#include <cflib.h> #include <cflib.h>
#include <sys/mchain.h>
#include <netsmb/smb_lib.h> #include <netsmb/smb_lib.h>
#include <netsmb/smb_conn.h> #include <netsmb/smb_conn.h>
#include <netsmb/smb_rap.h> #include <netsmb/smb_rap.h>
@ -53,8 +55,8 @@
static char *shtype[] = { static char *shtype[] = {
"disk", "disk",
"printer", "printer",
"pipe", "comm", /* Communications device */
"comm", "pipe", /* IPC Inter process communication */
"unknown" "unknown"
}; };
@ -64,7 +66,9 @@ cmd_view(int argc, char *argv[])
struct smb_ctx sctx, *ctx = &sctx; struct smb_ctx sctx, *ctx = &sctx;
struct smb_share_info_1 *rpbuf, *ep; struct smb_share_info_1 *rpbuf, *ep;
char *cp; char *cp;
u_int16_t type;
int error, opt, bufsize, i, entries, total; int error, opt, bufsize, i, entries, total;
if (argc < 2) if (argc < 2)
view_usage(); view_usage();
@ -100,7 +104,7 @@ cmd_view(int argc, char *argv[])
} }
printf("Share Type Comment\n"); printf("Share Type Comment\n");
printf("-------------------------------\n"); printf("-------------------------------\n");
bufsize = 65535; bufsize = 0xffe0; /* samba notes win2k bug with 65535 */
rpbuf = malloc(bufsize); rpbuf = malloc(bufsize);
error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total); error = smb_rap_NetShareEnum(ctx, 1, rpbuf, bufsize, &entries, &total);
if (error && if (error &&
@ -109,9 +113,11 @@ cmd_view(int argc, char *argv[])
exit(1); exit(1);
} }
for (ep = rpbuf, i = 0; i < entries; i++, ep++) { for (ep = rpbuf, i = 0; i < entries; i++, ep++) {
type = letohs(ep->shi1_type);
cp = (char*)rpbuf + ep->shi1_remark; cp = (char*)rpbuf + ep->shi1_remark;
printf("%-12s %-10s %s\n", ep->shi1_netname, 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) : ""); ep->shi1_remark ? nls_str_toloc(cp, cp) : "");
} }
printf("\n%d shares listed from %d available\n", entries, total); printf("\n%d shares listed from %d available\n", entries, total);