1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

Merge commit 'origin/v3-2-test' into v3-2-stable

Conflicts:

	WHATSNEW.txt
This commit is contained in:
Karolin Seeger 2008-02-29 10:44:38 +01:00
commit a390bcf940
501 changed files with 80862 additions and 53871 deletions

17
.gitignore vendored
View File

@ -1,6 +1,7 @@
*.o
*.po
*~
source/TAGS
source/client/client_proto.h
source/libnet/libnet_proto.h
source/include/build_env.h
@ -45,3 +46,19 @@ examples/VFS/module_config.h.in
examples/VFS/shadow_copy_test.so
examples/VFS/skel_opaque.so
examples/VFS/skel_transparent.so
examples/libsmbclient/smbwrapper/smbsh
examples/libsmbclient/smbwrapper/smbwrapper.so
examples/libsmbclient/testacl
examples/libsmbclient/testacl2
examples/libsmbclient/testacl3
examples/libsmbclient/testbrowse
examples/libsmbclient/testbrowse2
examples/libsmbclient/testchmod
examples/libsmbclient/testread
examples/libsmbclient/testsmbc
examples/libsmbclient/teststat
examples/libsmbclient/teststat2
examples/libsmbclient/teststat3
examples/libsmbclient/testutime
examples/libsmbclient/testwrite
examples/libsmbclient/testtruncate

7
PFIF.txt Normal file
View File

@ -0,0 +1,7 @@
This code was developed in participation with the Protocol Freedom
Information Foundation.
Please see
http://protocolfreedom.org/ and
http://samba.org/samba/PFIF/
for more details.

8
README
View File

@ -102,16 +102,16 @@ for more details) and are always glad to receive feedback or
suggestions to the address samba@lists.samba.org. More information
on the various Samba mailing lists can be found at http://lists.samba.org/.
You can also get the Samba sourcecode straight from the Subversion tree - see
http://samba.org/samba/subversion.html.
You can also get the Samba sourcecode straight from the git repository - see
http://wiki.samba.org/index.php/Using_Git_for_Samba_Development.
You could also send hardware/software/money/jewelry or pre-paid pizza
vouchers directly to Andrew. The pizza vouchers would be especially
welcome, in fact there is a special field in the survey for people who
have paid up their pizza :-)
If you like a particular feature then look through the Subversion change-log
(on the web at http://websvn.samba.org/cgi-bin/viewcvs.cgi) and see
If you like a particular feature then look through the git change-log
(on the web at http://gitweb.samba.org/?p=samba.git;a=summary) and see
who added it, then send them an email.
Remember that free software of this kind lives or dies by the response

View File

@ -1,6 +1,6 @@
=================================
Release Notes for Samba 3.2.0pre2
Jan 16, 2008
Feb 29, 2008
=================================
This is the second preview release of Samba 3.2.0. This is *not*
@ -22,18 +22,19 @@ Major enhancements in Samba 3.2.0 include:
o Introduction of a registry based configuration system.
o Improved CIFS Unix Extensions support.
o Experimental support for file serving clusters.
o Support for IPv6 connections.
o Support for IPv6 in the server, and client tools and libraries.
o Support for storing alternate data streams in xattrs.
o Encrypted SMB transport in client tools and libraries, and server.
Winbind and Active Directory Integration:
o Full support for Windows 2003 cross-forest, transitive trusts
and one-way domain trusts
and one-way domain trusts.
o Support for userPrincipalName logons via pam_winbind and NSS
lookups.
o Support in pam_winbind for logging on using the userPrincipalName.
o Expansion of nested domain groups via NSS calls.
o Support for Active Directory LDAP Signing policy.
o New LGPL Winbind client library (libwbclient.so)
o New LGPL Winbind client library (libwbclient.so).
Users & Groups:
@ -74,13 +75,12 @@ to the "Changes" section for details on the exact parameters that were
updated.
Registry Configuration Backend
==============================
Samba is now able to use a registry based configuration backed to
supplement smb.conf setting. This feature may be enabled by setting
"include = registry" and "registry shares = yes" in the [global]
"config backend = registry" and "registry shares = yes" in the [global]
section of smb.conf and may be managed using the "net conf" command.
More information may be obtained from the smb.conf(5) and net(8) man
@ -93,6 +93,11 @@ Removed Features
Both the Python bindings and the libmsrpc shared library have been
removed from the tree due to lack of an official maintainer.
As smbfs is no longer supported in current kernel versions, smbmount has
been removed in this Samba version. Please use cifs (mount.cifs) instead.
See examples/scripts/mount/mount.smbfs as an example for a wrapper which
calls mount.cifs instead of smbmount/mount.smbfs.
######################################################################
@ -109,16 +114,20 @@ smb.conf changes
client plaintext auth Changed Default No
clustering New No
cluster addresses New ""
debug class New No
config backend New file
ctdb socket New ""
debug class New No
hidden New No
lanman auth Changed Default No
mangle map Removed
min receive file size New 0
open files database hash size Removed
read bmpx Removed
ldap debug level New 0
ldap debug threshold New 10
mangle map Removed
min receive file size New 0
open files database hashsize Removed
read bmpx Removed
registry shares New No
winbind expand groups New 1
winbind rpc only New No
winbind expand groups New 1
winbind rpc only New No
Changes since 3.2.0pre1:
@ -130,13 +139,24 @@ o Michael Adam <obnox@samba.org>
* BUG 4308: Fix Excel save operation ACL bug.
* Refactor and consolidate logic for retrieving the machine
trust password information.
* VFS API cleanup.
* VFS API cleanup (remove redundant parameter).
* BUG 4801: Correctly implement LSA lookup levels for LookupNames.
* Add new option "debug class" to control printing of the debug class.
in debug headers.
* Enable building of the zfsacl and notify_fam vfs modules.
* BUG 5083: Fix memleak in solarisacl module.
* BUG 5063: Fix build on RHEL5.
* New smb.conf parameter "config backend = registry" to enable registry
only configuration.
* Move "net conf" functionality into a separate module libnet_conf.c
* Restructure registry code, eliminating the dynamic overlay.
Make use of reg_api instead of backend code in most places.
* Add support for intercepting LDAP libraries' debug output and print
it in Samba's debugging system.
* Libreplace fixes.
* Build fixes.
* Initial support for using subsystems as shared libraries.
Use talloc, tdb, and libnetapi as shared libraries internally.
o Jeremy Allison <jra@samba.org>
@ -146,8 +166,15 @@ o Jeremy Allison <jra@samba.org>
* Remove unused utilities: smbctool and rpctorture.
* Fix service principal detection to match Windows Vista
(based on work from Andreas Schneider).
* Additional work on the session data privacy for clients
implementing the Unix CIFS Extensions.
* Encrypted SMB transport in client tools and libraries, and server.
o Kai Blin <kai@samba.org>
* Added support for an SMB_CONF_PATH environment variable
containing the path to smb.conf.
* Various fixes to ntlm_auth.
* make test now supports more extensive SPOOLSS testing using vlp.
* Correctly handle mixed-case hostnames in NTLMv2 authentication.
o Gerald (Jerry) Carter <jerry@samba.org>
@ -175,7 +202,12 @@ o Volker Lendecke <vl@samba.org>
* Add generic a in-memory cache.
* Import the Linux red-black tree implementation.
* Remove large amount of global variables.
* Add vfs_xattr_tdb module for file systems that do not implement xattrs.
* Support for storing xattrs in tdb files.
* Support for storing alternate data streams in xattrs.
* Implement a generic in-memory cache based on rb-trees.
* Add implicit temporary talloc contexts via talloc_stack().
* Speed up the smbclient "get" command
* Add the aio_fork module
o Stefan Metzmacher <metze@samba.org>
@ -185,6 +217,18 @@ o Stefan Metzmacher <metze@samba.org>
* Networking fixes to the libreplace library.
* Pidl fixes.
* Remove unused Winbind pipe calls.
* Build fixes.
* Fix for a crash bug in pidl generated client code.
This could have happend with [in,out,unique] pointers
when the client sends a valid pointer, but the server
responds with a NULL pointer (as samba-3.0.26a does for some calls).
* Change NTSTATUS into enum ndr_err_code in librpc/ndr.
* Remove unused calls in the struct based winbindd protocol.
* Add --configfile option to wbinfo.
* Convert winbind_env_set(), winbind_on() and winbind_off() into macros.
* Return rids and other_sids arrays in WBFLAG_PAM_INFO3_TEXT mode.
* Implement wbcErrorString() and wbcAuthenticateUserEx().
* Convert auth_winbind to use wbcAuthenticateUserEx().
o James Peach <jpeach@samba.org>
@ -195,10 +239,16 @@ o James Peach <jpeach@samba.org>
o Andreas Schneider <anschneider@suse.de>
* Don't restart winbind if a corrupted tdb is found during
initialization.
* Fix Windows 2008 (Longhorn) join.
* Add share parameter "hidden".
o Karolin Seeger <ks@sernet.de>
* Add net rap file user.
* Improve error messages of net subcommands.
* Add 'net rap file user'.
* Change LDAP search filter to find machine accounts which
are not located in the user suffix.
* Remove smbmount.
o David Shaw <dshaw@jabberwocky.com>
@ -223,6 +273,9 @@ o Jelmer Vernooij <jelmer@samba.org>
* Additional portability support for building shared libraries.
o Corinna Vinschen <corinna@vinschen.de>
* Get Samba version or capability information from Windows user space.
Original 3.2.0pre1 commits:
---------------------------
@ -301,7 +354,7 @@ o Volker Lendecke <vl@samba.org>
o Steve French <sfrench@samba.org>
* Fixes for mount.cfs Linux utility.
* Fixes for mount.cifs Linux utility.
o Stefan Metzmacher <metze@samba.org>
@ -322,7 +375,7 @@ o James Peach <jpeach@apple.com>
o Jiri Sasek <Jiri.Sasek@Sun.COM>
* Added vfs_vfsacl module.
* Added vfs_zfsacl module.
o Karolin Seeger <ks@sernet.de>

View File

@ -580,6 +580,21 @@ static int skel_aio_suspend(struct vfs_handle_struct *handle, struct files_struc
return vfswrap_aio_suspend(NULL, fsp, aiocb, n, ts);
}
static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
{
return vfswrap_aio_force(NULL, fsp);
}
static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
{
return vfswrap_is_offline(NULL, path, sbuf);
}
static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
{
return vfswrap_set_offline(NULL, path);
}
/* VFS operations structure */
static vfs_op_tuple skel_op_tuples[] = {
@ -676,7 +691,7 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, SMB_VFS_LAYER_OPAQUE},
/* EA operations. */
{SMB_VFS_OP(skel_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_OPAQUE},
@ -699,6 +714,11 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_aio_error), SMB_VFS_OP_AIO_ERROR, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_aio_fsync), SMB_VFS_OP_AIO_FSYNC, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_aio_suspend), SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_OPAQUE},
/* offline operations */
{SMB_VFS_OP(skel_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_OPAQUE},
{SMB_VFS_OP(skel_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_OPAQUE},
{NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
};

View File

@ -539,6 +539,26 @@ static int skel_aio_suspend(struct vfs_handle_struct *handle, struct files_struc
return SMB_VFS_NEXT_AIO_SUSPEND(handle, fsp, aiocb, n, ts);
}
static bool skel_aio_force(struct vfs_handle_struct *handle, struct files_struct *fsp)
{
return SMB_VFS_NEXT_AIO_FORCE(handle, fsp);
}
static bool skel_is_offline(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
{
return SMB_VFS_NEXT_IS_OFFLINE(handle, path, sbuf);
}
static int skel_set_offline(struct vfs_handle_struct *handle, const char *path)
{
return SMB_VFS_NEXT_SET_OFFLINE(handle, path);
}
static bool skel_is_remotestorage(struct vfs_handle_struct *handle, const char *path)
{
return SMB_VFS_NEXT_IS_REMOTESTORAGE(handle, path);
}
/* VFS operations structure */
static vfs_op_tuple skel_op_tuples[] = {
@ -633,7 +653,7 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_sys_acl_free_text), SMB_VFS_OP_SYS_ACL_FREE_TEXT, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_sys_acl_free_acl), SMB_VFS_OP_SYS_ACL_FREE_ACL, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_sys_acl_free_qualifier), SMB_VFS_OP_SYS_ACL_FREE_QUALIFIER, SMB_VFS_LAYER_TRANSPARENT},
/* EA operations. */
{SMB_VFS_OP(skel_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT},
@ -656,6 +676,11 @@ static vfs_op_tuple skel_op_tuples[] = {
{SMB_VFS_OP(skel_aio_error), SMB_VFS_OP_AIO_ERROR, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_aio_fsync), SMB_VFS_OP_AIO_FSYNC, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_aio_suspend), SMB_VFS_OP_AIO_SUSPEND, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_aio_force), SMB_VFS_OP_AIO_FORCE, SMB_VFS_LAYER_TRANSPARENT},
/* offline operations */
{SMB_VFS_OP(skel_is_offline), SMB_VFS_OP_IS_OFFLINE, SMB_VFS_LAYER_TRANSPARENT},
{SMB_VFS_OP(skel_set_offline), SMB_VFS_OP_SET_OFFLINE, SMB_VFS_LAYER_TRANSPARENT},
{NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
};

View File

@ -18,13 +18,17 @@ LIBSMBCLIENT = -lwbclient -lsmbclient -ldl -lresolv
TESTS= testsmbc \
testacl \
testacl2 \
testacl3 \
testbrowse \
testbrowse2 \
teststat \
teststat2 \
teststat3 \
testtruncate \
testchmod \
testutime \
testread
testread \
testwrite
# tree \
@ -46,6 +50,10 @@ testacl2: testacl2.o
@echo Linking testacl2
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testacl3: testacl3.o
@echo Linking testacl3
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testbrowse: testbrowse.o
@echo Linking testbrowse
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
@ -62,6 +70,14 @@ teststat2: teststat2.o
@echo Linking teststat2
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
teststat3: teststat3.o
@echo Linking teststat3
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testtruncate: testtruncate.o
@echo Linking testtruncate
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testchmod: testchmod.o
@echo Linking testchmod
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
@ -74,6 +90,10 @@ testread: testread.o
@echo Linking testread
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
testwrite: testwrite.o
@echo Linking testwrite
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBSMBCLIENT) -lpopt
smbsh:
make -C smbwrapper

View File

@ -8,7 +8,23 @@ get_auth_data_fn(const char * pServer,
char * pPassword,
int maxLenPassword)
{
char temp[128];
char temp[128];
char server[256] = { '\0' };
char share[256] = { '\0' };
char workgroup[256] = { '\0' };
char username[256] = { '\0' };
char password[256] = { '\0' };
if (strcmp(server, pServer) == 0 &&
strcmp(share, pShare) == 0 &&
*workgroup != '\0' &&
*username != '\0')
{
strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
strncpy(pUsername, username, maxLenUsername - 1);
strncpy(pPassword, password, maxLenPassword - 1);
return;
}
fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
fgets(temp, sizeof(temp), stdin);
@ -48,4 +64,8 @@ get_auth_data_fn(const char * pServer,
{
strncpy(pPassword, temp, maxLenPassword - 1);
}
strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
strncpy(username, pUsername, sizeof(username) - 1);
strncpy(password, pPassword, sizeof(password) - 1);
}

View File

@ -72,13 +72,12 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf
int ret;
fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf;
struct timeval tval2, *ptval, end_time, now_time;
extern void GetTimeOfDay(struct timeval *tval);
readfds2 = (readfds ? &readfds_buf : NULL);
writefds2 = (writefds ? &writefds_buf : NULL);
errorfds2 = (errorfds ? &errorfds_buf : NULL);
if (tval) {
GetTimeOfDay(&end_time);
gettimeofday(&end_time, NULL);
end_time.tv_sec += tval->tv_sec;
end_time.tv_usec += tval->tv_usec;
end_time.tv_sec += end_time.tv_usec / 1000000;
@ -96,7 +95,7 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf
if (errorfds)
errorfds_buf = *errorfds;
if (tval) {
GetTimeOfDay(&now_time);
gettimeofday(&now_time, NULL);
tval2.tv_sec = end_time.tv_sec - now_time.tv_sec;
tval2.tv_usec = end_time.tv_usec - now_time.tv_usec;
if ((signed long) tval2.tv_usec < 0) {

View File

@ -0,0 +1,62 @@
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <libsmbclient.h>
#include "get_auth_data_fn.h"
int main(int argc, char * argv[])
{
int i;
int fd;
int ret;
int debug = 0;
int mode = 0666;
int savedErrno;
char value[2048];
char path[2048];
char * the_acl;
char * p;
time_t t0;
time_t t1;
struct stat st;
SMBCCTX * context;
smbc_init(get_auth_data_fn, debug);
context = smbc_set_context(NULL);
smbc_option_set(context, "full_time_names", 1);
for (;;)
{
fprintf(stdout, "Path: ");
*path = '\0';
fgets(path, sizeof(path) - 1, stdin);
if (strlen(path) == 0)
{
return 0;
}
p = path + strlen(path) - 1;
if (*p == '\n')
{
*p = '\0';
}
the_acl = strdup("system.nt_sec_desc.*+");
ret = smbc_getxattr(path, the_acl, value, sizeof(value));
if (ret < 0)
{
printf("Could not get attributes for [%s] %d: %s\n",
path, errno, strerror(errno));
return 1;
}
printf("Attributes for [%s] are:\n%s\n", path, value);
}
return 0;
}

View File

@ -10,66 +10,58 @@
int main(int argc, char * argv[])
{
int i;
int fd;
int ret;
int debug = 0;
int mode = 0666;
int savedErrno;
char buffer[2048];
char * pSmbPath = NULL;
char path[2048];
char * p;
time_t t0;
time_t t1;
struct stat st;
if (argc == 1)
{
pSmbPath = "smb://RANDOM/Public/bigfile";
}
else if (argc == 2)
{
pSmbPath = argv[1];
}
else
{
printf("usage: "
"%s [ smb://path/to/file ]\n",
argv[0]);
return 1;
}
smbc_init(get_auth_data_fn, debug);
printf("Open file %s\n", pSmbPath);
for (;;)
{
fprintf(stdout, "Path: ");
*path = '\0';
fgets(path, sizeof(path) - 1, stdin);
if (strlen(path) == 0)
{
return 0;
}
p = path + strlen(path) - 1;
if (*p == '\n')
{
*p = '\0';
}
t0 = time(NULL);
if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
{
perror("smbc_open");
continue;
}
if ((fd = smbc_open(pSmbPath, O_RDONLY, 0)) < 0)
{
perror("smbc_open");
return 1;
do
{
ret = smbc_read(fd, buffer, sizeof(buffer));
savedErrno = errno;
if (ret > 0) fwrite(buffer, 1, ret, stdout);
} while (ret > 0);
smbc_close(fd);
if (ret < 0)
{
errno = savedErrno;
perror("read");
}
}
printf("Beginning read loop.\n");
do
{
ret = smbc_read(fd, buffer, sizeof(buffer));
savedErrno = errno;
if (ret > 0) fwrite(buffer, 1, ret, stdout);
} while (ret > 0);
smbc_close(fd);
if (ret < 0)
{
errno = savedErrno;
perror("read");
return 1;
}
t1 = time(NULL);
printf("Elapsed time: %d seconds\n", t1 - t0);
return 0;
}

View File

@ -0,0 +1,78 @@
#include <libsmbclient.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include "get_auth_data_fn.h"
/*
* This test is intended to ensure that the timestamps returned by
* libsmbclient using smbc_stat() are the same as those returned by
* smbc_fstat().
*/
int main(int argc, char* argv[])
{
int fd;
struct stat st1;
struct stat st2;
char mtime[32];
char ctime[32];
char atime[32];
char * pUrl = argv[1];
if(argc != 2)
{
printf("usage: %s <file_url>\n", argv[0]);
return 1;
}
smbc_init(get_auth_data_fn, 0);
if (smbc_stat(pUrl, &st1) < 0)
{
perror("smbc_stat");
return 1;
}
if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
{
perror("smbc_open");
return 1;
}
if (smbc_fstat(fd, &st2) < 0)
{
perror("smbc_fstat");
return 1;
}
smbc_close(fd);
#define COMPARE(name, field) \
if (st1.field != st2.field) \
{ \
printf("Field " name " MISMATCH: st1=%lu, st2=%lu\n", \
(unsigned long) st1.field, \
(unsigned long) st2.field); \
}
COMPARE("st_dev", st_dev);
COMPARE("st_ino", st_ino);
COMPARE("st_mode", st_mode);
COMPARE("st_nlink", st_nlink);
COMPARE("st_uid", st_uid);
COMPARE("st_gid", st_gid);
COMPARE("st_rdev", st_rdev);
COMPARE("st_size", st_size);
COMPARE("st_blksize", st_blksize);
COMPARE("st_blocks", st_blocks);
COMPARE("st_atime", st_atime);
COMPARE("st_mtime", st_mtime);
COMPARE("st_ctime", st_ctime);
return 0;
}

View File

@ -0,0 +1,82 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <libsmbclient.h>
#include "get_auth_data_fn.h"
int main(int argc, char * argv[])
{
int fd;
int ret;
int debug = 0;
int savedErrno;
char buffer[128];
char * pSmbPath = NULL;
char * pLocalPath = NULL;
struct stat st;
if (argc != 2)
{
printf("usage: "
"%s smb://path/to/file\n",
argv[0]);
return 1;
}
smbc_init(get_auth_data_fn, debug);
if ((fd = smbc_open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
{
perror("smbc_open");
return 1;
}
strcpy(buffer, "Hello world.\nThis is a test.\n");
ret = smbc_write(fd, buffer, strlen(buffer));
savedErrno = errno;
smbc_close(fd);
if (ret < 0)
{
errno = savedErrno;
perror("write");
}
if (smbc_stat(argv[1], &st) < 0)
{
perror("smbc_stat");
return 1;
}
printf("Original size: %lu\n", (unsigned long) st.st_size);
if ((fd = smbc_open(argv[1], O_WRONLY, 0)) < 0)
{
perror("smbc_open");
return 1;
}
ret = smbc_ftruncate(fd, 13);
savedErrno = errno;
smbc_close(fd);
if (ret < 0)
{
errno = savedErrno;
perror("smbc_ftruncate");
return 1;
}
if (smbc_stat(argv[1], &st) < 0)
{
perror("smbc_stat");
return 1;
}
printf("New size: %lu\n", (unsigned long) st.st_size);
return 0;
}

View File

@ -0,0 +1,69 @@
#include <sys/types.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <libsmbclient.h>
#include "get_auth_data_fn.h"
int main(int argc, char * argv[])
{
int i;
int fd;
int ret;
int debug = 0;
int mode = 0666;
int savedErrno;
char buffer[2048];
char path[2048];
char * p;
time_t t0;
time_t t1;
struct stat st;
smbc_init(get_auth_data_fn, debug);
printf("CAUTION: This program will overwrite a file. "
"Press ENTER to continue.");
fgets(buffer, sizeof(buffer), stdin);
for (;;)
{
fprintf(stdout, "\nPath: ");
*path = '\0';
fgets(path, sizeof(path) - 1, stdin);
if (strlen(path) == 0)
{
return 0;
}
p = path + strlen(path) - 1;
if (*p == '\n')
{
*p = '\0';
}
if ((fd = smbc_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
{
perror("smbc_open");
continue;
}
strcpy(buffer, "Hello world\n");
ret = smbc_write(fd, buffer, strlen(buffer));
savedErrno = errno;
smbc_close(fd);
if (ret < 0)
{
errno = savedErrno;
perror("write");
}
}
return 0;
}

View File

@ -3,7 +3,7 @@
# adssearch.pl - query an Active Directory server and
# display objects in a human readable format
#
# Copyright (C) Guenther Deschner <gd@samba.org> 2003-2007
# Copyright (C) Guenther Deschner <gd@samba.org> 2003-2008
#
# TODO: add range retrieval
# write sddl-converter, decode userParameters
@ -230,6 +230,7 @@ my %ads_mixed_domain = (
my %ads_ds_func = (
"DS_BEHAVIOR_WIN2000" => 0, # untested
"DS_BEHAVIOR_WIN2003" => 2,
"DS_BEHAVIOR_WIN2008" => 3,
);
my %ads_instance_type = (
@ -244,6 +245,14 @@ my %ads_uacc = (
"ACCOUNT_LOCKED_OUT" => 0x800010, # 8388624
);
my %ads_enctypes = (
"DES-CBC-CRC" => 0x01,
"DES-CBC-MD5" => 0x02,
"RC4_HMAC_MD5" => 0x04,
"AES128_CTS_HMAC_SHA1_96" => 0x08,
"AES128_CTS_HMAC_SHA1_128" => 0x10,
);
my %ads_gpoptions = (
"GPOPTIONS_INHERIT" => 0,
"GPOPTIONS_BLOCK_INHERITANCE" => 1,
@ -518,6 +527,7 @@ my %attr_handler = (
"modifyTimeStamp" => \&dump_timestr,
"msDS-Behavior-Version" => \&dump_ds_func, #unsure
"msDS-User-Account-Control-Computed" => \&dump_uacc,
"msDS-SupportedEncryptionTypes" => \&dump_enctypes,
"mS-DS-CreatorSID" => \&dump_sid,
# "msRADIUSFramedIPAddress" => \&dump_ipaddr,
# "msRASSavedFramedIPAddress" => \&dump_ipaddr,
@ -1209,6 +1219,10 @@ sub dump_uacc {
return dump_bitmask_equal(@_,%ads_uacc);
}
sub dump_enctypes {
return dump_bitmask_and(@_,%ads_enctypes);
}
sub dump_uf {
return dump_bitmask_and(@_,%ads_uf);
}

View File

@ -0,0 +1,115 @@
#!/bin/bash
# Debian mount.smbfs compatibility wrapper
# Copyright 2007, Steve Langasek <vorlon at debian.org>
# Licensed under the GNU General Public License, version 2. See the
# file /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.
# This script accepts all documented mount options for mount.smbfs,
# passing through those that are also recognized by mount.cifs,
# converting those that are not recognized but map to available cifs
# options, and warning about the use of options for which no equivalent
# exists.
# known bugs: quoted spaces in arguments are not passed intact
set -e
# reverse the order of username and password in a "username" parameter,
# taking care to leave any "%password" bit intact
reverse_username_workgroup() {
local workgroup password username
username="$1"
case "$username" in
*%*) password="${username#*%}"
username="${username%%%*}"
;;
*) ;;
esac
case "$username" in
*/*) workgroup="${username#*/}"
username="${username%%/*}"
;;
*) ;;
esac
if [ -n "$workgroup" ]; then
username="$workgroup\\$username"
fi
if [ -n "$password" ]; then
username="$username%$password"
fi
echo "$username"
}
# parse out the mount options that have been specified using -o, and if
# necessary, convert them for use by mount.cifs
parse_mount_options () {
local OLD_IFS IFS options option username
OLD_IFS="$IFS"
IFS=","
options=""
workgroup=""
password=""
for option in $@; do
case "$option" in
sockopt=* | scope=* | codepage=* | ttl=* | debug=*)
echo "Warning: ignoring deprecated smbfs option '$option'" >&2
;;
krb)
options="$options${options:+,}sec=krb5"
;;
guest)
echo "Warning: mapping 'guest' to 'guest,sec=none'" >&2
options="$options${options:+,}guest,sec=none"
;;
# username and workgroup are reversed in username= arguments,
# so need to be parsed out
username=*/*)
IFS="$OLD_IFS"
username="${option#username=}"
username="$(reverse_username_workgroup "$username")"
IFS=","
options="$options${options:+,}username=$username"
;;
*)
options="$options${options:+,}$option"
;;
esac
done
IFS="$OLD_IFS"
echo $options
}
args=()
while [ "$#" -gt 0 ]; do
case "$1" in
-o*)
arg=${1#-o}
shift
if [ -z "$arg" ]; then
arg=$1
shift
fi
arg="$(parse_mount_options "$arg")"
if [ -n "$arg" ]; then
args=("${args[@]}" "-o" "$arg")
fi
;;
*)
args=("${args[@]}" "$1")
shift
;;
esac
done
USER="$(reverse_username_workgroup "$USER")"
exec /sbin/mount.cifs "${args[@]}"

File diff suppressed because it is too large Load Diff

View File

@ -458,7 +458,9 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
char **auth_method_list = NULL;
NTSTATUS nt_status;
if (lp_auth_methods() && !str_list_copy(&auth_method_list, lp_auth_methods())) {
if (lp_auth_methods()
&& !str_list_copy(talloc_tos(), &auth_method_list,
lp_auth_methods())) {
return NT_STATUS_NO_MEMORY;
}
@ -467,38 +469,52 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
{
case SEC_DOMAIN:
DEBUG(5,("Making default auth method list for security=domain\n"));
auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest sam winbind:ntdomain",
NULL);
break;
case SEC_SERVER:
DEBUG(5,("Making default auth method list for security=server\n"));
auth_method_list = str_list_make("guest sam smbserver", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest sam smbserver",
NULL);
break;
case SEC_USER:
if (lp_encrypted_passwords()) {
if ((lp_server_role() == ROLE_DOMAIN_PDC) || (lp_server_role() == ROLE_DOMAIN_BDC)) {
DEBUG(5,("Making default auth method list for DC, security=user, encrypt passwords = yes\n"));
auth_method_list = str_list_make("guest sam winbind:trustdomain", NULL);
auth_method_list = str_list_make(
talloc_tos(),
"guest sam winbind:trustdomain",
NULL);
} else {
DEBUG(5,("Making default auth method list for standalone security=user, encrypt passwords = yes\n"));
auth_method_list = str_list_make("guest sam", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest sam",
NULL);
}
} else {
DEBUG(5,("Making default auth method list for security=user, encrypt passwords = no\n"));
auth_method_list = str_list_make("guest unix", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest unix", NULL);
}
break;
case SEC_SHARE:
if (lp_encrypted_passwords()) {
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = yes\n"));
auth_method_list = str_list_make("guest sam", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest sam", NULL);
} else {
DEBUG(5,("Making default auth method list for security=share, encrypt passwords = no\n"));
auth_method_list = str_list_make("guest unix", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest unix", NULL);
}
break;
case SEC_ADS:
DEBUG(5,("Making default auth method list for security=ADS\n"));
auth_method_list = str_list_make("guest sam winbind:ntdomain", NULL);
auth_method_list = str_list_make(
talloc_tos(), "guest sam winbind:ntdomain",
NULL);
break;
default:
DEBUG(5,("Unknown auth method!\n"));
@ -508,12 +524,10 @@ NTSTATUS make_auth_context_subsystem(struct auth_context **auth_context)
DEBUG(5,("Using specified auth order\n"));
}
if (!NT_STATUS_IS_OK(nt_status = make_auth_context_text_list(auth_context, auth_method_list))) {
str_list_free(&auth_method_list);
return nt_status;
}
str_list_free(&auth_method_list);
nt_status = make_auth_context_text_list(auth_context,
auth_method_list);
TALLOC_FREE(auth_method_list);
return nt_status;
}

View File

@ -124,7 +124,7 @@ machine %s. Error was : %s.\n", dc_name, nt_errstr(result)));
if (!lp_client_schannel()) {
/* We need to set up a creds chain on an unauthenticated netlogon pipe. */
uint32 neg_flags = NETLOGON_NEG_AUTH2_FLAGS;
uint32 neg_flags = NETLOGON_NEG_SELECT_AUTH2_FLAGS;
uint32 sec_chan_type = 0;
unsigned char machine_pwd[16];
const char *account_name;
@ -189,7 +189,7 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx,
struct sockaddr_storage *dc_ss)
{
NET_USER_INFO_3 info3;
struct netr_SamInfo3 *info3 = NULL;
struct cli_state *cli = NULL;
struct rpc_pipe_client *netlogon_pipe = NULL;
NTSTATUS nt_status = NT_STATUS_NO_LOGON_SERVERS;
@ -227,8 +227,6 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx,
saf_store( domain, cli->desthost );
ZERO_STRUCT(info3);
/*
* If this call succeeds, we now have lots of info about the user
* in the info3 structure.
@ -267,7 +265,7 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx,
user_info->smb_name,
domain,
server_info,
&info3);
info3);
if (NT_STATUS_IS_OK(nt_status)) {
if (user_info->was_mapped) {
@ -281,12 +279,14 @@ static NTSTATUS domain_client_validate(TALLOC_CTX *mem_ctx,
if ( !NT_STATUS_IS_OK(nt_status)) {
DEBUG(1, ("PAM account restriction prevents user login\n"));
cli_shutdown(cli);
TALLOC_FREE(info3);
return nt_status;
}
}
}
netsamlogon_cache_store( user_info->smb_name, &info3 );
netsamlogon_cache_store(user_info->smb_name, info3);
TALLOC_FREE(info3);
}
/* Note - once the cli stream is shutdown the mem_ctx used

View File

@ -186,8 +186,13 @@ NTSTATUS auth_ntlmssp_start(AUTH_NTLMSSP_STATE **auth_ntlmssp_state)
void auth_ntlmssp_end(AUTH_NTLMSSP_STATE **auth_ntlmssp_state)
{
TALLOC_CTX *mem_ctx = (*auth_ntlmssp_state)->mem_ctx;
TALLOC_CTX *mem_ctx;
if (*auth_ntlmssp_state == NULL) {
return;
}
mem_ctx = (*auth_ntlmssp_state)->mem_ctx;
if ((*auth_ntlmssp_state)->ntlmssp_state) {
ntlmssp_end(&(*auth_ntlmssp_state)->ntlmssp_state);
}

View File

@ -122,7 +122,7 @@ static bool logon_hours_ok(struct samu *sampass)
}
/****************************************************************************
Do a specific test for a struct samu being vaild for this connection
Do a specific test for a struct samu being valid for this connection
(ie not disabled, expired and the like).
****************************************************************************/

View File

@ -1422,7 +1422,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
const char *sent_nt_username,
const char *domain,
auth_serversupplied_info **server_info,
NET_USER_INFO_3 *info3)
struct netr_SamInfo3 *info3)
{
char zeros[16];
@ -1446,23 +1446,25 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
matches.
*/
sid_copy(&user_sid, &info3->dom_sid.sid);
if (!sid_append_rid(&user_sid, info3->user_rid)) {
sid_copy(&user_sid, info3->base.domain_sid);
if (!sid_append_rid(&user_sid, info3->base.rid)) {
return NT_STATUS_INVALID_PARAMETER;
}
sid_copy(&group_sid, &info3->dom_sid.sid);
if (!sid_append_rid(&group_sid, info3->group_rid)) {
sid_copy(&group_sid, info3->base.domain_sid);
if (!sid_append_rid(&group_sid, info3->base.primary_gid)) {
return NT_STATUS_INVALID_PARAMETER;
}
if (!(nt_username = unistr2_to_ascii_talloc(mem_ctx, &(info3->uni_user_name)))) {
nt_username = talloc_strdup(mem_ctx, info3->base.account_name.string);
if (!nt_username) {
/* If the server didn't give us one, just use the one we sent
* them */
nt_username = sent_nt_username;
}
if (!(nt_domain = unistr2_to_ascii_talloc(mem_ctx, &(info3->uni_logon_dom)))) {
nt_domain = talloc_strdup(mem_ctx, info3->base.domain.string);
if (!nt_domain) {
/* If the server didn't give us one, just use the one we sent
* them */
nt_domain = domain;
@ -1527,50 +1529,50 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
TALLOC_FREE(sam_account);
return NT_STATUS_UNSUCCESSFUL;
}
if (!pdb_set_fullname(sam_account,
unistr2_static(&(info3->uni_full_name)),
info3->base.full_name.string,
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_logon_script(sam_account,
unistr2_static(&(info3->uni_logon_script)),
info3->base.logon_script.string,
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_profile_path(sam_account,
unistr2_static(&(info3->uni_profile_path)),
info3->base.profile_path.string,
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_homedir(sam_account,
unistr2_static(&(info3->uni_home_dir)),
info3->base.home_directory.string,
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_dir_drive(sam_account,
unistr2_static(&(info3->uni_dir_drive)),
info3->base.home_drive.string,
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_acct_ctrl(sam_account, info3->acct_flags, PDB_CHANGED)) {
if (!pdb_set_acct_ctrl(sam_account, info3->base.acct_flags, PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_pass_last_set_time(
sam_account,
nt_time_to_unix(info3->pass_last_set_time),
nt_time_to_unix(info3->base.last_password_change),
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
@ -1578,7 +1580,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
if (!pdb_set_pass_can_change_time(
sam_account,
nt_time_to_unix(info3->pass_can_change_time),
nt_time_to_unix(info3->base.allow_password_change),
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
@ -1586,7 +1588,7 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
if (!pdb_set_pass_must_change_time(
sam_account,
nt_time_to_unix(info3->pass_must_change_time),
nt_time_to_unix(info3->base.force_password_change),
PDB_CHANGED)) {
TALLOC_FREE(sam_account);
return NT_STATUS_NO_MEMORY;
@ -1624,27 +1626,260 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx,
return nt_status;
}
result->login_server = unistr2_to_ascii_talloc(result,
&(info3->uni_logon_srv));
result->login_server = talloc_strdup(result,
info3->base.logon_server.string);
/* ensure we are never given NULL session keys */
ZERO_STRUCT(zeros);
if (memcmp(info3->user_sess_key, zeros, sizeof(zeros)) == 0) {
if (memcmp(info3->base.key.key, zeros, sizeof(zeros)) == 0) {
result->user_session_key = data_blob_null;
} else {
result->user_session_key = data_blob_talloc(
result, info3->user_sess_key,
sizeof(info3->user_sess_key));
result, info3->base.key.key,
sizeof(info3->base.key.key));
}
if (memcmp(info3->lm_sess_key, zeros, 8) == 0) {
if (memcmp(info3->base.LMSessKey.key, zeros, 8) == 0) {
result->lm_session_key = data_blob_null;
} else {
result->lm_session_key = data_blob_talloc(
result, info3->lm_sess_key,
sizeof(info3->lm_sess_key));
result, info3->base.LMSessKey.key,
sizeof(info3->base.LMSessKey.key));
}
result->was_mapped = username_was_mapped;
*server_info = result;
return NT_STATUS_OK;
}
/*****************************************************************************
Make a server_info struct from the wbcAuthUserInfo returned by a domain logon
******************************************************************************/
NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
const char *sent_nt_username,
const char *domain,
const struct wbcAuthUserInfo *info,
auth_serversupplied_info **server_info)
{
char zeros[16];
NTSTATUS nt_status = NT_STATUS_OK;
char *found_username = NULL;
const char *nt_domain;
const char *nt_username;
struct samu *sam_account = NULL;
DOM_SID user_sid;
DOM_SID group_sid;
bool username_was_mapped;
uint32_t i;
uid_t uid = (uid_t)-1;
gid_t gid = (gid_t)-1;
auth_serversupplied_info *result;
result = make_server_info(NULL);
if (result == NULL) {
DEBUG(4, ("make_server_info failed!\n"));
return NT_STATUS_NO_MEMORY;
}
/*
Here is where we should check the list of
trusted domains, and verify that the SID
matches.
*/
memcpy(&user_sid, &info->sids[0].sid, sizeof(user_sid));
memcpy(&group_sid, &info->sids[1].sid, sizeof(group_sid));
if (info->account_name) {
nt_username = talloc_strdup(result, info->account_name);
} else {
/* If the server didn't give us one, just use the one we sent
* them */
nt_username = talloc_strdup(result, sent_nt_username);
}
if (!nt_username) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (info->domain_name) {
nt_domain = talloc_strdup(result, info->domain_name);
} else {
/* If the server didn't give us one, just use the one we sent
* them */
nt_domain = talloc_strdup(result, domain);
}
if (!nt_domain) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
/* try to fill the SAM account.. If getpwnam() fails, then try the
add user script (2.2.x behavior).
We use the _unmapped_ username here in an attempt to provide
consistent username mapping behavior between kerberos and NTLM[SSP]
authentication in domain mode security. I.E. Username mapping
should be applied to the fully qualified username
(e.g. DOMAIN\user) and not just the login name. Yes this means we
called map_username() unnecessarily in make_user_info_map() but
that is how the current code is designed. Making the change here
is the least disruptive place. -- jerry */
if ( !(sam_account = samu_new( result )) ) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
/* this call will try to create the user if necessary */
nt_status = fill_sam_account(result, nt_domain, sent_nt_username,
&found_username, &uid, &gid, sam_account,
&username_was_mapped);
/* if we still don't have a valid unix account check for
'map to guest = bad uid' */
if (!NT_STATUS_IS_OK(nt_status)) {
TALLOC_FREE( result );
if ( lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID ) {
make_server_info_guest(server_info);
return NT_STATUS_OK;
}
return nt_status;
}
if (!pdb_set_nt_username(sam_account, nt_username, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_username(sam_account, nt_username, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_domain(sam_account, nt_domain, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_user_sid(sam_account, &user_sid, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_UNSUCCESSFUL;
}
if (!pdb_set_group_sid(sam_account, &group_sid, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_UNSUCCESSFUL;
}
if (!pdb_set_fullname(sam_account, info->full_name, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_logon_script(sam_account, info->logon_script, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_profile_path(sam_account, info->profile_path, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_homedir(sam_account, info->home_directory, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_dir_drive(sam_account, info->home_drive, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_acct_ctrl(sam_account, info->acct_flags, PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_pass_last_set_time(
sam_account,
nt_time_to_unix(info->pass_last_set_time),
PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_pass_can_change_time(
sam_account,
nt_time_to_unix(info->pass_can_change_time),
PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
if (!pdb_set_pass_must_change_time(
sam_account,
nt_time_to_unix(info->pass_must_change_time),
PDB_CHANGED)) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
/* save this here to _net_sam_logon() doesn't fail (it assumes a
valid struct samu) */
result->sam_account = sam_account;
result->unix_name = talloc_strdup(result, found_username);
result->login_server = talloc_strdup(result, info->logon_server);
/* Fill in the unix info we found on the way */
result->uid = uid;
result->gid = gid;
/* Create a 'combined' list of all SIDs we might want in the SD */
result->num_sids = info->num_sids - 2;
result->sids = talloc_array(result, DOM_SID, result->num_sids);
if (result->sids == NULL) {
TALLOC_FREE(result);
return NT_STATUS_NO_MEMORY;
}
for (i=0; i < result->num_sids; i++) {
memcpy(&result->sids[i], &info->sids[i+2].sid, sizeof(result->sids[i]));
}
/* ensure we are never given NULL session keys */
ZERO_STRUCT(zeros);
if (memcmp(info->user_session_key, zeros, sizeof(zeros)) == 0) {
result->user_session_key = data_blob_null;
} else {
result->user_session_key = data_blob_talloc(
result, info->user_session_key,
sizeof(info->user_session_key));
}
if (memcmp(info->lm_session_key, zeros, 8) == 0) {
result->lm_session_key = data_blob_null;
} else {
result->lm_session_key = data_blob_talloc(
result, info->lm_session_key,
sizeof(info->lm_session_key));
}
result->was_mapped = username_was_mapped;

View File

@ -25,31 +25,6 @@
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_AUTH
static NTSTATUS get_info3_from_ndr(TALLOC_CTX *mem_ctx, struct winbindd_response *response, NET_USER_INFO_3 *info3)
{
uint8 *info3_ndr;
size_t len = response->length - sizeof(struct winbindd_response);
prs_struct ps;
if (len > 0) {
info3_ndr = (uint8 *)response->extra_data.data;
if (!prs_init(&ps, len, mem_ctx, UNMARSHALL)) {
return NT_STATUS_NO_MEMORY;
}
prs_copy_data_in(&ps, (char *)info3_ndr, len);
prs_set_offset(&ps,0);
if (!net_io_user_info3("", info3, &ps, 1, 3, False)) {
DEBUG(2, ("get_info3_from_ndr: could not parse info3 struct!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
prs_mem_free(&ps);
return NT_STATUS_OK;
} else {
DEBUG(2, ("get_info3_from_ndr: No info3 struct found!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
}
/* Authenticate a user with a challenge/response */
static NTSTATUS check_winbind_security(const struct auth_context *auth_context,
@ -58,11 +33,11 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context,
const auth_usersupplied_info *user_info,
auth_serversupplied_info **server_info)
{
struct winbindd_request request;
struct winbindd_response response;
NSS_STATUS result;
NTSTATUS nt_status;
NET_USER_INFO_3 info3;
wbcErr wbc_status;
struct wbcAuthUserParams params;
struct wbcAuthUserInfo *info = NULL;
struct wbcAuthErrorInfo *err = NULL;
if (!user_info) {
return NT_STATUS_INVALID_PARAMETER;
@ -82,36 +57,34 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context,
/* Send off request */
ZERO_STRUCT(request);
ZERO_STRUCT(response);
params.account_name = user_info->smb_name;
params.domain_name = user_info->domain;
params.workstation_name = user_info->wksta_name;
request.flags = WBFLAG_PAM_INFO3_NDR;
params.flags = 0;
params.parameter_control= user_info->logon_parameters;
request.data.auth_crap.logon_parameters = user_info->logon_parameters;
params.level = WBC_AUTH_USER_LEVEL_RESPONSE;
fstrcpy(request.data.auth_crap.user, user_info->smb_name);
fstrcpy(request.data.auth_crap.domain, user_info->domain);
fstrcpy(request.data.auth_crap.workstation, user_info->wksta_name);
memcpy(params.password.response.challenge,
auth_context->challenge.data,
sizeof(params.password.response.challenge));
memcpy(request.data.auth_crap.chal, auth_context->challenge.data, sizeof(request.data.auth_crap.chal));
request.data.auth_crap.lm_resp_len = MIN(user_info->lm_resp.length,
sizeof(request.data.auth_crap.lm_resp));
request.data.auth_crap.nt_resp_len = MIN(user_info->nt_resp.length,
sizeof(request.data.auth_crap.nt_resp));
memcpy(request.data.auth_crap.lm_resp, user_info->lm_resp.data,
request.data.auth_crap.lm_resp_len);
memcpy(request.data.auth_crap.nt_resp, user_info->nt_resp.data,
request.data.auth_crap.nt_resp_len);
params.password.response.nt_length = user_info->nt_resp.length;
params.password.response.nt_data = user_info->nt_resp.data;
params.password.response.lm_length = user_info->lm_resp.length;
params.password.response.lm_data = user_info->lm_resp.data;
/* we are contacting the privileged pipe */
become_root();
result = winbindd_priv_request_response(WINBINDD_PAM_AUTH_CRAP,
&request, &response);
wbc_status = wbcAuthenticateUserEx(&params, &info, &err);
unbecome_root();
if ( result == NSS_STATUS_UNAVAIL ) {
if (wbc_status == WBC_ERR_NO_MEMORY) {
return NT_STATUS_NO_MEMORY;
}
if (wbc_status == WBC_ERR_WINBIND_NOT_AVAILABLE) {
struct auth_methods *auth_method =
(struct auth_methods *)my_private_data;
@ -123,27 +96,29 @@ static NTSTATUS check_winbind_security(const struct auth_context *auth_context,
DEBUG(0,("check_winbind_security: ERROR! my_private_data == NULL!\n"));
}
nt_status = NT_STATUS(response.data.auth.nt_status);
if (result == NSS_STATUS_SUCCESS && response.extra_data.data) {
if (NT_STATUS_IS_OK(nt_status)) {
if (NT_STATUS_IS_OK(nt_status = get_info3_from_ndr(mem_ctx, &response, &info3))) {
nt_status = make_server_info_info3(mem_ctx,
user_info->smb_name, user_info->domain,
server_info, &info3);
}
if (NT_STATUS_IS_OK(nt_status)) {
if (user_info->was_mapped) {
(*server_info)->was_mapped = user_info->was_mapped;
}
}
}
} else if (NT_STATUS_IS_OK(nt_status)) {
nt_status = NT_STATUS_NO_LOGON_SERVERS;
if (wbc_status == WBC_ERR_AUTH_ERROR) {
nt_status = NT_STATUS(err->nt_status);
wbcFreeMemory(err);
return nt_status;
}
if (!WBC_ERROR_IS_OK(wbc_status)) {
return NT_STATUS_LOGON_FAILURE;
}
nt_status = make_server_info_wbcAuthUserInfo(mem_ctx,
user_info->smb_name,
user_info->domain,
info, server_info);
wbcFreeMemory(info);
if (!NT_STATUS_IS_OK(nt_status)) {
return nt_status;
}
if (user_info->was_mapped) {
(*server_info)->was_mapped = user_info->was_mapped;
}
SAFE_FREE(response.extra_data.data);
return nt_status;
}

View File

@ -3,11 +3,13 @@
* Copyright (C) Igor Mammedov (niallain@gmail.com) 2007
*
* Used by /sbin/request-key for handling
* cifs upcall for kerberos authorization of access to share.
* cifs upcall for kerberos authorization of access to share and
* cifs upcall for DFS srver name resolving (IPv4/IPv6 aware).
* You should have keyutils installed and add following line to
* /etc/request-key.conf file
create cifs.spnego * * /usr/local/sbin/cifs.spnego [-v][-c] %k
create cifs.resolver * * /usr/local/sbin/cifs.spnego [-v] %k
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -27,7 +29,7 @@ create cifs.spnego * * /usr/local/sbin/cifs.spnego [-v][-c] %k
#include "cifs_spnego.h"
const char* CIFSSPNEGO_VERSION="1.0";
const char *CIFSSPNEGO_VERSION = "1.1";
static const char *prog = "cifs.spnego";
typedef enum _secType {
KRB5,
@ -146,6 +148,58 @@ int decode_key_description(const char *desc, int *ver, secType_t * sec,
return retval;
}
int cifs_resolver(const key_serial_t key, const char *key_descr)
{
int c;
struct addrinfo *addr;
char ip[INET6_ADDRSTRLEN];
void *p;
const char *keyend = key_descr;
/* skip next 4 ';' delimiters to get to description */
for (c = 1; c <= 4; c++) {
keyend = index(keyend+1, ';');
if (!keyend) {
syslog(LOG_WARNING, "invalid key description: %s",
key_descr);
return 1;
}
}
keyend++;
/* resolve name to ip */
c = getaddrinfo(keyend, NULL, NULL, &addr);
if (c) {
syslog(LOG_WARNING, "unable to resolve hostname: %s [%s]",
keyend, gai_strerror(c));
return 1;
}
/* conver ip to string form */
if (addr->ai_family == AF_INET) {
p = &(((struct sockaddr_in *)addr->ai_addr)->sin_addr);
} else {
p = &(((struct sockaddr_in6 *)addr->ai_addr)->sin6_addr);
}
if (!inet_ntop(addr->ai_family, p, ip, sizeof(ip))) {
syslog(LOG_WARNING, "%s: inet_ntop: %s",
__FUNCTION__, strerror(errno));
freeaddrinfo(addr);
return 1;
}
/* setup key */
c = keyctl_instantiate(key, ip, strlen(ip)+1, 0);
if (c == -1) {
syslog(LOG_WARNING, "%s: keyctl_instantiate: %s",
__FUNCTION__, strerror(errno));
freeaddrinfo(addr);
return 1;
}
freeaddrinfo(addr);
return 0;
}
int main(const int argc, char *const argv[])
{
struct cifs_spnego_msg *keydata = NULL;
@ -199,6 +253,11 @@ int main(const int argc, char *const argv[])
goto out;
}
if (strncmp(buf, "cifs.resolver", sizeof("cifs.resolver")-1) == 0) {
rc = cifs_resolver(key, buf);
goto out;
}
rc = decode_key_description(buf, &kernel_upcall_version, &sectype,
&hostname, &uid);
if ((rc & DKD_MUSTHAVE_SET) != DKD_MUSTHAVE_SET) {

View File

@ -308,6 +308,17 @@ static int cmd_pwd(void)
return 0;
}
/****************************************************************************
Ensure name has correct directory separators.
****************************************************************************/
static void normalize_name(char *newdir)
{
if (!(cli->posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP)) {
string_replace(newdir,'/','\\');
}
}
/****************************************************************************
Change directory - inner section.
****************************************************************************/
@ -329,7 +340,8 @@ static int do_cd(const char *new_dir)
TALLOC_FREE(ctx);
return 1;
}
string_replace(newdir,'/','\\');
normalize_name(newdir);
/* Save the current directory in case the new directory is invalid */
@ -349,17 +361,16 @@ static int do_cd(const char *new_dir)
if (!new_cd) {
goto out;
}
if ((new_cd[0] != '\0') && (*(new_cd+strlen(new_cd)-1) != CLI_DIRSEP_CHAR)) {
new_cd = talloc_asprintf_append(new_cd, CLI_DIRSEP_STR);
if (!new_cd) {
goto out;
}
}
/* Ensure cur_dir ends in a DIRSEP */
if ((new_cd[0] != '\0') && (*(new_cd+strlen(new_cd)-1) != CLI_DIRSEP_CHAR)) {
new_cd = talloc_asprintf_append(new_cd, CLI_DIRSEP_STR);
if (!new_cd) {
goto out;
}
client_set_cur_dir(new_cd);
}
if (!new_cd) {
goto out;
}
client_set_cur_dir(new_cd);
new_cd = clean_name(ctx, new_cd);
client_set_cur_dir(new_cd);
@ -851,26 +862,15 @@ static int cmd_dir(void)
int rc = 1;
dir_total = 0;
if (strcmp(client_get_cur_dir(), CLI_DIRSEP_STR) != 0) {
mask = talloc_strdup(ctx, client_get_cur_dir());
if (!mask) {
return 1;
}
if ((mask[0] != '\0') && (mask[strlen(mask)-1]!=CLI_DIRSEP_CHAR)) {
mask = talloc_asprintf_append(mask, CLI_DIRSEP_STR);
}
} else {
mask = talloc_strdup(ctx, CLI_DIRSEP_STR);
}
mask = talloc_strdup(ctx, client_get_cur_dir());
if (!mask) {
return 1;
}
if (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
string_replace(buf,'/','\\');
normalize_name(buf);
if (*buf == CLI_DIRSEP_CHAR) {
mask = talloc_strdup(ctx, buf + 1);
mask = talloc_strdup(ctx, buf);
} else {
mask = talloc_asprintf_append(mask, buf);
}
@ -920,7 +920,7 @@ static int cmd_du(void)
}
if (next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
string_replace(buf,'/','\\');
normalize_name(buf);
if (*buf == CLI_DIRSEP_CHAR) {
mask = talloc_strdup(ctx, buf);
} else {
@ -964,12 +964,20 @@ static int cmd_echo(void)
Get a file from rname to lname
****************************************************************************/
static NTSTATUS writefile_sink(char *buf, size_t n, void *priv)
{
int *pfd = (int *)priv;
if (writefile(*pfd, buf, n) == -1) {
return map_nt_error_from_unix(errno);
}
return NT_STATUS_OK;
}
static int do_get(const char *rname, const char *lname_in, bool reget)
{
TALLOC_CTX *ctx = talloc_tos();
int handle = 0, fnum;
bool newhandle = false;
char *data = NULL;
struct timeval tp_start;
int read_size = io_bufsize;
uint16 attr;
@ -980,6 +988,7 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
struct cli_state *targetcli = NULL;
char *targetname = NULL;
char *lname = NULL;
NTSTATUS status;
lname = talloc_strdup(ctx, lname_in);
if (!lname) {
@ -1038,36 +1047,15 @@ static int do_get(const char *rname, const char *lname_in, bool reget)
DEBUG(1,("getting file %s of size %.0f as %s ",
rname, (double)size, lname));
if(!(data = (char *)SMB_MALLOC(read_size))) {
d_printf("malloc fail for size %d\n", read_size);
status = cli_pull(targetcli, fnum, start, size, 1024*1024,
writefile_sink, (void *)&handle, &nread);
if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr, "parallel_read returned %s\n",
nt_errstr(status));
cli_close(targetcli, fnum);
return 1;
}
while (1) {
int n = cli_read(targetcli, fnum, data, nread + start, read_size);
if (n <= 0)
break;
if (writefile(handle,data, n) != n) {
d_printf("Error writing local file\n");
rc = 1;
break;
}
nread += n;
}
if (nread + start < size) {
DEBUG (0, ("Short read when getting file %s. Only got %ld bytes.\n",
rname, (long)nread));
rc = 1;
}
SAFE_FREE(data);
if (!cli_close(targetcli, fnum)) {
d_printf("Error %s closing remote file\n",cli_errstr(cli));
rc = 1;
@ -1112,10 +1100,7 @@ static int cmd_get(void)
char *rname = NULL;
char *fname = NULL;
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
CLI_DIRSEP_STR);
rname = talloc_strdup(ctx, client_get_cur_dir());
if (!rname) {
return 1;
}
@ -1262,10 +1247,7 @@ static int cmd_more(void)
int fd;
int rc = 0;
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
CLI_DIRSEP_STR);
rname = talloc_strdup(ctx, client_get_cur_dir());
if (!rname) {
return 1;
}
@ -1334,15 +1316,6 @@ static int cmd_mget(void)
if (!mget_mask) {
return 1;
}
if ((mget_mask[0] != '\0') &&
(mget_mask[strlen(mget_mask)-1]!=CLI_DIRSEP_CHAR)) {
mget_mask = talloc_asprintf_append(mget_mask,
CLI_DIRSEP_STR);
if (!mget_mask) {
return 1;
}
}
if (*buf == CLI_DIRSEP_CHAR) {
mget_mask = talloc_strdup(ctx, buf);
} else {
@ -1356,18 +1329,9 @@ static int cmd_mget(void)
}
if (!*mget_mask) {
mget_mask = talloc_strdup(ctx, client_get_cur_dir());
if (!mget_mask) {
return 1;
}
if(mget_mask[strlen(mget_mask)-1]!=CLI_DIRSEP_CHAR) {
mget_mask = talloc_asprintf_append(mget_mask,
CLI_DIRSEP_STR);
if (!mget_mask) {
return 1;
}
}
mget_mask = talloc_asprintf_append(mget_mask, "*");
mget_mask = talloc_asprintf(ctx,
"%s*",
client_get_cur_dir());
if (!mget_mask) {
return 1;
}
@ -1463,6 +1427,7 @@ static int cmd_mkdir(void)
struct cli_state *targetcli;
char *targetname = NULL;
char *p = NULL;
char *saveptr;
ddir2 = talloc_strdup(ctx, "");
if (!ddir2) {
@ -1478,7 +1443,7 @@ static int cmd_mkdir(void)
return 1;
}
trim_char(ddir,'.','\0');
p = strtok(ddir,"/\\");
p = strtok_r(ddir, "/\\", &saveptr);
while (p) {
ddir2 = talloc_asprintf_append(ddir2, p);
if (!ddir2) {
@ -1491,7 +1456,7 @@ static int cmd_mkdir(void)
if (!ddir2) {
return 1;
}
p = strtok(NULL,"/\\");
p = strtok_r(NULL, "/\\", &saveptr);
}
} else {
do_mkdir(mask);
@ -1527,6 +1492,92 @@ static int cmd_altname(void)
return 0;
}
/****************************************************************************
Show all info we can get
****************************************************************************/
static int do_allinfo(const char *name)
{
fstring altname;
struct timespec b_time, a_time, m_time, c_time;
SMB_OFF_T size;
uint16_t mode;
SMB_INO_T ino;
NTTIME tmp;
unsigned int num_streams;
struct stream_struct *streams;
unsigned int i;
if (!NT_STATUS_IS_OK(cli_qpathinfo_alt_name(cli, name, altname))) {
d_printf("%s getting alt name for %s\n",
cli_errstr(cli),name);
return false;
}
d_printf("altname: %s\n", altname);
if (!cli_qpathinfo2(cli, name, &b_time, &a_time, &m_time, &c_time,
&size, &mode, &ino)) {
d_printf("%s getting pathinfo for %s\n",
cli_errstr(cli),name);
return false;
}
unix_timespec_to_nt_time(&tmp, b_time);
d_printf("create_time: %s\n", nt_time_string(talloc_tos(), tmp));
unix_timespec_to_nt_time(&tmp, a_time);
d_printf("access_time: %s\n", nt_time_string(talloc_tos(), tmp));
unix_timespec_to_nt_time(&tmp, m_time);
d_printf("write_time: %s\n", nt_time_string(talloc_tos(), tmp));
unix_timespec_to_nt_time(&tmp, c_time);
d_printf("change_time: %s\n", nt_time_string(talloc_tos(), tmp));
if (!cli_qpathinfo_streams(cli, name, talloc_tos(), &num_streams,
&streams)) {
d_printf("%s getting streams for %s\n",
cli_errstr(cli),name);
return false;
}
for (i=0; i<num_streams; i++) {
d_printf("stream: [%s], %lld bytes\n", streams[i].name,
(unsigned long long)streams[i].size);
}
return 0;
}
/****************************************************************************
Show all info we can get
****************************************************************************/
static int cmd_allinfo(void)
{
TALLOC_CTX *ctx = talloc_tos();
char *name;
char *buf;
name = talloc_strdup(ctx, client_get_cur_dir());
if (!name) {
return 1;
}
if (!next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) {
d_printf("allinfo <file>\n");
return 1;
}
name = talloc_asprintf_append(name, buf);
if (!name) {
return 1;
}
do_allinfo(name);
return 0;
}
/****************************************************************************
Put a single file.
****************************************************************************/
@ -1673,10 +1724,7 @@ static int cmd_put(void)
char *rname;
char *buf;
rname = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
CLI_DIRSEP_STR);
rname = talloc_strdup(ctx, client_get_cur_dir());
if (!rname) {
return 1;
}
@ -1893,10 +1941,10 @@ static int cmd_mput(void)
break;
} else { /* Yes */
SAFE_FREE(rname);
if(asprintf(&rname, "%s%s", cur_dir, lname) < 0) {
if(asprintf(&rname, "%s%s", client_get_cur_dir(), lname) < 0) {
break;
}
string_replace(rname,'/','\\');
normalize_name(rname);
if (!cli_chkpath(cli, rname) &&
!do_mkdir(rname)) {
DEBUG (0, ("Unable to make dir, skipping..."));
@ -1920,12 +1968,12 @@ static int cmd_mput(void)
/* Yes */
SAFE_FREE(rname);
if (asprintf(&rname, "%s%s", cur_dir, lname) < 0) {
if (asprintf(&rname, "%s%s", client_get_cur_dir(), lname) < 0) {
break;
}
}
string_replace(rname,'/','\\');
normalize_name(rname);
do_put(rname, lname, false);
}
@ -3469,10 +3517,7 @@ static int cmd_reget(void)
char *fname = NULL;
char *p = NULL;
remote_name = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
CLI_DIRSEP_STR);
remote_name = talloc_strdup(ctx, client_get_cur_dir());
if (!remote_name) {
return 1;
}
@ -3511,10 +3556,7 @@ static int cmd_reput(void)
char *buf;
SMB_STRUCT_STAT st;
remote_name = talloc_asprintf(ctx,
"%s%s",
client_get_cur_dir(),
CLI_DIRSEP_STR);
remote_name = talloc_strdup(ctx, client_get_cur_dir());
if (!remote_name) {
return 1;
}
@ -3839,6 +3881,8 @@ static struct {
char compl_args[2]; /* Completion argument info */
} commands[] = {
{"?",cmd_help,"[command] give help on a command",{COMPL_NONE,COMPL_NONE}},
{"allinfo",cmd_allinfo,"<file> show all available info",
{COMPL_NONE,COMPL_NONE}},
{"altname",cmd_altname,"<file> show alt name",{COMPL_NONE,COMPL_NONE}},
{"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit",{COMPL_NONE,COMPL_NONE}},
{"blocksize",cmd_block,"blocksize <number> (default 20)",{COMPL_NONE,COMPL_NONE}},
@ -4069,7 +4113,7 @@ static void completion_remote_filter(const char *mnt,
return;
}
if (f->mode & aDIR) {
tmp = talloc_asprintf_append(tmp, "/");
tmp = talloc_asprintf_append(tmp, CLI_DIRSEP_STR);
}
if (!tmp) {
TALLOC_FREE(ctx);
@ -4333,9 +4377,30 @@ static void readline_callback(void)
session keepalives and then drop them here.
*/
if (FD_ISSET(cli->fd,&fds)) {
if (receive_smb_raw(cli->fd,cli->inbuf,0,0,&cli->smb_rw_error) == -1) {
DEBUG(0, ("Read from server failed, maybe it closed the "
"connection\n"));
NTSTATUS status;
size_t len;
set_smb_read_error(&cli->smb_rw_error, SMB_READ_OK);
status = receive_smb_raw(cli->fd, cli->inbuf, 0, 0, &len);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Read from server failed, maybe it closed "
"the connection\n"));
if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE)) {
set_smb_read_error(&cli->smb_rw_error,
SMB_READ_EOF);
return;
}
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) {
set_smb_read_error(&cli->smb_rw_error,
SMB_READ_TIMEOUT);
return;
}
set_smb_read_error(&cli->smb_rw_error, SMB_READ_ERROR);
return;
}
if(CVAL(cli->inbuf,0) != SMBkeepalive) {

View File

@ -513,6 +513,7 @@ static bool ensurepath(const char *fname)
char *partpath, *ffname;
const char *p=fname;
char *basehack;
char *saveptr;
DEBUG(5, ( "Ensurepath called with: %s\n", fname));
@ -528,7 +529,7 @@ static bool ensurepath(const char *fname)
*partpath = 0;
/* fname copied to ffname so can strtok */
/* fname copied to ffname so can strtok_r */
safe_strcpy(ffname, fname, strlen(fname));
@ -541,7 +542,7 @@ static bool ensurepath(const char *fname)
*basehack='\0';
}
p=strtok(ffname, "\\");
p=strtok_r(ffname, "\\", &saveptr);
while (p) {
safe_strcat(partpath, p, strlen(fname) + 1);
@ -558,7 +559,7 @@ static bool ensurepath(const char *fname)
}
safe_strcat(partpath, "\\", strlen(fname) + 1);
p = strtok(NULL,"/\\");
p = strtok_r(NULL, "/\\", &saveptr);
}
SAFE_FREE(partpath);
@ -1470,8 +1471,10 @@ int cmd_tar(void)
}
argl=toktocliplist(&argcl, NULL);
if (!tar_parseargs(argcl, argl, buf, 0))
if (!tar_parseargs(argcl, argl, buf, 0)) {
SAFE_FREE(argl);
return 1;
}
ret = process_tar();
SAFE_FREE(argl);

View File

@ -37,6 +37,7 @@
#include <string.h>
#include <mntent.h>
#include <fcntl.h>
#include <limits.h>
#define MOUNT_CIFS_VERSION_MAJOR "1"
#define MOUNT_CIFS_VERSION_MINOR "11"
@ -62,8 +63,6 @@
#define MS_BIND 4096
#endif
#define MAX_UNC_LEN 1024
#define CONST_DISCARD(type, ptr) ((type) ((void *) (ptr)))
const char *thisprogram;
@ -75,6 +74,7 @@ static int got_ip = 0;
static int got_unc = 0;
static int got_uid = 0;
static int got_gid = 0;
static int free_share_name = 0;
static char * user_name = NULL;
static char * mountpassword = NULL;
char * domain_name = NULL;
@ -205,8 +205,10 @@ static int open_cred_file(char * file_name)
/* go past equals sign */
temp_val++;
for(length = 0;length<4087;length++) {
if(temp_val[length] == '\n')
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
break;
}
}
if(length > 4086) {
printf("mount.cifs failed due to malformed username in credentials file");
@ -229,8 +231,10 @@ static int open_cred_file(char * file_name)
/* go past equals sign */
temp_val++;
for(length = 0;length<65;length++) {
if(temp_val[length] == '\n')
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
break;
}
}
if(length > 64) {
printf("mount.cifs failed: password in credentials file too long\n");
@ -258,8 +262,10 @@ static int open_cred_file(char * file_name)
if(verboseflag)
printf("\nDomain %s\n",temp_val);
for(length = 0;length<65;length++) {
if(temp_val[length] == '\n')
break;
if ((temp_val[length] == '\n')
|| (temp_val[length] == '\0')) {
break;
}
}
if(length > 64) {
printf("mount.cifs failed: domain in credentials file too long\n");
@ -831,27 +837,17 @@ static char * check_for_domain(char **ppuser)
return domainnm;
}
/* replace all occurances of "from" in a string with "to" */
static void replace_char(char *string, char from, char to)
{
while (string) {
string = strchr(string, from);
if (string)
*string = to;
}
}
/* Note that caller frees the returned buffer if necessary */
static char * parse_server(char ** punc_name)
{
char * unc_name = *punc_name;
int length = strnlen(unc_name, MAX_UNC_LEN);
int length = strnlen(unc_name,1024);
char * share;
char * ipaddress_string = NULL;
struct hostent * host_entry = NULL;
struct in_addr server_ipaddr;
if(length > (MAX_UNC_LEN - 1)) {
if(length > 1023) {
printf("mount error: UNC name too long");
return NULL;
}
@ -870,6 +866,7 @@ static char * parse_server(char ** punc_name)
/* check for nfs syntax ie server:share */
share = strchr(unc_name,':');
if(share) {
free_share_name = 1;
*punc_name = (char *)malloc(length+3);
if(*punc_name == NULL) {
/* put the original string back if
@ -877,9 +874,9 @@ static char * parse_server(char ** punc_name)
*punc_name = unc_name;
return NULL;
}
*share = '/';
strncpy((*punc_name)+2,unc_name,length);
free(unc_name);
unc_name = *punc_name;
unc_name[length+2] = 0;
goto continue_unc_parsing;
@ -890,21 +887,18 @@ static char * parse_server(char ** punc_name)
}
} else {
continue_unc_parsing:
unc_name[0] = '\\';
unc_name[1] = '\\';
unc_name[0] = '/';
unc_name[1] = '/';
unc_name += 2;
/* convert any '/' in unc to '\\' */
replace_char(unc_name, '/', '\\');
if ((share = strchr(unc_name,'\\'))) {
if ((share = strchr(unc_name, '/')) ||
(share = strchr(unc_name,'\\'))) {
*share = 0; /* temporarily terminate the string */
share += 1;
if(got_ip == 0) {
host_entry = gethostbyname(unc_name);
}
*(share - 1) = '\\'; /* put delimiter back */
if ((prefixpath = strchr(share, '\\'))) {
*(share - 1) = '/'; /* put the slash back */
if ((prefixpath = strchr(share, '/'))) {
*prefixpath = 0; /* permanently terminate the string */
if (!strlen(++prefixpath))
prefixpath = NULL; /* this needs to be done explicitly */
@ -969,25 +963,6 @@ static struct option longopts[] = {
{ NULL, 0, NULL, 0 }
};
/* convert a string to uppercase. return false if the string
* wasn't ASCII or was a NULL ptr */
static int
uppercase_string(char *string)
{
if (!string)
return 0;
while (*string) {
/* check for unicode */
if ((unsigned char) string[0] & 0x80)
return 0;
*string = toupper((unsigned char) *string);
string++;
}
return 1;
}
int main(int argc, char ** argv)
{
int c;
@ -1000,7 +975,6 @@ int main(int argc, char ** argv)
char * options = NULL;
char * resolved_path = NULL;
char * temp;
char * dev_name;
int rc;
int rsize = 0;
int wsize = 0;
@ -1037,16 +1011,8 @@ int main(int argc, char ** argv)
printf(" node: %s machine: %s sysname %s domain %s\n", sysinfo.nodename,sysinfo.machine,sysinfo.sysname,sysinfo.domainname);
#endif */
if(argc > 2) {
dev_name = argv[1];
share_name = strndup(argv[1], MAX_UNC_LEN);
if (share_name == NULL) {
fprintf(stderr, "%s: %s", argv[0], strerror(ENOMEM));
exit(1);
}
share_name = argv[1];
mountpoint = argv[2];
} else {
mount_cifs_usage();
exit(1);
}
/* add sharename in opts string as unc= parm */
@ -1186,7 +1152,7 @@ int main(int argc, char ** argv)
}
}
if((argc < 3) || (dev_name == NULL) || (mountpoint == NULL)) {
if((argc < 3) || (share_name == NULL) || (mountpoint == NULL)) {
mount_cifs_usage();
exit(1);
}
@ -1344,12 +1310,10 @@ mount_retry:
}
if(verboseflag)
printf("\nmount.cifs kernel mount options %s \n",options);
/* convert all '\\' to '/' so that /proc/mounts looks pretty */
replace_char(dev_name, '\\', '/');
if(mount(dev_name, mountpoint, "cifs", flags, options)) {
if(mount(share_name, mountpoint, "cifs", flags, options)) {
/* remember to kill daemon on error */
char * tmp;
switch (errno) {
case 0:
printf("mount failed but no error number set\n");
@ -1360,9 +1324,12 @@ mount_retry:
case ENXIO:
if(retry == 0) {
retry = 1;
if (uppercase_string(dev_name) &&
uppercase_string(share_name) &&
uppercase_string(prefixpath)) {
tmp = share_name;
while (*tmp && !(((unsigned char)tmp[0]) & 0x80)) {
*tmp = toupper((unsigned char)*tmp);
tmp++;
}
if(!*tmp) {
printf("retrying with upper case share name\n");
goto mount_retry;
}
@ -1376,7 +1343,7 @@ mount_retry:
} else {
pmntfile = setmntent(MOUNTED, "a+");
if(pmntfile) {
mountent.mnt_fsname = dev_name;
mountent.mnt_fsname = share_name;
mountent.mnt_dir = mountpoint;
mountent.mnt_type = CONST_DISCARD(char *,"cifs");
mountent.mnt_opts = (char *)malloc(220);
@ -1436,6 +1403,8 @@ mount_exit:
free(resolved_path);
}
free(share_name);
if(free_share_name) {
free(share_name);
}
return rc;
}

View File

@ -1,331 +0,0 @@
/*
* smbmnt.c
*
* Copyright (C) 1995-1998 by Paal-Kr. Engstad and Volker Lendecke
* extensively modified by Tridge
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
*/
#define SMBMOUNT_MALLOC 1
#include "includes.h"
#include <mntent.h>
#include <sys/utsname.h>
#include <asm/types.h>
#include <asm/posix_types.h>
#include <linux/smb.h>
#include <linux/smb_mount.h>
#include <asm/unistd.h>
#ifndef MS_MGC_VAL
/* This may look strange but MS_MGC_VAL is what we are looking for and
is what we need from <linux/fs.h> under libc systems and is
provided in standard includes on glibc systems. So... We
switch on what we need... */
#include <linux/fs.h>
#endif
static uid_t mount_uid;
static gid_t mount_gid;
static int mount_ro;
static unsigned mount_fmask;
static unsigned mount_dmask;
static int user_mount;
static char *options;
static void
help(void)
{
printf("\n");
printf("Usage: smbmnt mount-point [options]\n");
printf("Version %s\n\n",SAMBA_VERSION_STRING);
printf("-s share share name on server\n"
"-r mount read-only\n"
"-u uid mount as uid\n"
"-g gid mount as gid\n"
"-f mask permission mask for files\n"
"-d mask permission mask for directories\n"
"-o options name=value, list of options\n"
"-h print this help text\n");
}
static int
parse_args(int argc, char *argv[], struct smb_mount_data *data, char **share)
{
int opt;
while ((opt = getopt (argc, argv, "s:u:g:rf:d:o:")) != EOF)
{
switch (opt)
{
case 's':
*share = optarg;
break;
case 'u':
if (!user_mount) {
mount_uid = strtol(optarg, NULL, 0);
}
break;
case 'g':
if (!user_mount) {
mount_gid = strtol(optarg, NULL, 0);
}
break;
case 'r':
mount_ro = 1;
break;
case 'f':
mount_fmask = strtol(optarg, NULL, 8);
break;
case 'd':
mount_dmask = strtol(optarg, NULL, 8);
break;
case 'o':
options = optarg;
break;
default:
return -1;
}
}
return 0;
}
static char *
fullpath(const char *p)
{
char path[PATH_MAX+1];
if (strlen(p) > PATH_MAX) {
return NULL;
}
if (realpath(p, path) == NULL) {
fprintf(stderr,"Failed to find real path for mount point %s: %s\n",
p, strerror(errno));
exit(1);
}
return strdup(path);
}
/* Check whether user is allowed to mount on the specified mount point. If it's
OK then we change into that directory - this prevents race conditions */
static int mount_ok(char *mount_point)
{
struct stat st;
if (chdir(mount_point) != 0) {
return -1;
}
if (stat(".", &st) != 0) {
return -1;
}
if (!S_ISDIR(st.st_mode)) {
errno = ENOTDIR;
return -1;
}
if ((getuid() != 0) &&
((getuid() != st.st_uid) ||
((st.st_mode & S_IRWXU) != S_IRWXU))) {
errno = EPERM;
return -1;
}
return 0;
}
/* Tries to mount using the appropriate format. For 2.2 the struct,
for 2.4 the ascii version. */
static int
do_mount(char *share_name, unsigned int flags, struct smb_mount_data *data)
{
char *opts;
struct utsname uts;
char *release, *major, *minor;
char *data1, *data2;
int ret;
if (asprintf(&opts,
"version=7,uid=%d,gid=%d,file_mode=0%o,dir_mode=0%o,%s",
mount_uid, mount_gid, data->file_mode,
data->dir_mode,options) < 0) {
return -1;
}
uname(&uts);
release = uts.release;
major = strtok(release, ".");
minor = strtok(NULL, ".");
if (major && minor && atoi(major) == 2 && atoi(minor) < 4) {
/* < 2.4, assume struct */
data1 = (char *) data;
data2 = opts;
} else {
/* >= 2.4, assume ascii but fall back on struct */
data1 = opts;
data2 = (char *) data;
}
if (mount(share_name, ".", "smbfs", flags, data1) == 0) {
SAFE_FREE(opts);
return 0;
}
ret = mount(share_name, ".", "smbfs", flags, data2);
SAFE_FREE(opts);
return ret;
}
int main(int argc, char *argv[])
{
char *mount_point, *share_name = NULL;
FILE *mtab;
int fd;
unsigned int flags;
struct smb_mount_data data;
struct mntent ment;
memset(&data, 0, sizeof(struct smb_mount_data));
if (argc < 2) {
help();
exit(1);
}
if (argv[1][0] == '-') {
help();
exit(1);
}
if (getuid() != 0) {
user_mount = 1;
}
if (geteuid() != 0) {
fprintf(stderr, "smbmnt must be installed suid root for direct user mounts (%d,%d)\n", getuid(), geteuid());
exit(1);
}
mount_uid = getuid();
mount_gid = getgid();
mount_fmask = umask(0);
umask(mount_fmask);
mount_fmask = ~mount_fmask;
mount_point = fullpath(argv[1]);
argv += 1;
argc -= 1;
if (mount_ok(mount_point) != 0) {
fprintf(stderr, "cannot mount on %s: %s\n",
mount_point, strerror(errno));
exit(1);
}
data.version = SMB_MOUNT_VERSION;
/* getuid() gives us the real uid, who may umount the fs */
data.mounted_uid = getuid();
if (parse_args(argc, argv, &data, &share_name) != 0) {
help();
return -1;
}
data.uid = mount_uid; // truncates to 16-bits here!!!
data.gid = mount_gid;
data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & mount_fmask;
data.dir_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & mount_dmask;
if (mount_dmask == 0) {
data.dir_mode = data.file_mode;
if ((data.dir_mode & S_IRUSR) != 0)
data.dir_mode |= S_IXUSR;
if ((data.dir_mode & S_IRGRP) != 0)
data.dir_mode |= S_IXGRP;
if ((data.dir_mode & S_IROTH) != 0)
data.dir_mode |= S_IXOTH;
}
flags = MS_MGC_VAL | MS_NOSUID | MS_NODEV;
if (mount_ro) flags |= MS_RDONLY;
if (do_mount(share_name, flags, &data) < 0) {
switch (errno) {
case ENODEV:
fprintf(stderr, "ERROR: smbfs filesystem not supported by the kernel\n");
break;
default:
perror("mount error");
}
fprintf(stderr, "Please refer to the smbmnt(8) manual page\n");
return -1;
}
ment.mnt_fsname = share_name ? share_name : (char *)"none";
ment.mnt_dir = mount_point;
ment.mnt_type = (char *)"smbfs";
ment.mnt_opts = (char *)"";
ment.mnt_freq = 0;
ment.mnt_passno= 0;
mount_point = ment.mnt_dir;
if (mount_point == NULL)
{
fprintf(stderr, "Mount point too long\n");
return -1;
}
if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
{
fprintf(stderr, "Can't get "MOUNTED"~ lock file");
return 1;
}
close(fd);
if ((mtab = setmntent(MOUNTED, "a+")) == NULL)
{
fprintf(stderr, "Can't open " MOUNTED);
return 1;
}
if (addmntent(mtab, &ment) == 1)
{
fprintf(stderr, "Can't write mount entry");
return 1;
}
if (fchmod(fileno(mtab), 0644) == -1)
{
fprintf(stderr, "Can't set perms on "MOUNTED);
return 1;
}
endmntent(mtab);
if (unlink(MOUNTED"~") == -1)
{
fprintf(stderr, "Can't remove "MOUNTED"~");
return 1;
}
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,196 +0,0 @@
/*
* smbumount.c
*
* Copyright (C) 1995-1998 by Volker Lendecke
*
*/
#define SMBMOUNT_MALLOC 1
#include "includes.h"
#include <mntent.h>
#include <asm/types.h>
#include <asm/posix_types.h>
#include <linux/smb.h>
#include <linux/smb_mount.h>
#include <linux/smb_fs.h>
/* This is a (hopefully) temporary hack due to the fact that
sizeof( uid_t ) != sizeof( __kernel_uid_t ) under glibc.
This may change in the future and smb.h may get fixed in the
future. In the mean time, it's ugly hack time - get over it.
*/
#undef SMB_IOC_GETMOUNTUID
#define SMB_IOC_GETMOUNTUID _IOR('u', 1, __kernel_uid_t)
#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0400000
#endif
static void
usage(void)
{
printf("usage: smbumount mountpoint\n\n");
printf("Please be aware that smbfs is deprecated in favor of "
"cifs\n");
}
static int
umount_ok(const char *mount_point)
{
/* we set O_NOFOLLOW to prevent users playing games with symlinks to
umount filesystems they don't own */
int fid = open(mount_point, O_RDONLY|O_NOFOLLOW, 0);
__kernel_uid32_t mount_uid;
if (fid == -1) {
fprintf(stderr, "Could not open %s: %s\n",
mount_point, strerror(errno));
return -1;
}
if (ioctl(fid, SMB_IOC_GETMOUNTUID32, &mount_uid) != 0) {
__kernel_uid_t mount_uid16;
if (ioctl(fid, SMB_IOC_GETMOUNTUID, &mount_uid16) != 0) {
fprintf(stderr, "%s probably not smb-filesystem\n",
mount_point);
return -1;
}
mount_uid = mount_uid16;
}
if ((getuid() != 0)
&& (mount_uid != getuid())) {
fprintf(stderr, "You are not allowed to umount %s\n",
mount_point);
return -1;
}
close(fid);
return 0;
}
/* Make a canonical pathname from PATH. Returns a freshly malloced string.
It is up the *caller* to ensure that the PATH is sensible. i.e.
canonicalize ("/dev/fd0/.") returns "/dev/fd0" even though ``/dev/fd0/.''
is not a legal pathname for ``/dev/fd0'' Anything we cannot parse
we return unmodified. */
static char *
canonicalize (char *path)
{
char *canonical = (char*)malloc (PATH_MAX + 1);
if (!canonical) {
fprintf(stderr, "Error! Not enough memory!\n");
return NULL;
}
if (strlen(path) > PATH_MAX) {
fprintf(stderr, "Mount point string too long\n");
return NULL;
}
if (path == NULL)
return NULL;
if (realpath (path, canonical))
return canonical;
strncpy (canonical, path, PATH_MAX);
canonical[PATH_MAX] = '\0';
return canonical;
}
int
main(int argc, char *argv[])
{
int fd;
char* mount_point;
struct mntent *mnt;
FILE* mtab;
FILE* new_mtab;
TALLOC_CTX *frame = talloc_stackframe();
if (argc != 2) {
usage();
exit(1);
}
if (geteuid() != 0) {
fprintf(stderr, "smbumount must be installed suid root\n");
exit(1);
}
mount_point = canonicalize(argv[1]);
if (mount_point == NULL)
{
exit(1);
}
if (umount_ok(mount_point) != 0) {
exit(1);
}
if (umount(mount_point) != 0) {
fprintf(stderr, "Could not umount %s: %s\n",
mount_point, strerror(errno));
exit(1);
}
if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1)
{
fprintf(stderr, "Can't get "MOUNTED"~ lock file");
return 1;
}
close(fd);
if ((mtab = setmntent(MOUNTED, "r")) == NULL) {
fprintf(stderr, "Can't open " MOUNTED ": %s\n",
strerror(errno));
return 1;
}
#define MOUNTED_TMP MOUNTED".tmp"
if ((new_mtab = setmntent(MOUNTED_TMP, "w")) == NULL) {
fprintf(stderr, "Can't open " MOUNTED_TMP ": %s\n",
strerror(errno));
endmntent(mtab);
return 1;
}
while ((mnt = getmntent(mtab)) != NULL) {
if (strcmp(mnt->mnt_dir, mount_point) != 0) {
addmntent(new_mtab, mnt);
}
}
endmntent(mtab);
if (fchmod (fileno (new_mtab), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
fprintf(stderr, "Error changing mode of %s: %s\n",
MOUNTED_TMP, strerror(errno));
exit(1);
}
endmntent(new_mtab);
if (rename(MOUNTED_TMP, MOUNTED) < 0) {
fprintf(stderr, "Cannot rename %s to %s: %s\n",
MOUNTED, MOUNTED_TMP, strerror(errno));
exit(1);
}
if (unlink(MOUNTED"~") == -1)
{
fprintf(stderr, "Can't remove "MOUNTED"~");
return 1;
}
TALLOC_FREE(frame);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -64,6 +64,11 @@ static char *dyn_##name; \
}\
dyn_##name = SMB_STRDUP(newpath);\
return dyn_##name;\
}\
\
bool is_default_dyn_##name(void) \
{\
return (dyn_##name == NULL);\
}
DEFINE_DYN_CONFIG_PARAM(SBINDIR)

View File

@ -0,0 +1,6 @@
{
global:
talloc_*;
_talloc_*;
local: *;
};

View File

@ -235,7 +235,7 @@ enum {
** that contains the icon data, icon size, icon type, the file type, and file creator.
**
**
** The server returns only that the call was succesfull or not.
** The server returns only that the call was successful or not.
*/
#define SMB_MAC_DT_ADD_ICON 0x309

View File

@ -319,11 +319,6 @@ typedef void **ADS_MODLIST;
#define ADS_DNS_DOMAIN 0x40000000 /* DomainName is a DNS name */
#define ADS_DNS_FOREST 0x80000000 /* DnsForestName is a DNS name */
/* DomainControllerAddressType */
#define ADS_INET_ADDRESS 0x00000001
#define ADS_NETBIOS_ADDRESS 0x00000002
/* ads auth control flags */
#define ADS_AUTH_DISABLE_KERBEROS 0x01
#define ADS_AUTH_NO_BIND 0x02
@ -396,4 +391,11 @@ typedef struct {
#define ADS_IGNORE_PRINCIPAL "not_defined_in_RFC4178@please_ignore"
/* Settings for the domainFunctionality attribute in the rootDSE */
#define DS_DOMAIN_FUNCTION_2000 0
#define DS_DOMAIN_FUCNTION_2003_MIXED 1
#define DS_DOMAIN_FUNCTION_2003 2
#define DS_DOMAIN_FUNCTION_2008 3
#endif /* _INCLUDE_ADS_H_ */

View File

@ -0,0 +1,89 @@
/*
Unix SMB/CIFS implementation.
Infrastructure for async requests
Copyright (C) Volker Lendecke 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ASYNC_REQ_H__
#define __ASYNC_REQ_H__
#include "includes.h"
/*
* An async request moves between the following 4 states.
*/
enum async_req_state {
ASYNC_REQ_INIT, /* we are creating the request */
ASYNC_REQ_IN_PROGRESS, /* we are waiting the request to complete */
ASYNC_REQ_DONE, /* the request is finished */
ASYNC_REQ_ERROR }; /* an error has occured */
struct async_req {
/* the external state - will be queried by the caller */
enum async_req_state state;
/* a private pointer for use by the async function implementation */
void *private_data;
/* print yourself, for debugging purposes */
char *(*print)(TALLOC_CTX *mem_ctx, struct async_req *);
/* status code when finished */
NTSTATUS status;
/* the event context we are using */
struct event_context *event_ctx;
/* information on what to do on completion */
struct {
void (*fn)(struct async_req *);
void *priv;
} async;
};
/*
* Print an async_req structure for debugging purposes
*/
char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req);
/*
* Create an async request
*/
struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev);
/*
* An async request has successfully finished, invoke the callback
*/
void async_req_done(struct async_req *req);
/*
* An async request has seen an error, invoke the callback
*/
void async_req_error(struct async_req *req, NTSTATUS status);
/*
* Convenience helper to easily check alloc failure within a callback.
*
* Call pattern would be
* p = talloc(mem_ctx, bla);
* if (async_req_nomem(p, req)) {
* return;
* }
*
*/
bool async_req_nomem(const void *p, struct async_req *req);
#endif

View File

@ -0,0 +1,62 @@
/*
Unix SMB/CIFS implementation.
Infrastructure for async SMB client requests
Copyright (C) Volker Lendecke 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
/*
* Create a fresh async smb request
*/
struct async_req *cli_request_new(TALLOC_CTX *mem_ctx,
struct event_context *ev,
struct cli_state *cli,
uint8_t num_words, size_t num_bytes,
struct cli_request **preq);
/*
* Convenience function to get the SMB part out of an async_req
*/
struct cli_request *cli_request_get(struct async_req *req);
/*
* Fetch an error out of a NBT packet
*/
NTSTATUS cli_pull_error(char *buf);
/*
* Compatibility helper for the sync APIs: Fake NTSTATUS in cli->inbuf
*/
void cli_set_error(struct cli_state *cli, NTSTATUS status);
/*
* Create a temporary event context for use in the sync helper functions
*/
struct cli_tmp_event *cli_tmp_event_ctx(TALLOC_CTX *mem_ctx,
struct cli_state *cli);
/*
* Attach an event context permanently to a cli_struct
*/
NTSTATUS cli_add_event_ctx(struct cli_state *cli,
struct event_context *event_ctx);

View File

@ -19,7 +19,7 @@
*/
#ifndef _AUTHDATA_H
#define _AUTHDATA_H
#define _AUTHDATA_H
#include "rpc_misc.h"
#include "rpc_netlogon.h"
@ -37,136 +37,4 @@
#define KRB5_AUTHDATA_IF_RELEVANT 1
#endif
typedef struct pac_logon_name {
NTTIME logon_time;
uint16 len;
uint8 *username; /* Actually always little-endian. might not be null terminated, so not UNISTR */
} PAC_LOGON_NAME;
typedef struct pac_signature_data {
uint32 type;
RPC_DATA_BLOB signature; /* this not the on-wire-format (!) */
} PAC_SIGNATURE_DATA;
typedef struct group_membership {
uint32 rid;
uint32 attrs;
} GROUP_MEMBERSHIP;
typedef struct group_membership_array {
uint32 count;
GROUP_MEMBERSHIP *group_membership;
} GROUP_MEMBERSHIP_ARRAY;
#if 0 /* Unused, replaced by NET_USER_INFO_3 - Guenther */
typedef struct krb_sid_and_attrs {
uint32 sid_ptr;
uint32 attrs;
DOM_SID2 *sid;
} KRB_SID_AND_ATTRS;
typedef struct krb_sid_and_attr_array {
uint32 count;
KRB_SID_AND_ATTRS *krb_sid_and_attrs;
} KRB_SID_AND_ATTR_ARRAY;
/* This is awfully similar to a samr_user_info_23, but not identical.
Many of the field names have been swiped from there, because it is
so similar that they are likely the same, but many have been verified.
Some are in a different order, though... */
typedef struct pac_logon_info {
NTTIME logon_time; /* logon time */
NTTIME logoff_time; /* logoff time */
NTTIME kickoff_time; /* kickoff time */
NTTIME pass_last_set_time; /* password last set time */
NTTIME pass_can_change_time; /* password can change time */
NTTIME pass_must_change_time; /* password must change time */
UNIHDR hdr_user_name; /* user name unicode string header */
UNIHDR hdr_full_name; /* user's full name unicode string header */
UNIHDR hdr_logon_script; /* these last 4 appear to be in a different */
UNIHDR hdr_profile_path; /* order than in the info23 */
UNIHDR hdr_home_dir;
UNIHDR hdr_dir_drive;
uint16 logon_count; /* number of times user has logged onto domain */
uint16 bad_password_count; /* samba4 idl */
uint32 user_rid;
uint32 group_rid;
uint32 group_count;
uint32 group_membership_ptr;
uint32 user_flags;
uint8 session_key[16]; /* samba4 idl */
UNIHDR hdr_dom_controller;
UNIHDR hdr_dom_name;
uint32 ptr_dom_sid;
uint8 lm_session_key[8]; /* samba4 idl */
uint32 acct_flags; /* samba4 idl */
uint32 unknown[7];
uint32 sid_count;
uint32 ptr_extra_sids;
uint32 ptr_res_group_dom_sid;
uint32 res_group_count;
uint32 ptr_res_groups;
UNISTR2 uni_user_name; /* user name unicode string header */
UNISTR2 uni_full_name; /* user's full name unicode string header */
UNISTR2 uni_logon_script; /* these last 4 appear to be in a different*/
UNISTR2 uni_profile_path; /* order than in the info23 */
UNISTR2 uni_home_dir;
UNISTR2 uni_dir_drive;
UNISTR2 uni_dom_controller;
UNISTR2 uni_dom_name;
DOM_SID2 dom_sid;
GROUP_MEMBERSHIP_ARRAY groups;
KRB_SID_AND_ATTR_ARRAY extra_sids;
DOM_SID2 res_group_dom_sid;
GROUP_MEMBERSHIP_ARRAY res_groups;
} PAC_LOGON_INFO;
#endif
typedef struct pac_logon_info {
NET_USER_INFO_3 info3;
DOM_SID2 res_group_dom_sid;
GROUP_MEMBERSHIP_ARRAY res_groups;
} PAC_LOGON_INFO;
typedef struct pac_info_ctr
{
union
{
PAC_LOGON_INFO *logon_info;
PAC_SIGNATURE_DATA *srv_cksum;
PAC_SIGNATURE_DATA *privsrv_cksum;
PAC_LOGON_NAME *logon_name;
} pac;
} PAC_INFO_CTR;
typedef struct pac_buffer {
uint32 type;
uint32 size;
uint32 offset;
uint32 offsethi;
PAC_INFO_CTR *ctr;
uint32 pad;
} PAC_BUFFER;
typedef struct pac_data {
uint32 num_buffers;
uint32 version;
PAC_BUFFER *pac_buffer;
} PAC_DATA;
#endif

View File

@ -167,4 +167,10 @@ it also defines lots of intermediate macros, just ignore those :-)
#define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3))
#define ALIGN2(p,base) ((p) + ((2 - (PTR_DIFF((p), (base)) & 1)) & 1))
/* 64 bit macros */
#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32))
#define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))
#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,((uint64_t)(v))>>32))
#define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v))
#endif /* _BYTEORDER_H */

View File

@ -82,7 +82,12 @@ struct rpc_pipe_client {
};
/* Transport encryption state. */
enum smb_trans_enc_type { SMB_TRANS_ENC_NTLM, SMB_TRANS_ENC_GSS };
enum smb_trans_enc_type {
SMB_TRANS_ENC_NTLM
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
, SMB_TRANS_ENC_GSS
#endif
};
#if defined(HAVE_GSSAPI) && defined(HAVE_KRB5)
struct smb_tran_enc_state_gss {
@ -187,6 +192,36 @@ struct cli_state {
bool force_dos_errors;
bool case_sensitive; /* False by default. */
struct event_context *event_ctx;
struct fd_event *fd_event;
char *evt_inbuf;
struct cli_request *outstanding_requests;
};
struct cli_request {
struct cli_request *prev, *next;
struct async_req *async;
struct cli_state *cli;
struct smb_trans_enc_state *enc_state;
uint16_t mid;
char *outbuf;
size_t sent;
char *inbuf;
union {
struct {
off_t ofs;
size_t size;
ssize_t received;
uint8_t *rcvbuf;
} read;
} data;
};
typedef struct file_info {

View File

@ -17,6 +17,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _CTDBD_CONN_H
#define _CTDBD_CONN_H
struct ctdbd_connection;
NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
@ -62,3 +65,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn);
NTSTATUS ctdbd_persistent_store(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key, TDB_DATA data);
#endif /* _CTDBD_CONN_H */

View File

@ -43,6 +43,7 @@ struct db_context {
void *private_data);
int (*get_seqnum)(struct db_context *db);
void *private_data;
bool persistent;
};
struct db_context *db_open(TALLOC_CTX *mem_ctx,

View File

@ -176,11 +176,14 @@ extern bool *DEBUGLEVEL_CLASS_ISSET;
#define unlikely(x) (x)
#endif
#define DEBUGLVL( level ) \
#define CHECK_DEBUGLVL( level ) \
( ((level) <= MAX_DEBUG_LEVEL) && \
unlikely((DEBUGLEVEL_CLASS[ DBGC_CLASS ] >= (level))|| \
(!DEBUGLEVEL_CLASS_ISSET[ DBGC_CLASS ] && \
DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) \
DEBUGLEVEL_CLASS[ DBGC_ALL ] >= (level)) ) )
#define DEBUGLVL( level ) \
( CHECK_DEBUGLVL(level) \
&& dbghdr( level, DBGC_CLASS, __FILE__, FUNCTION_MACRO, (__LINE__) ) )

View File

@ -202,6 +202,7 @@
#define WERR_SERVICE_ALREADY_RUNNING W_ERROR(1056)
#define WERR_SERVICE_DISABLED W_ERROR(1058)
#define WERR_SERVICE_NEVER_STARTED W_ERROR(1077)
#define WERR_INVALID_COMPUTER_NAME W_ERROR(1210)
#define WERR_MACHINE_LOCKED W_ERROR(1271)
#define WERR_NO_LOGON_SERVERS W_ERROR(1311)
#define WERR_NO_SUCH_LOGON_SESSION W_ERROR(1312)
@ -213,12 +214,17 @@
#define WERR_SERVER_UNAVAILABLE W_ERROR(1722)
#define WERR_INVALID_FORM_NAME W_ERROR(1902)
#define WERR_INVALID_FORM_SIZE W_ERROR(1903)
#define WERR_PASSWORD_MUST_CHANGE W_ERROR(1907)
#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(1908)
#define WERR_ACCOUNT_LOCKED_OUT W_ERROR(1909)
/* should these go down to NERR_BASE ? */
#define WERR_BUF_TOO_SMALL W_ERROR(2123)
#define WERR_JOB_NOT_FOUND W_ERROR(2151)
#define WERR_DEST_NOT_FOUND W_ERROR(2152)
#define WERR_USER_EXISTS W_ERROR(2224)
#define WERR_NOT_LOCAL_DOMAIN W_ERROR(2320)
#define WERR_DOMAIN_CONTROLLER_NOT_FOUND W_ERROR(2453)
#define WERR_DC_NOT_FOUND W_ERROR(2453)
#define WERR_SETUP_ALREADY_JOINED W_ERROR(2691)
#define WERR_SETUP_NOT_JOINED W_ERROR(2692)

View File

@ -41,42 +41,60 @@ extern char dyn_PRIVATE_DIR[1024];
const char *get_dyn_SBINDIR(void);
const char *set_dyn_SBINDIR(const char *newpath);
bool is_default_dyn_SBINDIR(void);
const char *get_dyn_BINDIR(void);
const char *set_dyn_BINDIR(const char *newpath);
bool is_default_dyn_BINDIR(void);
const char *get_dyn_SWATDIR(void);
const char *set_dyn_SWATDIR(const char *newpath);
bool is_default_dyn_SWATDIR(void);
const char *get_dyn_CONFIGFILE(void);
const char *set_dyn_CONFIGFILE(const char *newpath);
bool is_default_dyn_CONFIGFILE(void);
const char *get_dyn_dyn_LOGFILEBASE(void);
const char *set_dyn_dyn_LOGFILEBASE(const char *newpath);
const char *get_dyn_LOGFILEBASE(void);
const char *set_dyn_LOGFILEBASE(const char *newpath);
bool is_default_dyn_LOGFILEBASE(void);
const char *get_dyn_LMHOSTSFILE(void);
const char *set_dyn_LMHOSTSFILE(const char *newpath);
bool is_default_dyn_LMHOSTSFILE(void);
const char *get_dyn_CODEPAGEDIR(void);
const char *set_dyn_CODEPAGEDIR(const char *newpath);
bool is_default_dyn_CODEPAGEDIR(void);
const char *get_dyn_LIBDIR(void);
const char *set_dyn_LIBDIR(const char *newpath);
bool is_default_dyn_LIBDIR(void);
const char *get_dyn_SHLIBEXT(void);
const char *set_dyn_SHLIBEXT(const char *newpath);
bool is_default_dyn_SHLIBEXT(void);
const char *get_dyn_LOCKDIR(void);
const char *set_dyn_LOCKDIR(const char *newpath);
bool is_default_dyn_LOCKDIR(void);
const char *get_dyn_PIDDIR(void);
const char *set_dyn_PIDDIR(const char *newpath);
bool is_default_dyn_PIDDIR(void);
const char *get_dyn_SMB_PASSWD_FILE(void);
const char *set_dyn_SMB_PASSWD_FILE(const char *newpath);
bool is_default_dyn_SMB_PASSWD_FILE(void);
const char *get_dyn_PRIVATE_DIR(void);
const char *set_dyn_PRIVATE_DIR(const char *newpath);
bool is_default_dyn_PRIVATE_DIR(void);
const char *get_dyn_STATEDIR(void);
const char *set_dyn_STATEDIR(const char *newpath);
bool is_default_dyn_STATEDIR(void);
const char *get_dyn_CACHEDIR(void);
const char *set_dyn_CACHEDIR(const char *newpath);
bool is_default_dyn_CACHEDIR(bool);

View File

@ -250,6 +250,10 @@ typedef int ber_int_t;
#include <langinfo.h>
#endif
#if HAVE_NETGROUP_H
#include <netgroup.h>
#endif
#if defined(HAVE_AIO_H) && defined(WITH_AIO)
#include <aio.h>
#endif
@ -694,14 +698,13 @@ typedef char fstring[FSTRING_LEN];
#include "rpc_netlogon.h"
#include "reg_objects.h"
#include "reg_db.h"
#include "rpc_samr.h"
#include "rpc_srvsvc.h"
#include "rpc_spoolss.h"
#include "rpc_eventlog.h"
#include "rpc_ds.h"
#include "rpc_perfcount.h"
#include "rpc_perfcount_defs.h"
#include "librpc/gen_ndr/notify.h"
#include "librpc/gen_ndr/xattr.h"
#include "nt_printing.h"
#include "idmap.h"
#include "client.h"
@ -720,6 +723,8 @@ typedef char fstring[FSTRING_LEN];
#include "ctdbd_conn.h"
#include "talloc_stack.h"
#include "memcache.h"
#include "async_req.h"
#include "async_smb.h"
/* used in net.c */
struct functable {
@ -1107,6 +1112,14 @@ char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) PRINTF_ATT
#define VXFS_QUOTA
#endif
#ifndef XATTR_CREATE
#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */
#endif
#ifndef XATTR_REPLACE
#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */
#endif
#if defined(HAVE_KRB5)
krb5_error_code smb_krb5_parse_name(krb5_context context,
@ -1158,15 +1171,15 @@ bool kerberos_compatible_enctypes(krb5_context context, krb5_enctype enctype1, k
void kerberos_free_data_contents(krb5_context context, krb5_data *pdata);
NTSTATUS decode_pac_data(TALLOC_CTX *mem_ctx,
DATA_BLOB *pac_data_blob,
krb5_context context,
krb5_context context,
krb5_keyblock *service_keyblock,
krb5_const_principal client_principal,
time_t tgs_authtime,
PAC_DATA **pac_data);
struct PAC_DATA **pac_data_out);
void smb_krb5_checksum_from_pac_sig(krb5_checksum *cksum,
PAC_SIGNATURE_DATA *sig);
struct PAC_SIGNATURE_DATA *sig);
krb5_error_code smb_krb5_verify_checksum(krb5_context context,
krb5_keyblock *keyblock,
const krb5_keyblock *keyblock,
krb5_keyusage usage,
krb5_checksum *cksum,
uint8 *data,
@ -1194,7 +1207,6 @@ bool smb_krb5_principal_compare_any_realm(krb5_context context,
krb5_const_principal princ2);
int cli_krb5_get_ticket(const char *principal, time_t time_offset,
DATA_BLOB *ticket, DATA_BLOB *session_key_krb5, uint32 extra_ap_opts, const char *ccname, time_t *tgs_expire);
PAC_LOGON_INFO *get_logon_info_from_pac(PAC_DATA *pac_data);
krb5_error_code smb_krb5_renew_ticket(const char *ccache_string, const char *client_string, const char *service_string, time_t *expire_time);
krb5_error_code kpasswd_err_to_krb5_err(krb5_error_code res_code);
krb5_error_code smb_krb5_gen_netbios_krb5_address(smb_krb5_addresses **kerb_addr);

View File

@ -15,6 +15,7 @@ struct _SMBCSRV {
bool no_pathinfo;
bool no_pathinfo2;
bool no_nt_session;
POLICY_HND pol;
SMBCSRV *next, *prev;

View File

@ -427,6 +427,8 @@ struct _SMBCCTX {
off_t (*lseek) (SMBCCTX *c, SMBCFILE * file, off_t offset, int whence);
int (*stat) (SMBCCTX *c, const char *fname, struct stat *st);
int (*fstat) (SMBCCTX *c, SMBCFILE *file, struct stat *st);
/* ftruncate added near _internal for ABI compatibility */
int (*close_fn) (SMBCCTX *c, SMBCFILE *file);
/** callable functions for dirs
@ -520,6 +522,12 @@ struct _SMBCCTX {
int flags;
/** user options selections that apply to this session
*
* NEW OPTIONS ARE NOT ADDED HERE!
*
* We must maintain ABI backward compatibility. We now use
* smbc_option_set() and smbc_option_get() for all newly added
* options.
*/
struct _smbc_options {
@ -580,6 +588,9 @@ struct _SMBCCTX {
int one_share_per_server;
} options;
/* Add additional functions here for ABI backward compatibility */
int (*ftruncate)(SMBCCTX *c, SMBCFILE *f, off_t size);
/** INTERNAL DATA
* do _NOT_ touch this from your program !
*/
@ -1193,6 +1204,26 @@ int smbc_stat(const char *url, struct stat *st);
int smbc_fstat(int fd, struct stat *st);
/**@ingroup attribute
* Truncate a file given a file descriptor
*
* @param fd Open file handle from smbc_open() or smbc_creat()
*
* @param size size to truncate the file to
*
* @return EBADF filedes is bad.
* - EACCES Permission denied.
* - EBADF fd is not a valid file descriptor
* - EINVAL Problems occurred in the underlying routines
* or smbc_init not called.
* - ENOMEM Out of memory
*
* @see , Unix ftruncate()
*
*/
int smbc_ftruncate(int fd, off_t size);
/**@ingroup attribue
* Change the ownership of a file or directory.
*

View File

@ -97,6 +97,7 @@
#define MSG_WINBIND_TRY_TO_GO_ONLINE 0x0406
#define MSG_WINBIND_FAILED_TO_GO_ONLINE 0x0407
#define MSG_WINBIND_VALIDATE_CACHE 0x0408
#define MSG_WINBIND_DUMP_DOMAIN_LIST 0x0409
/* event messages */
#define MSG_DUMP_EVENT_LIST 0x0500

View File

@ -135,9 +135,9 @@ struct handle_list {
/* Domain controller authentication protocol info */
struct dcinfo {
uint32 sequence; /* "timestamp" from client. */
DOM_CHAL seed_chal;
DOM_CHAL clnt_chal; /* Client credential */
DOM_CHAL srv_chal; /* Server credential */
struct netr_Credential seed_chal;
struct netr_Credential clnt_chal; /* Client credential */
struct netr_Credential srv_chal; /* Server credential */
unsigned char sess_key[16]; /* Session key - 8 bytes followed by 8 zero bytes */
unsigned char mach_pw[16]; /* md4(machine password) */

View File

@ -25,40 +25,13 @@
/*
* fields_present flags meanings
* same names as found in samba4 idl files
* in samba4 idl
* ACCT_NT_PWD_SET == SAMR_FIELD_PASSWORD and
* ACCT_LM_PWD_SET == SAMR_FIELD_PASSWORD2
*/
#define ACCT_USERNAME 0x00000001
#define ACCT_FULL_NAME 0x00000002
#define ACCT_RID 0x00000004
#define ACCT_PRIMARY_GID 0x00000008
#define ACCT_DESCRIPTION 0x00000010
#define ACCT_COMMENT 0x00000020
#define ACCT_HOME_DIR 0x00000040
#define ACCT_HOME_DRIVE 0x00000080
#define ACCT_LOGON_SCRIPT 0x00000100
#define ACCT_PROFILE 0x00000200
#define ACCT_WORKSTATIONS 0x00000400
#define ACCT_LAST_LOGON 0x00000800
#define ACCT_LAST_LOGOFF 0x00001000
#define ACCT_LOGON_HOURS 0x00002000
#define ACCT_BAD_PWD_COUNT 0x00004000
#define ACCT_NUM_LOGONS 0x00008000
#define ACCT_ALLOW_PWD_CHANGE 0x00010000
#define ACCT_FORCE_PWD_CHANGE 0x00020000
#define ACCT_LAST_PWD_CHANGE 0x00040000
#define ACCT_EXPIRY 0x00080000
#define ACCT_FLAGS 0x00100000
#define ACCT_CALLBACK 0x00200000
#define ACCT_COUNTRY_CODE 0x00400000
#define ACCT_CODE_PAGE 0x00800000
#define ACCT_NT_PWD_SET 0x01000000
#define ACCT_LM_PWD_SET 0x02000000
#define ACCT_PRIVATEDATA 0x04000000
#define ACCT_EXPIRED_FLAG 0x08000000
#define ACCT_SEC_DESC 0x10000000
#define ACCT_OWF_PWD 0x20000000
/*
* bit flags representing initialized fields in struct samu

View File

@ -94,11 +94,17 @@ typedef struct {
#define KEY_HKCU "HKCU"
#define KEY_HKDD "HKDD"
#define KEY_SERVICES "HKLM\\SYSTEM\\CurrentControlSet\\Services"
#define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
#define KEY_SHARES "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
#define KEY_NETLOGON_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters"
#define KEY_TCPIP_PARAMS "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
#define KEY_PROD_OPTIONS "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions"
#define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
#define KEY_PRINTING_2K "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"
#define KEY_PRINTING_PORTS "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
#define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
#define KEY_SHARES "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
#define KEY_CURRENT_VERSION "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
#define KEY_PERFLIB "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"
#define KEY_PERFLIB_009 "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009"
#define KEY_SMBCONF "HKLM\\SOFTWARE\\Samba\\smbconf"
#define KEY_TREE_ROOT ""

View File

@ -1,79 +0,0 @@
/*
Unix SMB/CIFS implementation.
SMB parameters and setup
Copyright (C) Andrew Tridgell 1992-1999
Copyright (C) Luke Kenneth Casson Leighton 1996-1999
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _RPC_BRS_H /* _RPC_BRS_H */
#define _RPC_BRS_H
/* brssvc pipe */
#define BRS_QUERY_INFO 0x02
/* BRS_Q_QUERY_INFO - probably a capabilities request */
typedef struct q_brs_query_info_info
{
uint32 ptr_srv_name; /* pointer (to server name?) */
UNISTR2 uni_srv_name; /* unicode server name starting with '\\' */
uint16 switch_value1; /* info level 100 (0x64) */
/* align */
uint16 switch_value2; /* info level 100 (0x64) */
uint32 ptr;
uint32 pad1;
uint32 pad2;
} BRS_Q_QUERY_INFO;
/* BRS_INFO_100 - level 100 info */
typedef struct brs_info_100_info
{
uint32 pad1;
uint32 ptr2;
uint32 pad2;
uint32 pad3;
} BRS_INFO_100;
/* BRS_R_QUERY_INFO - probably a capabilities request */
typedef struct r_brs_query_info_info
{
uint16 switch_value1; /* 100 (0x64) - switch value */
/* align */
uint16 switch_value2; /* info level 100 (0x64) */
/* for now, only level 100 is supported. this should be an enum container */
uint32 ptr_1; /* pointer 1 */
union
{
BRS_INFO_100 *brs100; /* browser info level 100 */
void *id;
} info;
NTSTATUS status; /* return status */
} BRS_R_QUERY_INFO;
#endif /* _RPC_BRS_H */

View File

@ -31,6 +31,10 @@
#include "librpc/gen_ndr/cli_initshutdown.h"
#include "librpc/gen_ndr/cli_winreg.h"
#include "librpc/gen_ndr/cli_srvsvc.h"
#include "librpc/gen_ndr/cli_samr.h"
#include "librpc/gen_ndr/cli_netlogon.h"
#include "librpc/gen_ndr/cli_dssetup.h"
#include "librpc/gen_ndr/cli_ntsvcs.h"
/* macro to expand cookie-cutter code in cli_xxx() using rpc_api_pipe_req() */

View File

@ -98,11 +98,6 @@ enum RPC_PKT_TYPE {
#define RPC_AUTH_SCHANNEL_SIGN_OR_SEAL_CHK_LEN 0x20
#define RPC_AUTH_SCHANNEL_SIGN_ONLY_CHK_LEN 0x18
#define NETLOGON_NEG_ARCFOUR 0x00000004
#define NETLOGON_NEG_128BIT 0x00004000
#define NETLOGON_NEG_SCHANNEL 0x40000000
/* The 7 here seems to be required to get Win2k not to downgrade us
to NT4. Actually, anything other than 1ff would seem to do... */
#define NETLOGON_NEG_AUTH2_FLAGS 0x000701ff
@ -111,6 +106,8 @@ enum RPC_PKT_TYPE {
/* these are the flags that ADS clients use */
#define NETLOGON_NEG_AUTH2_ADS_FLAGS (0x200fbffb | NETLOGON_NEG_ARCFOUR | NETLOGON_NEG_128BIT | NETLOGON_NEG_SCHANNEL)
#define NETLOGON_NEG_SELECT_AUTH2_FLAGS ((lp_security() == SEC_ADS) ? NETLOGON_NEG_AUTH2_ADS_FLAGS : NETLOGON_NEG_AUTH2_FLAGS)
enum schannel_direction {
SENDER_IS_INITIATOR,
SENDER_IS_ACCEPTOR

View File

@ -1,184 +0,0 @@
/*
Unix SMB/CIFS implementation.
SMB parameters and setup
Copyright (C) Gerald Carter 2002
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _RPC_DS_H /* _RPC_LSA_H */
#define _RPC_DS_H
/* Opcodes available on PIPE_LSARPC_DS */
#define DS_GETPRIMDOMINFO 0x00
#define DS_NOP 0xFF /* no op -- placeholder */
/* Opcodes available on PIPE_NETLOGON */
#define DS_ENUM_DOM_TRUSTS 0x28
/* macros for RPC's */
/* DSROLE_PRIMARY_DOMAIN_INFO_BASIC */
/* flags */
#define DSROLE_PRIMARY_DS_RUNNING 0x00000001
#define DSROLE_PRIMARY_DS_MIXED_MODE 0x00000002
#define DSROLE_UPGRADE_IN_PROGRESS 0x00000004
#define DSROLE_PRIMARY_DOMAIN_GUID_PRESENT 0x01000000
/* machine role */
#define DSROLE_DOMAIN_MEMBER_WKS 1
#define DSROLE_STANDALONE_SRV 2
#define DSROLE_DOMAIN_MEMBER_SRV 3
#define DSROLE_BDC 4
#define DSROLE_PDC 5
/* Settings for the domainFunctionality attribute in the rootDSE */
#define DS_DOMAIN_FUNCTION_2000 0
#define DS_DOMAIN_FUCNTION_2003_MIXED 1
#define DS_DOMAIN_FUNCTION_2003 2
typedef struct
{
uint16 machine_role;
uint32 flags;
uint32 netbios_ptr;
uint32 dnsname_ptr;
uint32 forestname_ptr;
struct GUID domain_guid;
UNISTR2 netbios_domain;
UNISTR2 dns_domain; /* our dns domain */
UNISTR2 forest_domain; /* root domain of the forest to which we belong */
} DSROLE_PRIMARY_DOMAIN_INFO_BASIC;
typedef struct
{
DSROLE_PRIMARY_DOMAIN_INFO_BASIC *basic;
} DS_DOMINFO_CTR;
/* info levels for ds_getprimdominfo() */
#define DsRolePrimaryDomainInfoBasic 1
/* DS_Q_GETPRIMDOMINFO - DsGetPrimaryDomainInformation() request */
typedef struct
{
uint16 level;
} DS_Q_GETPRIMDOMINFO;
/* DS_R_GETPRIMDOMINFO - DsGetPrimaryDomainInformation() response */
typedef struct
{
uint32 ptr;
uint16 level;
uint16 unknown0; /* 0x455c -- maybe just alignment? */
DS_DOMINFO_CTR info;
NTSTATUS status;
} DS_R_GETPRIMDOMINFO;
typedef struct {
/* static portion of structure */
uint32 netbios_ptr;
uint32 dns_ptr;
uint32 flags;
uint32 parent_index;
uint32 trust_type;
uint32 trust_attributes;
uint32 sid_ptr;
struct GUID guid;
UNISTR2 netbios_domain;
UNISTR2 dns_domain;
DOM_SID2 sid;
} DS_DOMAIN_TRUSTS;
struct ds_domain_trust {
/* static portion of structure */
uint32 flags;
uint32 parent_index;
uint32 trust_type;
uint32 trust_attributes;
struct GUID guid;
DOM_SID sid;
char *netbios_domain;
char *dns_domain;
};
typedef struct {
uint32 ptr;
uint32 max_count;
DS_DOMAIN_TRUSTS *trusts;
} DS_DOMAIN_TRUSTS_CTR;
/* Trust flags */
#define DS_DOMAIN_IN_FOREST 0x0001 /* domains in the forest to which
we belong; even different domain trees */
#define DS_DOMAIN_DIRECT_OUTBOUND 0x0002 /* trusted domains */
#define DS_DOMAIN_TREE_ROOT 0x0004 /* root of a forest */
#define DS_DOMAIN_PRIMARY 0x0008 /* our domain */
#define DS_DOMAIN_NATIVE_MODE 0x0010 /* native mode AD servers */
#define DS_DOMAIN_DIRECT_INBOUND 0x0020 /* trusting domains */
/* Trust types */
#define DS_DOMAIN_TRUST_TYPE_DOWNLEVEL 0x00000001
#define DS_DOMAIN_TRUST_TYPE_UPLEVEL 0x00000002
/* Trust attributes */
#define DS_DOMAIN_TRUST_ATTRIB_NON_TRANSITIVE 0x00000001
#define DS_DOMAIN_TRUST_ATTRIB_UPLEVEL_ONLY 0x00000002
#define DS_DOMAIN_TRUST_ATTRIB_QUARANTINED_DOMAIN 0x00000004
#define DS_DOMAIN_TRUST_ATTRIB_FOREST_TRANSITIVE 0x00000008
#define DS_DOMAIN_TRUST_ATTRIB_CROSS_ORG 0x00000010
#define DS_DOMAIN_TRUST_ATTRIB_IN_FOREST 0x00000020
#define DS_DOMAIN_TRUST_ATTRIB_EXTERNAL 0x00000040
/* DS_Q_ENUM_DOM_TRUSTS - DsEnumerateDomainTrusts() request */
typedef struct
{
uint32 server_ptr;
UNISTR2 server;
uint32 flags;
} DS_Q_ENUM_DOM_TRUSTS;
/* DS_R_ENUM_DOM_TRUSTS - DsEnumerateDomainTrusts() response */
typedef struct
{
uint32 num_domains;
DS_DOMAIN_TRUSTS_CTR domains;
NTSTATUS status;
} DS_R_ENUM_DOM_TRUSTS;
#endif /* _RPC_DS_H */

View File

@ -58,51 +58,6 @@ typedef struct elog_tdb {
#define EVENTLOG_DATABASE_VERSION_V1 1
/***********************************/
typedef struct {
uint16 unknown1;
uint16 unknown2;
} EVENTLOG_OPEN_UNKNOWN0;
typedef struct {
EVENTLOG_OPEN_UNKNOWN0 *unknown0;
UNISTR4 logname;
UNISTR4 servername;
uint32 unknown1;
uint32 unknown2;
} EVENTLOG_Q_OPEN_EVENTLOG;
typedef struct {
POLICY_HND handle;
NTSTATUS status;
} EVENTLOG_R_OPEN_EVENTLOG;
/***********************************/
typedef struct {
POLICY_HND handle;
} EVENTLOG_Q_GET_NUM_RECORDS;
typedef struct {
uint32 num_records;
NTSTATUS status;
} EVENTLOG_R_GET_NUM_RECORDS;
/***********************************/
typedef struct {
POLICY_HND handle;
} EVENTLOG_Q_GET_OLDEST_ENTRY;
typedef struct {
uint32 oldest_entry;
NTSTATUS status;
} EVENTLOG_R_GET_OLDEST_ENTRY;
/***********************************/
typedef struct
@ -165,16 +120,4 @@ typedef struct {
NTSTATUS status;
} EVENTLOG_R_READ_EVENTLOG;
/***********************************/
typedef struct {
POLICY_HND handle;
UNISTR4 backupfile;
} EVENTLOG_Q_CLEAR_EVENTLOG;
typedef struct {
NTSTATUS status;
} EVENTLOG_R_CLEAR_EVENTLOG;
#endif /* _RPC_EVENTLOG_H */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -33,32 +33,6 @@
#define NTSVCS_GET_VERSION_INTERNAL 0x3e
/**************************/
typedef struct {
/* nothing in the request */
uint32 dummy;
} NTSVCS_Q_GET_VERSION;
typedef struct {
uint32 version;
WERROR status;
} NTSVCS_R_GET_VERSION;
/**************************/
typedef struct {
UNISTR2 *devicename;
uint32 flags;
} NTSVCS_Q_GET_DEVICE_LIST_SIZE;
typedef struct {
uint32 size;
WERROR status;
} NTSVCS_R_GET_DEVICE_LIST_SIZE;
/**************************/
typedef struct {
@ -75,17 +49,6 @@ typedef struct {
/**************************/
typedef struct {
UNISTR2 devicepath;
uint32 flags;
} NTSVCS_Q_VALIDATE_DEVICE_INSTANCE;
typedef struct {
WERROR status;
} NTSVCS_R_VALIDATE_DEVICE_INSTANCE;
/**************************/
#define DEV_REGPROP_DESC 1
typedef struct {
@ -105,42 +68,4 @@ typedef struct {
WERROR status;
} NTSVCS_R_GET_DEVICE_REG_PROPERTY;
/**************************/
typedef struct {
uint32 index;
uint8 *buffer;
uint32 buffer_size;
uint32 unknown1;
} NTSVCS_Q_GET_HW_PROFILE_INFO;
typedef struct {
uint32 buffer_size; /* the size (not included in the reply)
if just matched from the request */
uint8 *buffer;
WERROR status;
} NTSVCS_R_GET_HW_PROFILE_INFO;
/**************************/
typedef struct {
uint32 unknown1;
UNISTR2 devicepath;
uint32 unknown2;
uint32 unknown3;
uint32 unknown4;
uint32 unknown5;
uint32 unknown6;
uint32 unknown7;
} NTSVCS_Q_HW_PROFILE_FLAGS;
typedef struct {
uint32 unknown1;
uint32 unknown2;
uint32 unknown3;
WERROR status;
} NTSVCS_R_HW_PROFILE_FLAGS;
#endif /* _RPC_NTSVCS_H */

File diff suppressed because it is too large Load Diff

View File

@ -196,81 +196,6 @@ typedef struct _ServiceInfo {
/**************************/
typedef struct {
UNISTR2 *servername;
UNISTR2 *database;
uint32 access;
} SVCCTL_Q_OPEN_SCMANAGER;
typedef struct {
POLICY_HND handle;
WERROR status;
} SVCCTL_R_OPEN_SCMANAGER;
/**************************/
typedef struct {
POLICY_HND handle;
UNISTR2 servicename;
uint32 display_name_len;
} SVCCTL_Q_GET_DISPLAY_NAME;
typedef struct {
UNISTR2 displayname;
uint32 display_name_len;
WERROR status;
} SVCCTL_R_GET_DISPLAY_NAME;
/**************************/
typedef struct {
POLICY_HND handle;
UNISTR2 servicename;
uint32 access;
} SVCCTL_Q_OPEN_SERVICE;
typedef struct {
POLICY_HND handle;
WERROR status;
} SVCCTL_R_OPEN_SERVICE;
/**************************/
typedef struct {
POLICY_HND handle;
uint32 parmcount;
UNISTR4_ARRAY *parameters;
} SVCCTL_Q_START_SERVICE;
typedef struct {
WERROR status;
} SVCCTL_R_START_SERVICE;
/**************************/
typedef struct {
POLICY_HND handle;
uint32 control;
} SVCCTL_Q_CONTROL_SERVICE;
typedef struct {
SERVICE_STATUS svc_status;
WERROR status;
} SVCCTL_R_CONTROL_SERVICE;
/**************************/
typedef struct {
POLICY_HND handle;
} SVCCTL_Q_QUERY_STATUS;
typedef struct {
SERVICE_STATUS svc_status;
WERROR status;
} SVCCTL_R_QUERY_STATUS;
/**************************/
typedef struct {
POLICY_HND handle;
uint32 type;
@ -346,57 +271,5 @@ typedef struct {
WERROR status;
} SVCCTL_R_QUERY_SERVICE_STATUSEX;
/**************************/
typedef struct {
POLICY_HND handle;
} SVCCTL_Q_LOCK_SERVICE_DB;
typedef struct {
POLICY_HND h_lock;
WERROR status;
} SVCCTL_R_LOCK_SERVICE_DB;
/**************************/
typedef struct {
POLICY_HND h_lock;
} SVCCTL_Q_UNLOCK_SERVICE_DB;
typedef struct {
WERROR status;
} SVCCTL_R_UNLOCK_SERVICE_DB;
/**************************/
typedef struct {
POLICY_HND handle;
uint32 security_flags;
uint32 buffer_size;
} SVCCTL_Q_QUERY_SERVICE_SEC;
typedef struct {
RPC_BUFFER buffer;
uint32 needed;
WERROR status;
} SVCCTL_R_QUERY_SERVICE_SEC;
/**************************/
typedef struct {
POLICY_HND handle;
uint32 security_flags;
RPC_BUFFER buffer;
uint32 buffer_size;
} SVCCTL_Q_SET_SERVICE_SEC;
typedef struct {
WERROR status;
} SVCCTL_R_SET_SERVICE_SEC;
#endif /* _RPC_SVCCTL_H */

View File

@ -193,7 +193,7 @@ typedef uint32 codepoint_t;
#define PIPE_NETLOGON_PLAIN "\\NETLOGON"
#define PI_LSARPC 0
#define PI_LSARPC_DS 1
#define PI_DSSETUP 1
#define PI_SAMR 2
#define PI_NETLOGON 3
#define PI_SRVSVC 4
@ -211,30 +211,6 @@ typedef uint32 codepoint_t;
/* 64 bit time (100usec) since ????? - cifs6.txt, section 3.5, page 30 */
typedef uint64_t NTTIME;
/* Allowable account control bits */
#define ACB_DISABLED 0x00000001 /* 1 = User account disabled */
#define ACB_HOMDIRREQ 0x00000002 /* 1 = Home directory required */
#define ACB_PWNOTREQ 0x00000004 /* 1 = User password not required */
#define ACB_TEMPDUP 0x00000008 /* 1 = Temporary duplicate account */
#define ACB_NORMAL 0x00000010 /* 1 = Normal user account */
#define ACB_MNS 0x00000020 /* 1 = MNS logon user account */
#define ACB_DOMTRUST 0x00000040 /* 1 = Interdomain trust account */
#define ACB_WSTRUST 0x00000080 /* 1 = Workstation trust account */
#define ACB_SVRTRUST 0x00000100 /* 1 = Server trust account (BDC) */
#define ACB_PWNOEXP 0x00000200 /* 1 = User password does not expire */
#define ACB_AUTOLOCK 0x00000400 /* 1 = Account auto locked */
/* only valid for > Windows 2000 */
#define ACB_ENC_TXT_PWD_ALLOWED 0x00000800 /* 1 = Text password encryped */
#define ACB_SMARTCARD_REQUIRED 0x00001000 /* 1 = Smart Card required */
#define ACB_TRUSTED_FOR_DELEGATION 0x00002000 /* 1 = Trusted for Delegation */
#define ACB_NOT_DELEGATED 0x00004000 /* 1 = Not delegated */
#define ACB_USE_DES_KEY_ONLY 0x00008000 /* 1 = Use DES key only */
#define ACB_DONT_REQUIRE_PREAUTH 0x00010000 /* 1 = Preauth not required */
#define ACB_PWEXPIRED 0x00020000 /* 1 = Password is expired */
#define ACB_NO_AUTH_DATA_REQD 0x00080000 /* 1 = No authorization data required */
#define MAX_HOURS_LEN 32
#ifndef MAXSUBAUTHS
@ -283,9 +259,6 @@ typedef struct dom_sid {
uint32 sub_auths[MAXSUBAUTHS];
} DOM_SID;
#define dom_sid2 dom_sid
#define dom_sid28 dom_sid
enum id_mapping {
ID_UNKNOWN = 0,
ID_MAPPED,
@ -310,8 +283,17 @@ struct id_map {
enum id_mapping status;
};
#include "librpc/ndr/misc.h"
#include "librpc/ndr/security.h"
/* used to hold an arbitrary blob of data */
typedef struct data_blob {
uint8 *data;
size_t length;
void (*free)(struct data_blob *data_blob);
} DATA_BLOB;
extern const DATA_BLOB data_blob_null;
#include "librpc/gen_ndr/misc.h"
#include "librpc/gen_ndr/security.h"
#include "librpc/ndr/libndr.h"
#include "librpc/gen_ndr/lsa.h"
#include "librpc/gen_ndr/dfs.h"
@ -322,8 +304,12 @@ struct id_map {
#include "librpc/gen_ndr/wkssvc.h"
#include "librpc/gen_ndr/echo.h"
#include "librpc/gen_ndr/svcctl.h"
#include "librpc/gen_ndr/netlogon.h"
#include "librpc/gen_ndr/samr.h"
#include "librpc/gen_ndr/dssetup.h"
#include "librpc/gen_ndr/libnet_join.h"
#include "librpc/gen_ndr/krb5pac.h"
#include "librpc/gen_ndr/ntsvcs.h"
struct lsa_dom_info {
bool valid;
@ -527,20 +513,13 @@ typedef struct files_struct {
FAKE_FILE_HANDLE *fake_file_handle;
struct notify_change_buf *notify;
struct files_struct *base_fsp; /* placeholder for delete on close */
} files_struct;
#include "ntquotas.h"
#include "sysquotas.h"
/* used to hold an arbitrary blob of data */
typedef struct data_blob {
uint8 *data;
size_t length;
void (*free)(struct data_blob *data_blob);
} DATA_BLOB;
extern const DATA_BLOB data_blob_null;
/*
* Structure used to keep directory state information around.
* Used in NT change-notify code.
@ -597,6 +576,16 @@ struct trans_state {
char *data;
};
/*
* Info about an alternate data stream
*/
struct stream_struct {
SMB_OFF_T size;
SMB_OFF_T alloc_size;
char *name;
};
/* Include VFS stuff */
#include "smb_acls.h"
@ -1382,6 +1371,9 @@ struct bitmap {
#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS 0x01000000
#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB 0x02000000
/* Private options for streams support */
#define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x04000000
/* Responses when opening a file. */
#define FILE_WAS_SUPERSEDED 0
#define FILE_WAS_OPENED 1
@ -1912,6 +1904,8 @@ struct ea_list {
#define SAMBA_POSIX_INHERITANCE_EA_NAME "user.SAMBA_PAI"
/* EA to use for DOS attributes */
#define SAMBA_XATTR_DOS_ATTRIB "user.DOSATTRIB"
/* Prefix for DosStreams in the vfs_streams_xattr module */
#define SAMBA_XATTR_DOSSTREAM_PREFIX "user.DosStream."
#define UUID_SIZE 16
@ -1942,4 +1936,15 @@ enum usershare_err {
/* Different reasons for closing a file. */
enum file_close_type {NORMAL_CLOSE=0,SHUTDOWN_CLOSE,ERROR_CLOSE};
/* Used in SMB_FS_OBJECTID_INFORMATION requests. Must be exactly 48 bytes. */
#define SAMBA_EXTENDED_INFO_MAGIC 0x536d4261 /* "SmBa" */
#define SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH 28
struct smb_extended_info {
uint32 samba_magic; /* Always SAMBA_EXTRA_INFO_MAGIC */
uint32 samba_version; /* Major/Minor/Release/Revision */
uint32 samba_subversion; /* Prerelease/RC/Vendor patch */
NTTIME samba_gitcommitdate;
char samba_version_string[SAMBA_EXTENDED_INFO_VERSION_STRING_LENGTH];
};
#endif /* _SMB_H */

View File

@ -305,10 +305,9 @@ NULL returns on zero request. JRA.
#define talloc_destroy(ctx) talloc_free(ctx)
#define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0)
/* only define PARANOID_MALLOC_CHECKER with --enable-developer and not compiling
the smbmount utils */
/* only define PARANOID_MALLOC_CHECKER with --enable-developer */
#if defined(DEVELOPER) && !defined(SMBMOUNT_MALLOC)
#if defined(DEVELOPER)
# define PARANOID_MALLOC_CHECKER 1
#endif

View File

@ -103,8 +103,8 @@
/* Leave at 22 - not yet released. Remove parameter fd from write. - obnox */
/* Leave at 22 - not yet released. Remove parameter fromfd from sendfile. - obnox */
/* Leave at 22 - not yet released. Remove parameter fromfd from recvfile. - obnox */
/* Leave at 22 - not yet released. Additional change: add operations for offline files -- ab */
/* Leave at 22 - not yet released. Add the streaminfo call. -- jpeach, vl */
#define SMB_VFS_INTERFACE_VERSION 22
@ -149,6 +149,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_SET_QUOTA,
SMB_VFS_OP_GET_SHADOW_COPY_DATA,
SMB_VFS_OP_STATVFS,
SMB_VFS_OP_FS_CAPABILITIES,
/* Directory operations */
@ -199,6 +200,7 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_NOTIFY_WATCH,
SMB_VFS_OP_CHFLAGS,
SMB_VFS_OP_FILE_ID_CREATE,
SMB_VFS_OP_STREAMINFO,
/* NT ACL operations. */
@ -257,9 +259,14 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_AIO_ERROR,
SMB_VFS_OP_AIO_FSYNC,
SMB_VFS_OP_AIO_SUSPEND,
SMB_VFS_OP_AIO_FORCE,
/* offline operations */
SMB_VFS_OP_IS_OFFLINE,
SMB_VFS_OP_SET_OFFLINE,
/* This should always be last enum value */
SMB_VFS_OP_LAST
} vfs_op_type;
@ -269,7 +276,7 @@ typedef enum _vfs_op_type {
struct vfs_ops {
struct vfs_fn_pointers {
/* Disk operations */
int (*connect_fn)(struct vfs_handle_struct *handle, const char *service, const char *user);
void (*disconnect)(struct vfs_handle_struct *handle);
SMB_BIG_UINT (*disk_free)(struct vfs_handle_struct *handle, const char *path, bool small_query, SMB_BIG_UINT *bsize,
@ -278,9 +285,10 @@ struct vfs_ops {
int (*set_quota)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
int (*get_shadow_copy_data)(struct vfs_handle_struct *handle, struct files_struct *fsp, SHADOW_COPY_DATA *shadow_copy_data, bool labels);
int (*statvfs)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf);
uint32_t (*fs_capabilities)(struct vfs_handle_struct *handle);
/* Directory operations */
SMB_STRUCT_DIR *(*opendir)(struct vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attributes);
SMB_STRUCT_DIRENT *(*readdir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp);
void (*seekdir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp, long offset);
@ -289,9 +297,9 @@ struct vfs_ops {
int (*mkdir)(struct vfs_handle_struct *handle, const char *path, mode_t mode);
int (*rmdir)(struct vfs_handle_struct *handle, const char *path);
int (*closedir)(struct vfs_handle_struct *handle, SMB_STRUCT_DIR *dir);
/* File operations */
int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode);
int (*close_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, int fd);
ssize_t (*read)(struct vfs_handle_struct *handle, struct files_struct *fsp, void *data, size_t n);
@ -335,8 +343,15 @@ struct vfs_ops {
int (*chflags)(struct vfs_handle_struct *handle, const char *path, unsigned int flags);
struct file_id (*file_id_create)(struct vfs_handle_struct *handle, SMB_DEV_T dev, SMB_INO_T inode);
NTSTATUS (*streaminfo)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
const char *fname,
TALLOC_CTX *mem_ctx,
unsigned int *num_streams,
struct stream_struct **streams);
/* NT ACL operations. */
NTSTATUS (*fget_nt_acl)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32 security_info,
@ -354,12 +369,12 @@ struct vfs_ops {
const char *name,
uint32 security_info_sent,
struct security_descriptor *psd);
/* POSIX ACL operations. */
int (*chmod_acl)(struct vfs_handle_struct *handle, const char *name, mode_t mode);
int (*fchmod_acl)(struct vfs_handle_struct *handle, struct files_struct *fsp, mode_t mode);
int (*sys_acl_get_entry)(struct vfs_handle_struct *handle, SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p);
int (*sys_acl_get_tag_type)(struct vfs_handle_struct *handle, SMB_ACL_ENTRY_T entry_d, SMB_ACL_TAG_T *tag_type_p);
int (*sys_acl_get_permset)(struct vfs_handle_struct *handle, SMB_ACL_ENTRY_T entry_d, SMB_ACL_PERMSET_T *permset_p);
@ -405,7 +420,11 @@ struct vfs_ops {
int (*aio_error_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_STRUCT_AIOCB *aiocb);
int (*aio_fsync)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_STRUCT_AIOCB *aiocb);
int (*aio_suspend)(struct vfs_handle_struct *handle, struct files_struct *fsp, const SMB_STRUCT_AIOCB * const aiocb[], int n, const struct timespec *timeout);
bool (*aio_force)(struct vfs_handle_struct *handle, struct files_struct *fsp);
/* offline operations */
bool (*is_offline)(struct vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf);
int (*set_offline)(struct vfs_handle_struct *handle, const char *path);
} ops;
struct vfs_handles_pointers {
@ -418,6 +437,7 @@ struct vfs_ops {
struct vfs_handle_struct *set_quota;
struct vfs_handle_struct *get_shadow_copy_data;
struct vfs_handle_struct *statvfs;
struct vfs_handle_struct *fs_capabilities;
/* Directory operations */
@ -468,6 +488,7 @@ struct vfs_ops {
struct vfs_handle_struct *notify_watch;
struct vfs_handle_struct *chflags;
struct vfs_handle_struct *file_id_create;
struct vfs_handle_struct *streaminfo;
/* NT ACL operations. */
@ -526,27 +547,32 @@ struct vfs_ops {
struct vfs_handle_struct *aio_error;
struct vfs_handle_struct *aio_fsync;
struct vfs_handle_struct *aio_suspend;
struct vfs_handle_struct *aio_force;
/* offline operations */
struct vfs_handle_struct *is_offline;
struct vfs_handle_struct *set_offline;
} handles;
};
/*
Possible VFS operation layers (per-operation)
These values are used by VFS subsystem when building vfs_ops for connection
from multiple VFS modules. Internally, Samba differentiates only opaque and
transparent layers at this process. Other types are used for providing better
diagnosing facilities.
Most modules will provide transparent layers. Opaque layer is for modules
which implement actual file system calls (like DB-based VFS). For example,
default POSIX VFS which is built in into Samba is an opaque VFS module.
Other layer types (audit, splitter, scanner) were designed to provide different
degree of transparency and for diagnosing VFS module behaviour.
Each module can implement several layers at the same time provided that only
one layer is used per each operation.
*/
typedef enum _vfs_op_layer {
@ -565,7 +591,7 @@ typedef enum _vfs_op_layer {
/*
VFS operation description. Each VFS module registers an array of vfs_op_tuple to VFS subsystem,
which describes all operations this module is willing to intercept.
which describes all operations this module is willing to intercept.
VFS subsystem initializes then the conn->vfs_ops and conn->vfs_opaque_ops structs
using this information.
*/
@ -590,12 +616,12 @@ typedef struct vfs_handle_struct {
typedef struct vfs_statvfs_struct {
/* For undefined recommended transfer size return -1 in that field */
uint32 OptimalTransferSize; /* bsize on some os, iosize on other os */
uint32 BlockSize;
uint32 BlockSize;
/*
The next three fields are in terms of the block size.
(above). If block size is unknown, 4096 would be a
reasonable block size for a server to report.
reasonable block size for a server to report.
Note that returning the blocks/blocksavail removes need
to make a second call (to QFSInfo level 0x103 to get this info.
UserBlockAvail is typically less than or equal to BlocksAvail,

View File

@ -1,18 +1,18 @@
/*
/*
Unix SMB/CIFS implementation.
VFS wrapper macros
Copyright (C) Stefan (metze) Metzmacher 2003
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
@ -26,7 +26,7 @@
(Fixes should go also into the vfs_opaque_* and vfs_next_* macros!)
********************************************************************/
/* Disk operations */
/* Disk operations */
#define SMB_VFS_CONNECT(conn, service, user) ((conn)->vfs.ops.connect_fn((conn)->vfs.handles.connect_hnd, (service), (user)))
#define SMB_VFS_DISCONNECT(conn) ((conn)->vfs.ops.disconnect((conn)->vfs.handles.disconnect))
#define SMB_VFS_DISK_FREE(conn, path, small_query, bsize, dfree ,dsize) ((conn)->vfs.ops.disk_free((conn)->vfs.handles.disk_free, (path), (small_query), (bsize), (dfree), (dsize)))
@ -34,6 +34,7 @@
#define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) ((conn)->vfs.ops.set_quota((conn)->vfs.handles.set_quota, (qtype), (id), (qt)))
#define SMB_VFS_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) ((fsp)->conn->vfs.ops.get_shadow_copy_data((fsp)->conn->vfs.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
#define SMB_VFS_STATVFS(conn, path, statbuf) ((conn)->vfs.ops.statvfs((conn)->vfs.handles.statvfs, (path), (statbuf)))
#define SMB_VFS_FS_CAPABILITIES(conn) ((conn)->vfs.ops.fs_capabilities((conn)->vfs.handles.fs_capabilities))
/* Directory operations */
#define SMB_VFS_OPENDIR(conn, fname, mask, attr) ((conn)->vfs.ops.opendir((conn)->vfs.handles.opendir, (fname), (mask), (attr)))
@ -44,7 +45,7 @@
#define SMB_VFS_MKDIR(conn, path, mode) ((conn)->vfs.ops.mkdir((conn)->vfs.handles.mkdir,(path), (mode)))
#define SMB_VFS_RMDIR(conn, path) ((conn)->vfs.ops.rmdir((conn)->vfs.handles.rmdir, (path)))
#define SMB_VFS_CLOSEDIR(conn, dir) ((conn)->vfs.ops.closedir((conn)->vfs.handles.closedir, dir))
/* File operations */
#define SMB_VFS_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs.ops.open)((conn)->vfs.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_CLOSE(fsp, fd) ((fsp)->conn->vfs.ops.close_fn((fsp)->conn->vfs.handles.close_hnd, (fsp), (fd)))
@ -82,6 +83,7 @@
#define SMB_VFS_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs.ops.notify_watch((conn)->vfs.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
#define SMB_VFS_CHFLAGS(conn, path, flags) ((conn)->vfs.ops.chflags((conn)->vfs.handles.chflags, (path), (flags)))
#define SMB_VFS_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops.file_id_create((conn)->vfs.handles.file_id_create, (dev), (inode)))
#define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs.ops.streaminfo((conn)->vfs.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
/* NT ACL operations. */
#define SMB_VFS_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
@ -138,6 +140,11 @@
#define SMB_VFS_AIO_ERROR(fsp,aiocb) ((fsp)->conn->vfs.ops.aio_error_fn((fsp)->conn->vfs.handles.aio_error,(fsp),(aiocb)))
#define SMB_VFS_AIO_FSYNC(fsp,op,aiocb) ((fsp)->conn->vfs.ops.aio_fsync((fsp)->conn->vfs.handles.aio_fsync,(fsp),(op),(aiocb)))
#define SMB_VFS_AIO_SUSPEND(fsp,aiocb,n,ts) ((fsp)->conn->vfs.ops.aio_suspend((fsp)->conn->vfs.handles.aio_suspend,(fsp),(aiocb),(n),(ts)))
#define SMB_VFS_AIO_FORCE(fsp) ((fsp)->conn->vfs.ops.aio_force((fsp)->conn->vfs.handles.aio_force,(fsp)))
/* Offline operations */
#define SMB_VFS_IS_OFFLINE(conn,path,sbuf) ((conn)->vfs.ops.is_offline((conn)->vfs.handles.is_offline,(path),(sbuf)))
#define SMB_VFS_SET_OFFLINE(conn,path) ((conn)->vfs.ops.set_offline((conn)->vfs.handles.set_offline,(path)))
/*******************************************************************
Don't access conn->vfs_opaque.ops directly!!!
@ -145,7 +152,7 @@
(Fixes should also go into the vfs_* and vfs_next_* macros!)
********************************************************************/
/* Disk operations */
/* Disk operations */
#define SMB_VFS_OPAQUE_CONNECT(conn, service, user) ((conn)->vfs_opaque.ops.connect_fn((conn)->vfs_opaque.handles.connect_hnd, (service), (user)))
#define SMB_VFS_OPAQUE_DISCONNECT(conn) ((conn)->vfs_opaque.ops.disconnect((conn)->vfs_opaque.handles.disconnect))
#define SMB_VFS_OPAQUE_DISK_FREE(conn, path, small_query, bsize, dfree ,dsize) ((conn)->vfs_opaque.ops.disk_free((conn)->vfs_opaque.handles.disk_free, (path), (small_query), (bsize), (dfree), (dsize)))
@ -153,6 +160,7 @@
#define SMB_VFS_OPAQUE_SET_QUOTA(conn, qtype, id, qt) ((conn)->vfs_opaque.ops.set_quota((conn)->vfs_opaque.handles.set_quota, (qtype), (id), (qt)))
#define SMB_VFS_OPAQUE_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) ((fsp)->conn->vfs_opaque.ops.get_shadow_copy_data((fsp)->conn->vfs_opaque.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
#define SMB_VFS_OPAQUE_STATVFS(conn, path, statbuf) ((conn)->vfs_opaque.ops.statvfs((conn)->vfs_opaque.handles.statvfs, (path), (statbuf)))
#define SMB_VFS_OPAQUE_FS_CAPABILITIES(conn) ((conn)->vfs_opaque.ops.fs_capabilities((conn)->vfs_opaque.handles.fs_capabilities))
/* Directory operations */
#define SMB_VFS_OPAQUE_OPENDIR(conn, fname, mask, attr) ((conn)->vfs_opaque.ops.opendir((conn)->vfs_opaque.handles.opendir, (fname), (mask), (attr)))
@ -163,7 +171,7 @@
#define SMB_VFS_OPAQUE_MKDIR(conn, path, mode) ((conn)->vfs_opaque.ops.mkdir((conn)->vfs_opaque.handles.mkdir,(path), (mode)))
#define SMB_VFS_OPAQUE_RMDIR(conn, path) ((conn)->vfs_opaque.ops.rmdir((conn)->vfs_opaque.handles.rmdir, (path)))
#define SMB_VFS_OPAQUE_CLOSEDIR(conn, dir) ((conn)->vfs_opaque.ops.closedir((conn)->vfs_opaque.handles.closedir, dir))
/* File operations */
#define SMB_VFS_OPAQUE_OPEN(conn, fname, fsp, flags, mode) (((conn)->vfs_opaque.ops.open)((conn)->vfs_opaque.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_OPAQUE_CLOSE(fsp, fd) ((fsp)->conn->vfs_opaque.ops.close_fn((fsp)->conn->vfs_opaque.handles.close_hnd, (fsp), (fd)))
@ -201,6 +209,7 @@
#define SMB_VFS_OPAQUE_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs_opaque.ops.notify_watch((conn)->vfs_opaque.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
#define SMB_VFS_OPAQUE_CHFLAGS(conn, path, flags) ((conn)->vfs_opaque.ops.chflags((conn)->vfs_opaque.handles.chflags, (path), (flags)))
#define SMB_VFS_OPAQUE_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops_opaque.file_id_create((conn)->vfs_opaque.handles.file_id_create, (dev), (inode)))
#define SMB_VFS_OPAQUE_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs_opaque.ops.streaminfo((conn)->vfs_opaque.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
/* NT ACL operations. */
#define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
@ -257,6 +266,11 @@
#define SMB_VFS_OPAQUE_AIO_ERROR(fsp,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_error_fn((fsp)->conn->vfs_opaque.handles.aio_error,(fsp),(aiocb)))
#define SMB_VFS_OPAQUE_AIO_FSYNC(fsp,op,aiocb) ((fsp)->conn->vfs_opaque.ops.aio_fsync((fsp)->conn->vfs_opaque.handles.aio_fsync,(fsp),(op),(aiocb)))
#define SMB_VFS_OPAQUE_AIO_SUSPEND(fsp,aiocb,n,ts) ((fsp)->conn->vfs_opaque.ops.aio_suspend((fsp)->conn->vfs_opaque.handles.aio_suspend,(fsp),(aiocb),(n),(ts)))
#define SMB_VFS_OPAQUE_AIO_FORCE(fsp) ((fsp)->conn->vfs_opaque.ops.aio_force((fsp)->conn->vfs_opaque.handles.aio_force,(fsp)))
/* Offline operations */
#define SMB_VFS_OPAQUE_IS_OFFLINE(conn,path,sbuf) ((conn)->vfs_opaque.ops.is_offline((conn)->vfs_opaque.handles.is_offline,(path),(sbuf)))
#define SMB_VFS_OPAQUE_SET_OFFLINE(conn,path) ((conn)->vfs_opaque.ops.set_offline((conn)->vfs_opaque.handles.set_offline,(path)))
/*******************************************************************
Don't access handle->vfs_next.ops.* directly!!!
@ -264,7 +278,7 @@
(Fixes should go also into the vfs_* and vfs_opaque_* macros!)
********************************************************************/
/* Disk operations */
/* Disk operations */
#define SMB_VFS_NEXT_CONNECT(handle, service, user) ((handle)->vfs_next.ops.connect_fn((handle)->vfs_next.handles.connect_hnd, (service), (user)))
#define SMB_VFS_NEXT_DISCONNECT(handle) ((handle)->vfs_next.ops.disconnect((handle)->vfs_next.handles.disconnect))
#define SMB_VFS_NEXT_DISK_FREE(handle, path, small_query, bsize, dfree ,dsize) ((handle)->vfs_next.ops.disk_free((handle)->vfs_next.handles.disk_free, (path), (small_query), (bsize), (dfree), (dsize)))
@ -272,6 +286,7 @@
#define SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt) ((handle)->vfs_next.ops.set_quota((handle)->vfs_next.handles.set_quota, (qtype), (id), (qt)))
#define SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data ,labels) ((handle)->vfs_next.ops.get_shadow_copy_data((handle)->vfs_next.handles.get_shadow_copy_data,(fsp),(shadow_copy_data),(labels)))
#define SMB_VFS_NEXT_STATVFS(handle, path, statbuf) ((handle)->vfs_next.ops.statvfs((handle)->vfs_next.handles.statvfs, (path), (statbuf)))
#define SMB_VFS_NEXT_FS_CAPABILITIES(handle) ((handle)->vfs_next.ops.fs_capabilities((handle)->vfs_next.handles.fs_capabilities))
/* Directory operations */
#define SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr) ((handle)->vfs_next.ops.opendir((handle)->vfs_next.handles.opendir, (fname), (mask), (attr)))
@ -283,7 +298,7 @@
#define SMB_VFS_NEXT_MKDIR(handle, path, mode) ((handle)->vfs_next.ops.mkdir((handle)->vfs_next.handles.mkdir,(path), (mode)))
#define SMB_VFS_NEXT_RMDIR(handle, path) ((handle)->vfs_next.ops.rmdir((handle)->vfs_next.handles.rmdir, (path)))
#define SMB_VFS_NEXT_CLOSEDIR(handle, dir) ((handle)->vfs_next.ops.closedir((handle)->vfs_next.handles.closedir, dir))
/* File operations */
#define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) (((handle)->vfs_next.ops.open)((handle)->vfs_next.handles.open, (fname), (fsp), (flags), (mode)))
#define SMB_VFS_NEXT_CLOSE(handle, fsp, fd) ((handle)->vfs_next.ops.close_fn((handle)->vfs_next.handles.close_hnd, (fsp), (fd)))
@ -321,6 +336,7 @@
#define SMB_VFS_NEXT_NOTIFY_WATCH(conn, ctx, e, callback, private_data, handle_p) ((conn)->vfs_next.ops.notify_watch((conn)->vfs_next.handles.notify_watch, (ctx), (e), (callback), (private_data), (handle_p)))
#define SMB_VFS_NEXT_CHFLAGS(handle, path, flags) ((handle)->vfs_next.ops.chflags((handle)->vfs_next.handles.chflags, (path), (flags)))
#define SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode) ((handle)->vfs_next.ops.file_id_create((handle)->vfs_next.handles.file_id_create, (dev), (inode)))
#define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, num_streams, streams) ((handle)->vfs.ops.streaminfo((handle)->vfs.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams)))
/* NT ACL operations. */
#define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (security_info), (ppdesc)))
@ -377,5 +393,10 @@
#define SMB_VFS_NEXT_AIO_ERROR(handle,fsp,aiocb) ((handle)->vfs_next.ops.aio_error_fn((handle)->vfs_next.handles.aio_error,(fsp),(aiocb)))
#define SMB_VFS_NEXT_AIO_FSYNC(handle,fsp,op,aiocb) ((handle)->vfs_next.ops.aio_fsync((handle)->vfs_next.handles.aio_fsync,(fsp),(op),(aiocb)))
#define SMB_VFS_NEXT_AIO_SUSPEND(handle,fsp,aiocb,n,ts) ((handle)->vfs_next.ops.aio_suspend((handle)->vfs_next.handles.aio_suspend,(fsp),(aiocb),(n),(ts)))
#define SMB_VFS_NEXT_AIO_FORCE(handle,fsp) ((handle)->vfs_next.ops.aio_force((handle)->vfs_next.handles.aio_force,(fsp)))
/* Offline operations */
#define SMB_VFS_NEXT_IS_OFFLINE(handle,path,sbuf) ((handle)->vfs_next.ops.is_offline((handle)->vfs_next.handles.is_offline,(path),(sbuf)))
#define SMB_VFS_NEXT_SET_OFFLINE(handle,path) ((handle)->vfs_next.ops.set_offline((handle)->vfs_next.handles.set_offline,(path)))
#endif /* _VFS_MACROS_H */

View File

@ -127,7 +127,11 @@ bool lang_tdb_init(const char *lang)
if (!lang)
return True;
asprintf(&msg_path, "%s.msg", data_path((const char *)lang));
if (asprintf(&msg_path, "%s.msg",
data_path((const char *)lang)) == -1) {
DEBUG(0, ("asprintf failed\n"));
goto done;
}
if (stat(msg_path, &st) != 0) {
/* the msg file isn't available */
DEBUG(10, ("lang_tdb_init: %s: %s\n", msg_path,
@ -135,7 +139,10 @@ bool lang_tdb_init(const char *lang)
goto done;
}
asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang);
if (asprintf(&path, "%s%s.tdb", lock_path("lang_"), lang) == -1) {
DEBUG(0, ("asprintf failed\n"));
goto done;
}
DEBUG(10, ("lang_tdb_init: loading %s\n", path));

View File

@ -42,20 +42,23 @@ static char *afs_encode_token(const char *cell, const DATA_BLOB ticket,
const struct ClearToken *ct)
{
char *base64_ticket;
char *result;
char *result = NULL;
DATA_BLOB key = data_blob(ct->HandShakeKey, 8);
char *base64_key;
TALLOC_CTX *mem_ctx;
base64_ticket = base64_encode_data_blob(ticket);
mem_ctx = talloc_stackframe();
if (mem_ctx == NULL)
goto done;
base64_ticket = base64_encode_data_blob(mem_ctx, ticket);
if (base64_ticket == NULL)
return NULL;
goto done;
base64_key = base64_encode_data_blob(key);
if (base64_key == NULL) {
TALLOC_FREE(base64_ticket);
return NULL;
}
base64_key = base64_encode_data_blob(mem_ctx, key);
if (base64_key == NULL)
goto done;
asprintf(&result, "%s\n%u\n%s\n%u\n%u\n%u\n%s\n", cell,
ct->AuthHandle, base64_key, ct->ViceId, ct->BeginTimestamp,
@ -63,8 +66,8 @@ static char *afs_encode_token(const char *cell, const DATA_BLOB ticket,
DEBUG(10, ("Got ticket string:\n%s\n", result));
TALLOC_FREE(base64_ticket);
TALLOC_FREE(base64_key);
done:
TALLOC_FREE(mem_ctx);
return result;
}

View File

@ -53,20 +53,21 @@ static bool afs_decode_token(const char *string, char **cell,
{
DATA_BLOB blob;
struct ClearToken result_ct;
char *saveptr;
char *s = SMB_STRDUP(string);
char *t;
if ((t = strtok(s, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(s, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}
*cell = SMB_STRDUP(t);
if ((t = strtok(NULL, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}
@ -75,8 +76,8 @@ static bool afs_decode_token(const char *string, char **cell,
return False;
}
if ((t = strtok(NULL, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}
@ -93,8 +94,8 @@ static bool afs_decode_token(const char *string, char **cell,
data_blob_free(&blob);
if ((t = strtok(NULL, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}
@ -103,8 +104,8 @@ static bool afs_decode_token(const char *string, char **cell,
return False;
}
if ((t = strtok(NULL, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}
@ -113,8 +114,8 @@ static bool afs_decode_token(const char *string, char **cell,
return False;
}
if ((t = strtok(NULL, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}
@ -123,8 +124,8 @@ static bool afs_decode_token(const char *string, char **cell,
return False;
}
if ((t = strtok(NULL, "\n")) == NULL) {
DEBUG(10, ("strtok failed\n"));
if ((t = strtok_r(NULL, "\n", &saveptr)) == NULL) {
DEBUG(10, ("strtok_r failed\n"));
return False;
}

68
source/lib/async_req.c Normal file
View File

@ -0,0 +1,68 @@
/*
Unix SMB/CIFS implementation.
Infrastructure for async requests
Copyright (C) Volker Lendecke 2008
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req)
{
return talloc_asprintf(mem_ctx, "async_req: state=%d, status=%s, "
"priv=%s", req->state, nt_errstr(req->status),
talloc_get_name(req->private_data));
}
struct async_req *async_req_new(TALLOC_CTX *mem_ctx, struct event_context *ev)
{
struct async_req *result;
result = TALLOC_ZERO_P(mem_ctx, struct async_req);
if (result == NULL) {
return NULL;
}
result->state = ASYNC_REQ_IN_PROGRESS;
result->event_ctx = ev;
result->print = async_req_print;
return result;
}
void async_req_done(struct async_req *req)
{
req->status = NT_STATUS_OK;
req->state = ASYNC_REQ_DONE;
if (req->async.fn != NULL) {
req->async.fn(req);
}
}
void async_req_error(struct async_req *req, NTSTATUS status)
{
req->status = status;
req->state = ASYNC_REQ_ERROR;
if (req->async.fn != NULL) {
req->async.fn(req);
}
}
bool async_req_nomem(const void *p, struct async_req *req)
{
if (p != NULL) {
return false;
}
async_req_error(req, NT_STATUS_NO_MEMORY);
return true;
}

View File

@ -524,7 +524,7 @@ size_t convert_string(charset_t from, charset_t to,
size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
void const *src, size_t srclen, void *dst, bool allow_bad_conv)
{
size_t i_len, o_len, destlen = MAX(srclen, 512);
size_t i_len, o_len, destlen = (srclen * 3) / 2;
size_t retval;
const char *inbuf = (const char *)src;
char *outbuf = NULL, *ob = NULL;
@ -550,7 +550,8 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
convert:
if ((destlen*2) < destlen) {
/* +2 is for ucs2 null termination. */
if ((destlen*2)+2 < destlen) {
/* wrapped ! abort. */
if (!conv_silent)
DEBUG(0, ("convert_string_allocate: destlen wrapped !\n"));
@ -561,10 +562,11 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
destlen = destlen * 2;
}
/* +2 is for ucs2 null termination. */
if (ctx) {
ob = (char *)TALLOC_REALLOC(ctx, ob, destlen);
ob = (char *)TALLOC_REALLOC(ctx, ob, destlen + 2);
} else {
ob = (char *)SMB_REALLOC(ob, destlen);
ob = (char *)SMB_REALLOC(ob, destlen + 2);
}
if (!ob) {
@ -619,10 +621,11 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
* reallocs *cost*. JRA.
*/
if (o_len > 1024) {
/* We're shrinking here so we know the +2 is safe from wrap. */
if (ctx) {
ob = (char *)TALLOC_REALLOC(ctx,ob,destlen);
ob = (char *)TALLOC_REALLOC(ctx,ob,destlen + 2);
} else {
ob = (char *)SMB_REALLOC(ob,destlen);
ob = (char *)SMB_REALLOC(ob,destlen + 2);
}
}
@ -632,6 +635,11 @@ size_t convert_string_allocate(TALLOC_CTX *ctx, charset_t from, charset_t to,
}
*dest = ob;
/* Must ucs2 null terminate in the extra space we allocated. */
ob[destlen] = '\0';
ob[destlen+1] = '\0';
return destlen;
use_as_is:

View File

@ -34,7 +34,7 @@ static struct db_context *connections_db_ctx(bool rw)
}
else {
db_ctx = db_open(NULL, lock_path("connections.tdb"), 0,
TDB_DEFAULT, O_RDONLY, 0);
TDB_CLEAR_IF_FIRST|TDB_DEFAULT, O_RDONLY, 0);
}
return db_ctx;

View File

@ -1203,6 +1203,42 @@ NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn)
return register_with_ctdbd(conn, CTDB_SRVID_RECONFIGURE);
}
/*
persstent store. Used when we update a record in a persistent database
*/
NTSTATUS ctdbd_persistent_store(struct ctdbd_connection *conn, uint32_t db_id, TDB_DATA key, TDB_DATA data)
{
int cstatus=0;
struct ctdb_rec_data *rec;
TDB_DATA recdata;
size_t length;
NTSTATUS status;
length = offsetof(struct ctdb_rec_data, data) + key.dsize + data.dsize;
rec = (struct ctdb_rec_data *)talloc_size(conn, length);
NT_STATUS_HAVE_NO_MEMORY(rec);
rec->length = length;
rec->reqid = db_id;
rec->keylen = key.dsize;
rec->datalen= data.dsize;
memcpy(&rec->data[0], key.dptr, key.dsize);
memcpy(&rec->data[key.dsize], data.dptr, data.dsize);
recdata.dptr = (uint8_t *)rec;
recdata.dsize = length;
status = ctdbd_control(conn, CTDB_CURRENT_NODE,
CTDB_CONTROL_PERSISTENT_STORE,
0, recdata, NULL, NULL, &cstatus);
if (cstatus != 0) {
return NT_STATUS_INTERNAL_DB_CORRUPTION;
}
return status;
}
#else
NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,

View File

@ -144,3 +144,15 @@ DATA_BLOB data_blob_const(const void *p, size_t length)
blob.free = NULL;
return blob;
}
/**
construct a zero data blob, using supplied TALLOC_CTX.
use this sparingly as it initialises data - better to initialise
yourself if you want specific data in the blob
**/
DATA_BLOB data_blob_talloc_zero(TALLOC_CTX *mem_ctx, size_t length)
{
DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, length);
data_blob_clear(&blob);
return blob;
}

View File

@ -20,7 +20,9 @@
*/
#include "includes.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb_private.h"
#endif
/*
* Fall back using fetch_locked if no genuine fetch operation is provided
*/
@ -46,10 +48,16 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
int open_flags, mode_t mode)
{
struct db_context *result = NULL;
#ifdef CLUSTER_SUPPORT
const char *sockname = lp_ctdbd_socket();
#endif
#ifdef CLUSTER_SUPPORT
if(!sockname || !*sockname) {
sockname = CTDB_PATH;
}
if (lp_clustering()) {
if (lp_clustering() && socket_exist(sockname)) {
const char *partname;
/* ctdb only wants the file part of the name */
partname = strrchr(name, '/');

View File

@ -18,16 +18,14 @@
*/
#include "includes.h"
#ifdef CLUSTER_SUPPORT
#include "ctdb.h"
#include "ctdb_private.h"
#include "ctdbd_conn.h"
struct db_ctdb_ctx {
struct tdb_wrap *wtdb;
uint32 db_id;
struct ctdbd_connection *conn;
};
struct db_ctdb_rec {
@ -35,8 +33,6 @@ struct db_ctdb_rec {
struct ctdb_ltdb_header header;
};
static struct ctdbd_connection *db_ctdbd_conn(struct db_ctdb_ctx *ctx);
static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
{
struct db_ctdb_rec *crec = talloc_get_type_abort(
@ -60,6 +56,42 @@ static NTSTATUS db_ctdb_store(struct db_record *rec, TDB_DATA data, int flag)
return (ret == 0) ? NT_STATUS_OK : NT_STATUS_INTERNAL_DB_CORRUPTION;
}
/* for persistent databases the store is a bit different. We have to
ask the ctdb daemon to push the record to all nodes after the
store */
static NTSTATUS db_ctdb_store_persistent(struct db_record *rec, TDB_DATA data, int flag)
{
struct db_ctdb_rec *crec = talloc_get_type_abort(
rec->private_data, struct db_ctdb_rec);
TDB_DATA cdata;
int ret;
NTSTATUS status;
cdata.dsize = sizeof(crec->header) + data.dsize;
if (!(cdata.dptr = SMB_MALLOC_ARRAY(uint8, cdata.dsize))) {
return NT_STATUS_NO_MEMORY;
}
crec->header.rsn++;
memcpy(cdata.dptr, &crec->header, sizeof(crec->header));
memcpy(cdata.dptr + sizeof(crec->header), data.dptr, data.dsize);
ret = tdb_store(crec->ctdb_ctx->wtdb->tdb, rec->key, cdata, TDB_REPLACE);
status = (ret == 0) ? NT_STATUS_OK : NT_STATUS_INTERNAL_DB_CORRUPTION;
/* now tell ctdbd to update this record on all other nodes */
if (NT_STATUS_IS_OK(status)) {
status = ctdbd_persistent_store(messaging_ctdbd_connection(), crec->ctdb_ctx->db_id, rec->key, cdata);
}
SAFE_FREE(cdata.dptr);
return status;
}
static NTSTATUS db_ctdb_delete(struct db_record *rec)
{
struct db_ctdb_rec *crec = talloc_get_type_abort(
@ -110,6 +142,7 @@ static struct db_record *db_ctdb_fetch_locked(struct db_context *db,
struct db_ctdb_rec *crec;
NTSTATUS status;
TDB_DATA ctdb_data;
int migrate_attempts = 0;
if (!(result = talloc(mem_ctx, struct db_record))) {
DEBUG(0, ("talloc failed\n"));
@ -153,7 +186,11 @@ again:
return NULL;
}
result->store = db_ctdb_store;
if (db->persistent) {
result->store = db_ctdb_store_persistent;
} else {
result->store = db_ctdb_store;
}
result->delete_rec = db_ctdb_delete;
talloc_set_destructor(result, db_ctdb_record_destr);
@ -175,12 +212,14 @@ again:
tdb_chainunlock(ctx->wtdb->tdb, key);
talloc_set_destructor(result, NULL);
migrate_attempts += 1;
DEBUG(10, ("ctdb_data.dptr = %p, dmaster = %u (%u)\n",
ctdb_data.dptr, ctdb_data.dptr ?
((struct ctdb_ltdb_header *)ctdb_data.dptr)->dmaster : -1,
get_my_vnn()));
status = ctdbd_migrate(db_ctdbd_conn(ctx), ctx->db_id, key);
status = ctdbd_migrate(messaging_ctdbd_connection(),ctx->db_id, key);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("ctdb_migrate failed: %s\n",
nt_errstr(status)));
@ -191,6 +230,11 @@ again:
goto again;
}
if (migrate_attempts > 10) {
DEBUG(0, ("db_ctdb_fetch_locked needed %d attempts\n",
migrate_attempts));
}
memcpy(&crec->header, ctdb_data.dptr, sizeof(crec->header));
result->value.dsize = ctdb_data.dsize - sizeof(crec->header);
@ -226,10 +270,12 @@ static int db_ctdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
/*
* See if we have a valid record and we are the dmaster. If so, we can
* take the shortcut and just return it.
* we bypass the dmaster check for persistent databases
*/
if ((ctdb_data.dptr != NULL) &&
(ctdb_data.dsize >= sizeof(struct ctdb_ltdb_header)) &&
((struct ctdb_ltdb_header *)ctdb_data.dptr)->dmaster == get_my_vnn()) {
(db->persistent ||
((struct ctdb_ltdb_header *)ctdb_data.dptr)->dmaster == get_my_vnn())) {
/* we are the dmaster - avoid the ctdb protocol op */
data->dsize = ctdb_data.dsize - sizeof(struct ctdb_ltdb_header);
@ -254,8 +300,7 @@ static int db_ctdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx,
SAFE_FREE(ctdb_data.dptr);
/* we weren't able to get it locally - ask ctdb to fetch it for us */
status = ctdbd_fetch(db_ctdbd_conn(ctx), ctx->db_id, key, mem_ctx,
data);
status = ctdbd_fetch(messaging_ctdbd_connection(),ctx->db_id, key, mem_ctx, data);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("ctdbd_fetch failed: %s\n", nt_errstr(status)));
return -1;
@ -283,6 +328,22 @@ static void traverse_callback(TDB_DATA key, TDB_DATA data, void *private_data)
talloc_free(tmp_ctx);
}
static int traverse_persistent_callback(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *private_data)
{
struct traverse_state *state = (struct traverse_state *)private_data;
struct db_record *rec;
TALLOC_CTX *tmp_ctx = talloc_new(state->db);
int ret = 0;
/* we have to give them a locked record to prevent races */
rec = db_ctdb_fetch_locked(state->db, tmp_ctx, kbuf);
if (rec && rec->value.dsize > 0) {
ret = state->fn(rec, state->private_data);
}
talloc_free(tmp_ctx);
return ret;
}
static int db_ctdb_traverse(struct db_context *db,
int (*fn)(struct db_record *rec,
void *private_data),
@ -296,6 +357,13 @@ static int db_ctdb_traverse(struct db_context *db,
state.fn = fn;
state.private_data = private_data;
if (db->persistent) {
/* for persistent databases we don't need to do a ctdb traverse,
we can do a faster local traverse */
return tdb_traverse(ctx->wtdb->tdb, traverse_persistent_callback, &state);
}
ctdbd_traverse(ctx->db_id, traverse_callback, &state);
return 0;
}
@ -322,6 +390,27 @@ static void traverse_read_callback(TDB_DATA key, TDB_DATA data, void *private_da
state->fn(&rec, state->private_data);
}
static int traverse_persistent_callback_read(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
void *private_data)
{
struct traverse_state *state = (struct traverse_state *)private_data;
struct db_record rec;
rec.key = kbuf;
rec.value = dbuf;
rec.store = db_ctdb_store_deny;
rec.delete_rec = db_ctdb_delete_deny;
rec.private_data = state->db;
if (rec.value.dsize <= sizeof(struct ctdb_ltdb_header)) {
/* a deleted record */
return 0;
}
rec.value.dsize -= sizeof(struct ctdb_ltdb_header);
rec.value.dptr += sizeof(struct ctdb_ltdb_header);
return state->fn(&rec, state->private_data);
}
static int db_ctdb_traverse_read(struct db_context *db,
int (*fn)(struct db_record *rec,
void *private_data),
@ -335,6 +424,12 @@ static int db_ctdb_traverse_read(struct db_context *db,
state.fn = fn;
state.private_data = private_data;
if (db->persistent) {
/* for persistent databases we don't need to do a ctdb traverse,
we can do a faster local traverse */
return tdb_traverse_read(ctx->wtdb->tdb, traverse_persistent_callback_read, &state);
}
ctdbd_traverse(ctx->db_id, traverse_read_callback, &state);
return 0;
}
@ -346,41 +441,6 @@ static int db_ctdb_get_seqnum(struct db_context *db)
return tdb_get_seqnum(ctx->wtdb->tdb);
}
/*
* Get the ctdbd connection for a database. If possible, re-use the messaging
* ctdbd connection
*/
static struct ctdbd_connection *db_ctdbd_conn(struct db_ctdb_ctx *ctx)
{
struct ctdbd_connection *result;
result = messaging_ctdbd_connection();
if (result != NULL) {
if (ctx->conn == NULL) {
/*
* Someone has initialized messaging since we
* initialized our own connection, we don't need it
* anymore.
*/
TALLOC_FREE(ctx->conn);
}
return result;
}
if (ctx->conn == NULL) {
NTSTATUS status;
status = ctdbd_init_connection(ctx, &ctx->conn);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
}
set_my_vnn(ctdbd_vnn(ctx->conn));
}
return ctx->conn;
}
struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
const char *name,
@ -390,7 +450,6 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
struct db_context *result;
struct db_ctdb_ctx *db_ctdb;
char *db_path;
NTSTATUS status;
if (!lp_clustering()) {
DEBUG(10, ("Clustering disabled -- no ctdb\n"));
@ -409,20 +468,15 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
return NULL;
}
db_ctdb->conn = NULL;
status = ctdbd_db_attach(db_ctdbd_conn(db_ctdb), name,
&db_ctdb->db_id, tdb_flags);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("ctdbd_db_attach failed for %s: %s\n", name,
nt_errstr(status)));
if (!NT_STATUS_IS_OK(ctdbd_db_attach(messaging_ctdbd_connection(),name, &db_ctdb->db_id, tdb_flags))) {
DEBUG(0, ("ctdbd_db_attach failed for %s\n", name));
TALLOC_FREE(result);
return NULL;
}
db_path = ctdbd_dbpath(db_ctdbd_conn(db_ctdb), db_ctdb,
db_ctdb->db_id);
db_path = ctdbd_dbpath(messaging_ctdbd_connection(), db_ctdb, db_ctdb->db_id);
result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);
/* only pass through specific flags */
tdb_flags &= TDB_SEQNUM;
@ -447,16 +501,4 @@ struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
return result;
}
#else
struct db_context *db_open_ctdb(TALLOC_CTX *mem_ctx,
const char *name,
int hash_size, int tdb_flags,
int open_flags, mode_t mode)
{
DEBUG(0, ("no clustering compiled in\n"));
return NULL;
}
#endif

View File

@ -17,10 +17,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Be aware that this is just sample code that has not seen too much testing
*/
#include "includes.h"
struct db_file_ctx {
@ -367,6 +363,7 @@ struct db_context *db_open_file(TALLOC_CTX *mem_ctx,
result->fetch_locked = db_file_fetch_locked;
result->traverse = db_file_traverse;
result->traverse_read = db_file_traverse;
result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);
ctx->locked_record = NULL;
if (!(ctx->dirname = talloc_strdup(ctx, name))) {

View File

@ -31,6 +31,11 @@ static int db_tdb_record_destr(struct db_record* data)
struct db_tdb_ctx *ctx =
talloc_get_type_abort(data->private_data, struct db_tdb_ctx);
/* This hex_encode() call allocates memory on data context. By way how current
__talloc_free() code works, it is OK to allocate in the destructor as
the children of data will be freed after call to the destructor and this
new 'child' will be caught and freed correctly.
*/
DEBUG(10, (DEBUGLEVEL > 10
? "Unlocking key %s\n" : "Unlocking key %.20s\n",
hex_encode(data, (unsigned char *)data->key.dptr,
@ -86,10 +91,10 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db,
struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data,
struct db_tdb_ctx);
struct tdb_fetch_locked_state state;
int res;
if (DEBUGLEVEL >= 10) {
char *keystr = hex_encode(NULL, key.dptr, key.dsize);
/* Do not accidently allocate/deallocate w/o need when debug level is lower than needed */
if(DEBUGLEVEL >= 10) {
char *keystr = hex_encode(NULL, (unsigned char*)key.dptr, key.dsize);
DEBUG(10, (DEBUGLEVEL > 10
? "Locking key %s\n" : "Locking key %.20s\n",
keystr));
@ -104,8 +109,7 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db,
state.mem_ctx = mem_ctx;
state.result = NULL;
res = tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse,
&state);
tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse, &state);
if (state.result == NULL) {
db_tdb_fetchlock_parse(key, tdb_null, &state);
@ -191,15 +195,16 @@ static NTSTATUS db_tdb_delete(struct db_record *rec)
{
struct db_tdb_ctx *ctx = talloc_get_type_abort(rec->private_data,
struct db_tdb_ctx);
int res;
res = tdb_delete(ctx->wtdb->tdb, rec->key);
if (res == 0) {
if (tdb_delete(ctx->wtdb->tdb, rec->key) == 0) {
return NT_STATUS_OK;
}
return map_nt_error_from_tdb(tdb_error(ctx->wtdb->tdb));
if (tdb_error(ctx->wtdb->tdb) == TDB_ERR_NOEXIST) {
return NT_STATUS_NOT_FOUND;
}
return NT_STATUS_UNSUCCESSFUL;
}
struct db_tdb_traverse_ctx {
@ -318,6 +323,7 @@ struct db_context *db_open_tdb(TALLOC_CTX *mem_ctx,
result->traverse = db_tdb_traverse;
result->traverse_read = db_tdb_traverse_read;
result->get_seqnum = db_tdb_get_seqnum;
result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);
return result;
fail:

90
source/lib/dbwrap_util.c Normal file
View File

@ -0,0 +1,90 @@
/*
Unix SMB/CIFS implementation.
Utility functions for the dbwrap API
Copyright (C) Volker Lendecke 2007
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "includes.h"
int32_t dbwrap_fetch_int32(struct db_context *db, const char *keystr)
{
TDB_DATA dbuf;
int32 ret;
if (db->fetch(db, NULL, string_term_tdb_data(keystr), &dbuf) != 0) {
return -1;
}
if ((dbuf.dptr == NULL) || (dbuf.dsize != sizeof(int32_t))) {
TALLOC_FREE(dbuf.dptr);
return -1;
}
ret = IVAL(dbuf.dptr, 0);
TALLOC_FREE(dbuf.dptr);
return ret;
}
int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v)
{
struct db_record *rec;
int32 v_store;
NTSTATUS status;
rec = db->fetch_locked(db, NULL, string_term_tdb_data(keystr));
if (rec == NULL) {
return -1;
}
SIVAL(&v_store, 0, v);
status = rec->store(rec, make_tdb_data((const uint8 *)&v_store,
sizeof(v_store)),
TDB_REPLACE);
TALLOC_FREE(rec);
return NT_STATUS_IS_OK(status) ? 0 : -1;
}
uint32_t dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
uint32_t *oldval, uint32_t change_val)
{
struct db_record *rec;
uint32 val = -1;
TDB_DATA data;
if (!(rec = db->fetch_locked(db, NULL,
string_term_tdb_data(keystr)))) {
return -1;
}
if ((rec->value.dptr != NULL)
&& (rec->value.dsize == sizeof(val))) {
val = IVAL(rec->value.dptr, 0);
}
val += change_val;
data.dsize = sizeof(val);
data.dptr = (uint8 *)&val;
rec->store(rec, data, TDB_REPLACE);
TALLOC_FREE(rec);
return 0;
}

View File

@ -429,8 +429,9 @@ static bool debug_parse_params(char **params)
/* Fill in new debug class levels */
for (; i < debug_num_classes && params[i]; i++) {
if ((class_name=strtok(params[i],":")) &&
(class_level=strtok(NULL, "\0")) &&
char *saveptr;
if ((class_name = strtok_r(params[i],":", &saveptr)) &&
(class_level = strtok_r(NULL, "\0", &saveptr)) &&
((ndx = debug_lookup_classname(class_name)) != -1)) {
DEBUGLEVEL_CLASS[ndx] = atoi(class_level);
DEBUGLEVEL_CLASS_ISSET[ndx] = True;
@ -459,14 +460,14 @@ bool debug_parse_levels(const char *params_str)
if (AllowDebugChange == False)
return True;
params = str_list_make(params_str, NULL);
params = str_list_make(talloc_tos(), params_str, NULL);
if (debug_parse_params(params)) {
debug_dump_status(5);
str_list_free(&params);
TALLOC_FREE(params);
return True;
} else {
str_list_free(&params);
TALLOC_FREE(params);
return False;
}
}
@ -826,6 +827,7 @@ void check_log_size( void )
};
int priority;
char *msgbuf = NULL;
int ret;
if( syslog_level >= ( sizeof(priority_map) / sizeof(priority_map[0]) ) || syslog_level < 0)
priority = LOG_DEBUG;
@ -833,10 +835,10 @@ void check_log_size( void )
priority = priority_map[syslog_level];
va_start(ap, format_str);
vasprintf(&msgbuf, format_str, ap);
ret = vasprintf(&msgbuf, format_str, ap);
va_end(ap);
if (msgbuf) {
if (ret == -1) {
syslog(priority, "%s", msgbuf);
}
SAFE_FREE(msgbuf);
@ -1058,12 +1060,13 @@ bool dbghdr(int level, int cls, const char *file, const char *func, int line)
va_list ap;
char *msgbuf = NULL;
bool ret = true;
int res;
va_start(ap, format_str);
vasprintf(&msgbuf, format_str, ap);
res = vasprintf(&msgbuf, format_str, ap);
va_end(ap);
if (msgbuf) {
if (res != -1) {
format_debug_text(msgbuf);
} else {
ret = false;

View File

@ -1,72 +0,0 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Guenther Deschner 2007
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
/****************************************************************
****************************************************************/
void display_ds_domain_controller_info(TALLOC_CTX *mem_ctx,
const struct DS_DOMAIN_CONTROLLER_INFO *info)
{
d_printf("domain_controller_name: %s\n",
info->domain_controller_name);
d_printf("domain_controller_address: %s\n",
info->domain_controller_address);
d_printf("domain_controller_address_type: %d\n",
info->domain_controller_address_type);
d_printf("domain_guid: %s\n",
GUID_string(mem_ctx, info->domain_guid));
d_printf("domain_name: %s\n",
info->domain_name);
d_printf("dns_forest_name: %s\n",
info->dns_forest_name);
d_printf("flags: 0x%08x\n"
"\tIs a PDC: %s\n"
"\tIs a GC of the forest: %s\n"
"\tIs an LDAP server: %s\n"
"\tSupports DS: %s\n"
"\tIs running a KDC: %s\n"
"\tIs running time services: %s\n"
"\tIs the closest DC: %s\n"
"\tIs writable: %s\n"
"\tHas a hardware clock: %s\n"
"\tIs a non-domain NC serviced by LDAP server: %s\n"
"\tDomainControllerName is a DNS name: %s\n"
"\tDomainName is a DNS name: %s\n"
"\tDnsForestName is a DNS name: %s\n",
info->flags,
(info->flags & ADS_PDC) ? "yes" : "no",
(info->flags & ADS_GC) ? "yes" : "no",
(info->flags & ADS_LDAP) ? "yes" : "no",
(info->flags & ADS_DS) ? "yes" : "no",
(info->flags & ADS_KDC) ? "yes" : "no",
(info->flags & ADS_TIMESERV) ? "yes" : "no",
(info->flags & ADS_CLOSEST) ? "yes" : "no",
(info->flags & ADS_WRITABLE) ? "yes" : "no",
(info->flags & ADS_GOOD_TIMESERV) ? "yes" : "no",
(info->flags & ADS_NDNC) ? "yes" : "no",
(info->flags & ADS_DNS_CONTROLLER) ? "yes":"no",
(info->flags & ADS_DNS_DOMAIN) ? "yes":"no",
(info->flags & ADS_DNS_FOREST) ? "yes":"no");
d_printf("dc_site_name: %s\n", info->dc_site_name);
d_printf("client_site_name: %s\n", info->client_site_name);
}

View File

@ -47,7 +47,10 @@
lang_msg_free(msgstr);
if (ret <= 0) return ret;
if (ret <= 0) {
va_end(ap2);
return ret;
}
/* now we have the string in unix format, convert it to the display
charset, but beware of it growing */
@ -56,6 +59,7 @@ again:
p2 = (char *)SMB_MALLOC(maxlen);
if (!p2) {
SAFE_FREE(p);
va_end(ap2);
return -1;
}
clen = convert_string(CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen, True);
@ -72,6 +76,8 @@ again:
ret = fwrite(p2, 1, clen, f);
SAFE_FREE(p2);
va_end(ap2);
return ret;
}

View File

@ -92,6 +92,9 @@ const struct unix_error_map unix_dos_nt_errmap[] = {
#ifdef EWOULDBLOCK
{ EWOULDBLOCK, ERRDOS, 111, NT_STATUS_NETWORK_BUSY },
#endif
#ifdef ENOATTR
{ ENOATTR, ERRDOS, ERRbadfile, NT_STATUS_NOT_FOUND },
#endif
{ 0, 0, 0, NT_STATUS_OK }
};

View File

@ -132,7 +132,6 @@ void dump_core_setup(const char *progname)
sys_chown(corepath,getuid(),getgid());
chmod(corepath,0700);
SAFE_FREE(corepath);
SAFE_FREE(logbase);
#ifdef HAVE_GETRLIMIT

View File

@ -120,9 +120,9 @@ bool gencache_set(const char *keystr, const char *value, time_t timeout)
if (!gencache_init()) return False;
asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value);
if (!valstr)
if (asprintf(&valstr, CACHE_DATA_FMT, (int)timeout, value) == -1) {
return False;
}
databuf = string_term_tdb_data(valstr);
DEBUG(10, ("Adding cache entry with key = %s; value = %s and timeout ="
@ -340,8 +340,7 @@ bool gencache_set_data_blob(const char *keystr, DATA_BLOB *blob, time_t timeout)
return False;
}
asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE);
if (!valstr) {
if (asprintf(&valstr, "%12u/%s", (int)timeout, BLOB_TYPE) == -1) {
return False;
}
@ -452,8 +451,9 @@ void gencache_iterate(void (*fn)(const char* key, const char *value, time_t time
break;
}
asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE, (unsigned int)databuf.dsize - TIMEOUT_LEN);
if (!fmt) {
if (asprintf(&fmt, READ_CACHE_DATA_FMT_TEMPLATE,
(unsigned int)databuf.dsize - TIMEOUT_LEN)
== -1) {
SAFE_FREE(valstr);
SAFE_FREE(entry);
SAFE_FREE(keystr);

View File

@ -191,7 +191,6 @@ void make_net(struct sockaddr_storage *pss_out,
Also gets IPv6 interfaces.
****************************************************************************/
#if HAVE_IFACE_GETIFADDRS
/****************************************************************************
Get the netmask address for a local interface.
****************************************************************************/
@ -237,19 +236,9 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
memcpy(&ifaces[total].netmask, ifptr->ifa_netmask, copy_size);
if (ifaces[total].flags & (IFF_BROADCAST|IFF_LOOPBACK)) {
if (ifptr->ifa_broadaddr) {
memcpy(&ifaces[total].bcast,
ifptr->ifa_broadaddr,
copy_size);
} else {
/* For some reason ifptr->ifa_broadaddr
* is null. Make one from ifa_addr and
* ifa_netmask.
*/
make_bcast(&ifaces[total].bcast,
&ifaces[total].ip,
&ifaces[total].netmask);
}
make_bcast(&ifaces[total].bcast,
&ifaces[total].ip,
&ifaces[total].netmask);
} else if ((ifaces[total].flags & IFF_POINTOPOINT) &&
ifptr->ifa_dstaddr ) {
memcpy(&ifaces[total].bcast,
@ -269,339 +258,6 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
return total;
}
#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_GETIFADDRS */
#if HAVE_IFACE_IFCONF
/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1
V4.0, Ultrix 4.4, SCO Unix 3.2, IRIX 6.4 and FreeBSD 3.2.
It probably also works on any BSD style system. */
/****************************************************************************
Get the netmask address for a local interface.
****************************************************************************/
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{
struct ifconf ifc;
char buff[8192];
int fd, i, n;
struct ifreq *ifr=NULL;
int total = 0;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
return -1;
}
ifc.ifc_len = sizeof(buff);
ifc.ifc_buf = buff;
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
close(fd);
return -1;
}
ifr = ifc.ifc_req;
n = ifc.ifc_len / sizeof(struct ifreq);
/* Loop through interfaces, looking for given IP address */
for (i=n-1;i>=0 && total < max_interfaces;i--) {
memset(&ifaces[total], '\0', sizeof(ifaces[total]));
/* Check the interface is up. */
if (ioctl(fd, SIOCGIFFLAGS, &ifr[i]) != 0) {
continue;
}
ifaces[total].flags = ifr[i].ifr_flags;
if (!(ifaces[total].flags & IFF_UP)) {
continue;
}
if (ioctl(fd, SIOCGIFADDR, &ifr[i]) != 0) {
continue;
}
strlcpy(ifaces[total].name, ifr[i].ifr_name,
sizeof(ifaces[total].name));
memcpy(&ifaces[total].ip, &ifr[i].ifr_addr,
sizeof(struct sockaddr_in));
if (ioctl(fd, SIOCGIFNETMASK, &ifr[i]) != 0) {
continue;
}
memcpy(&ifaces[total].netmask, &ifr[i].ifr_netmask,
sizeof(struct sockaddr_in));
if (ifaces[total].flags & IFF_BROADCAST) {
if (ioctl(fd, SIOCGIFBRDADDR, &ifr[i]) != 0) {
continue;
}
memcpy(&ifaces[total].bcast, &ifr[i].ifr_broadaddr,
sizeof(struct sockaddr_in));
} else if (ifaces[total].flags & IFF_POINTOPOINT) {
if (ioctl(fd, SIOCGIFDSTADDR, &ifr[i]) != 0) {
continue;
}
memcpy(&ifaces[total].bcast, &ifr[i].ifr_dstaddr,
sizeof(struct sockaddr_in));
} else {
continue;
}
total++;
}
close(fd);
return total;
}
#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_IFCONF */
#ifdef HAVE_IFACE_IFREQ
#ifndef I_STR
#include <sys/stropts.h>
#endif
/****************************************************************************
This should cover most of the streams based systems.
Thanks to Andrej.Borsenkow@mow.siemens.ru for several ideas in this code.
****************************************************************************/
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{
struct ifreq ifreq;
struct strioctl strioctl;
char buff[8192];
int fd, i, n;
struct ifreq *ifr=NULL;
int total = 0;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
return -1;
}
strioctl.ic_cmd = SIOCGIFCONF;
strioctl.ic_dp = buff;
strioctl.ic_len = sizeof(buff);
if (ioctl(fd, I_STR, &strioctl) < 0) {
close(fd);
return -1;
}
/* we can ignore the possible sizeof(int) here as the resulting
number of interface structures won't change */
n = strioctl.ic_len / sizeof(struct ifreq);
/* we will assume that the kernel returns the length as an int
at the start of the buffer if the offered size is a
multiple of the structure size plus an int */
if (n*sizeof(struct ifreq) + sizeof(int) == strioctl.ic_len) {
ifr = (struct ifreq *)(buff + sizeof(int));
} else {
ifr = (struct ifreq *)buff;
}
/* Loop through interfaces */
for (i = 0; i<n && total < max_interfaces; i++) {
memset(&ifaces[total], '\0', sizeof(ifaces[total]));
ifreq = ifr[i];
strioctl.ic_cmd = SIOCGIFFLAGS;
strioctl.ic_dp = (char *)&ifreq;
strioctl.ic_len = sizeof(struct ifreq);
if (ioctl(fd, I_STR, &strioctl) != 0) {
continue;
}
ifaces[total].flags = ifreq.ifr_flags;
if (!(ifaces[total].flags & IFF_UP)) {
continue;
}
strioctl.ic_cmd = SIOCGIFADDR;
strioctl.ic_dp = (char *)&ifreq;
strioctl.ic_len = sizeof(struct ifreq);
if (ioctl(fd, I_STR, &strioctl) != 0) {
continue;
}
strlcpy(ifaces[total].name,
ifreq.ifr_name,
sizeof(ifaces[total].name));
memcpy(&ifaces[total].ip, &ifreq.ifr_addr,
sizeof(struct sockaddr_in));
strioctl.ic_cmd = SIOCGIFNETMASK;
strioctl.ic_dp = (char *)&ifreq;
strioctl.ic_len = sizeof(struct ifreq);
if (ioctl(fd, I_STR, &strioctl) != 0) {
continue;
}
memcpy(&ifaces[total].netmask, &ifreq.ifr_addr,
sizeof(struct sockaddr_in));
if (ifaces[total].flags & IFF_BROADCAST) {
strioctl.ic_cmd = SIOCGIFBRDADDR;
strioctl.ic_dp = (char *)&ifreq;
strioctl.ic_len = sizeof(struct ifreq);
if (ioctl(fd, I_STR, &strioctl) != 0) {
continue;
}
memcpy(&ifaces[total].bcast, &ifreq.ifr_broadaddr,
sizeof(struct sockaddr_in));
} else if (ifaces[total].flags & IFF_POINTOPOINT) {
strioctl.ic_cmd = SIOCGIFDSTADDR;
strioctl.ic_dp = (char *)&ifreq;
strioctl.ic_len = sizeof(struct ifreq);
if (ioctl(fd, I_STR, &strioctl) != 0) {
continue;
}
memcpy(&ifaces[total].bcast, &ifreq.ifr_dstaddr,
sizeof(struct sockaddr_in));
} else {
continue;
}
total++;
}
close(fd);
return total;
}
#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_IFREQ */
#ifdef HAVE_IFACE_AIX
/****************************************************************************
This one is for AIX (tested on 4.2).
****************************************************************************/
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{
char buff[8192];
int fd, i;
struct ifconf ifc;
struct ifreq *ifr=NULL;
int total = 0;
if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
return -1;
}
ifc.ifc_len = sizeof(buff);
ifc.ifc_buf = buff;
if (ioctl(fd, SIOCGIFCONF, &ifc) != 0) {
close(fd);
return -1;
}
ifr = ifc.ifc_req;
/* Loop through interfaces */
i = ifc.ifc_len;
while (i > 0 && total < max_interfaces) {
uint_t inc;
memset(&ifaces[total], '\0', sizeof(ifaces[total]));
inc = ifr->ifr_addr.sa_len;
if (ioctl(fd, SIOCGIFFLAGS, ifr) != 0) {
goto next;
}
ifaces[total].flags = ifr->ifr_flags;
if (!(ifaces[total].flags & IFF_UP)) {
goto next;
}
if (ioctl(fd, SIOCGIFADDR, ifr) != 0) {
goto next;
}
memcpy(&ifaces[total].ip, &ifr->ifr_addr,
sizeof(struct sockaddr_in));
strlcpy(ifaces[total].name, ifr->ifr_name,
sizeof(ifaces[total].name));
if (ioctl(fd, SIOCGIFNETMASK, ifr) != 0) {
goto next;
}
memcpy(&ifaces[total].netmask, &ifr->ifr_addr,
sizeof(struct sockaddr_in));
if (ifaces[total].flags & IFF_BROADCAST) {
if (ioctl(fd, SIOCGIFBRDADDR, ifr) != 0) {
goto next;
}
memcpy(&ifaces[total].bcast, &ifr->ifr_broadaddr,
sizeof(struct sockaddr_in));
} else if (ifaces[total].flags & IFF_POINTOPOINT) {
if (ioctl(fd, SIOCGIFDSTADDR, ifr) != 0) {
goto next;
}
memcpy(&ifaces[total].bcast, &ifr->ifr_dstaddr,
sizeof(struct sockaddr_in));
} else {
goto next;
}
total++;
next:
/*
* Patch from Archie Cobbs (archie@whistle.com). The
* addresses in the SIOCGIFCONF interface list have a
* minimum size. Usually this doesn't matter, but if
* your machine has tunnel interfaces, etc. that have
* a zero length "link address", this does matter. */
if (inc < sizeof(ifr->ifr_addr))
inc = sizeof(ifr->ifr_addr);
inc += IFNAMSIZ;
ifr = (struct ifreq*) (((char*) ifr) + inc);
i -= inc;
}
close(fd);
return total;
}
#define _FOUND_IFACE_ANY
#endif /* HAVE_IFACE_AIX */
#ifndef _FOUND_IFACE_ANY
static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces)
{
return -1;
}
#endif
static int iface_comp(struct iface_struct *i1, struct iface_struct *i2)
{
int r;
@ -693,55 +349,3 @@ int get_interfaces(struct iface_struct *ifaces, int max_interfaces)
return total;
}
#ifdef AUTOCONF_TEST
/* this is the autoconf driver to test get_interfaces() */
static socklen_t calc_sa_size(struct sockaddr *psa)
{
socklen_t sl = sizeof(struct sockaddr_in);
#if defined(HAVE_IPV6)
if (psa->sa_family == AF_INET6) {
sl = sizeof(struct sockaddr_in6);
}
#endif
return sl;
}
int main()
{
struct iface_struct ifaces[MAX_INTERFACES];
int total = get_interfaces(ifaces, MAX_INTERFACES);
int i;
printf("got %d interfaces:\n", total);
if (total <= 0) {
exit(1);
}
for (i=0;i<total;i++) {
char addr[INET6_ADDRSTRLEN];
int ret;
printf("%-10s ", ifaces[i].name);
addr[0] = '\0';
ret = getnameinfo((struct sockaddr *)&ifaces[i].ip,
calc_sa_size(&ifaces[i].ip),
addr, sizeof(addr),
NULL, 0, NI_NUMERICHOST);
printf("IP=%s ", addr);
addr[0] = '\0';
ret = getnameinfo((struct sockaddr *)&ifaces[i].netmask,
calc_sa_size(&ifaces[i].netmask),
addr, sizeof(addr),
NULL, 0, NI_NUMERICHOST);
printf("NETMASK=%s ", addr);
addr[0] = '\0';
ret = getnameinfo((struct sockaddr *)&ifaces[i].bcast,
calc_sa_size(&ifaces[i].bcast),
addr, sizeof(addr),
NULL, 0, NI_NUMERICHOST);
printf("BCAST=%s\n", addr);
}
return 0;
}
#endif

View File

@ -0,0 +1,52 @@
/*
* Unix SMB/CIFS implementation.
* Intercept libldap debug output.
* Copyright (C) Michael Adam 2008
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#if HAVE_LDAP
static void samba_ldap_log_print_fn(LDAP_CONST char *data)
{
DEBUG(lp_ldap_debug_threshold(), ("[LDAP] %s", data));
}
#endif
void init_ldap_debugging(void)
{
#if defined(HAVE_LDAP) && defined(HAVE_LBER_LOG_PRINT_FN)
int ret;
int ldap_debug_level = lp_ldap_debug_level();
ret = ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &ldap_debug_level);
if (ret != LDAP_OPT_SUCCESS) {
DEBUG(10, ("Error setting LDAP debug level.\n"));
}
if (ldap_debug_level == 0) {
return;
}
ret = ber_set_option(NULL, LBER_OPT_LOG_PRINT_FN,
(void *)samba_ldap_log_print_fn);
if (ret != LBER_OPT_SUCCESS) {
DEBUG(10, ("Error setting LBER log print function.\n"));
}
#endif /* HAVE_LDAP && HAVE_LBER_LOG_PRINT_FN */
}

View File

@ -22,6 +22,10 @@
#ifdef CLUSTER_SUPPORT
#include "librpc/gen_ndr/messaging.h"
#include "ctdb.h"
#include "ctdb_private.h"
#include "ctdbd_conn.h"
struct messaging_ctdbd_context {
struct ctdbd_connection *conn;

View File

@ -3,9 +3,9 @@ GTK_LIBS=`pkg-config gtk+-2.0 --libs`
KRB5LIBS=@KRB5_LIBS@
LDAP_LIBS=@LDAP_LIBS@
LIBS=@LIBS@ -lnetapi
LIBS=@LIBS@ -lnetapi -ltdb -ltalloc
DEVELOPER_CFLAGS=@DEVELOPER_CFLAGS@
FLAGS=@CFLAGS@ $(GTK_FLAGS)
FLAGS=-I../ -L../../../bin @CFLAGS@ $(GTK_FLAGS)
CC=@CC@
LDFLAGS=@PIE_LDFLAGS@ @LDFLAGS@
DYNEXP=@DYNEXP@
@ -14,7 +14,12 @@ DYNEXP=@DYNEXP@
COMPILE_CC = $(CC) -I. $(FLAGS) $(PICFLAG) -c $< -o $@
COMPILE = $(COMPILE_CC)
BINARY_PREREQS = proto_exists bin/.dummy
PROGS = bin/getdc@EXEEXT@ \
bin/netdomjoin@EXEEXT@ \
bin/netdomjoin-gui@EXEEXT@ \
bin/getjoinableous@EXEEXT@
all: $(PROGS)
MAKEDIR = || exec false; \
if test -d "$$dir"; then :; else \
@ -24,6 +29,13 @@ MAKEDIR = || exec false; \
mkdir "$$dir" || \
exec false; fi || exec false
BINARY_PREREQS = bin/.dummy
bin/.dummy:
@if (: >> $@ || : > $@) >/dev/null 2>&1; then :; else \
dir=bin $(MAKEDIR); fi
@: >> $@ || : > $@ # what a fancy emoticon!
.c.o:
@if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
@ -36,22 +48,25 @@ MAKEDIR = || exec false; \
GETDC_OBJ = getdc/getdc.o
NETDOMJOIN_OBJ = netdomjoin/netdomjoin.o
NETDOMJOIN_GUI_OBJ = netdomjoin-gui/netdomjoin-gui.o
GETJOINABLEOUS_OBJ = getjoinableous/getjoinableous.o
PROGS = bin/getdc@EXEEXT@ bin/netdomjoin@EXEEXT@ bin/netdomjoin-gui@EXEEXT@
all: $(PROGS)
bin/getdc@EXEEXT@: $(GETDC_OBJ)
bin/getdc@EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(GETDC_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS)
bin/netdomjoin@EXEEXT@: $(NETDOMJOIN_OBJ)
bin/getjoinableous@EXEEXT@: $(BINARY_PREREQS) $(GETJOINABLEOUS_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(GETJOINABLEOUS_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS)
bin/netdomjoin@EXEEXT@: $(BINARY_PREREQS) $(NETDOMJOIN_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(NETDOMJOIN_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS)
bin/netdomjoin-gui@EXEEXT@: $(NETDOMJOIN_GUI_OBJ)
bin/netdomjoin-gui@EXEEXT@: $(BINARY_PREREQS) $(NETDOMJOIN_GUI_OBJ)
@echo Linking $@
@$(CC) $(FLAGS) $(GTK_FLAGS) -o $@ $(NETDOMJOIN_GUI_OBJ) $(LDFLAGS) $(DYNEXP) $(LIBS) $(KRB5LIBS) $(LDAP_LIBS) $(GTK_LIBS)
clean:
@rm -f $(PROGS)
-rm -f $(PROGS)
-rm -f core */*~ *~ \
*/*.o */*/*.o */*/*/*.o

View File

@ -29,7 +29,7 @@ int main(int argc, char **argv)
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
uint8_t *buffer;
uint8_t *buffer = NULL;
if (argc < 3) {
printf("usage: getdc <hostname> <domain>\n");
@ -50,7 +50,7 @@ int main(int argc, char **argv)
} else {
printf("%s\n", (char *)buffer);
}
NetApiBufferFree(buffer);
libnetapi_free(ctx);
return status;

View File

@ -0,0 +1,104 @@
/*
* Unix SMB/CIFS implementation.
* Join Support (cmdline + netapi)
* Copyright (C) Guenther Deschner 2008
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdio.h>
#include <netapi.h>
char *get_string_param(const char *param)
{
char *p;
p = strchr(param, '=');
if (!p) {
return NULL;
}
return (p+1);
}
int main(int argc, char **argv)
{
NET_API_STATUS status;
const char *server_name = NULL;
const char *domain_name = NULL;
const char *account = NULL;
const char *password = NULL;
const char **ous = NULL;
uint32_t num_ous = 0;
struct libnetapi_ctx *ctx = NULL;
int i;
status = libnetapi_init(&ctx);
if (status != 0) {
return status;
}
if (argc < 2) {
printf("usage: getjoinableous\n");
printf("\t<hostname> [domain=DOMAIN] <user=USER> <password=PASSWORD>\n");
return 0;
}
if (argc > 2) {
server_name = argv[1];
}
for (i=0; i<argc; i++) {
if (strncasecmp(argv[i], "domain", strlen("domain"))== 0) {
domain_name = get_string_param(argv[i]);
}
if (strncasecmp(argv[i], "user", strlen("user"))== 0) {
account = get_string_param(argv[i]);
libnetapi_set_username(ctx, account);
}
if (strncasecmp(argv[i], "password", strlen("password"))== 0) {
password = get_string_param(argv[i]);
libnetapi_set_password(ctx, password);
}
if (strncasecmp(argv[i], "debug", strlen("debug"))== 0) {
const char *str = NULL;
str = get_string_param(argv[i]);
libnetapi_set_debuglevel(ctx, str);
}
}
status = NetGetJoinableOUs(server_name,
domain_name,
account,
password,
&num_ous,
&ous);
if (status != 0) {
printf("failed with: %s\n",
libnetapi_get_error_string(ctx, status));
} else {
printf("Successfully queried joinable ous:\n");
for (i=0; i<num_ous; i++) {
printf("ou: %s\n", ous[i]);
}
}
NetApiBufferFree(ous);
libnetapi_free(ctx);
return status;
}

View File

@ -24,6 +24,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <netdb.h>
#include <gtk/gtk.h>
#include <glib/gprintf.h>
@ -439,7 +440,7 @@ static void callback_do_join(GtkWidget *widget,
state->password,
unjoin_flags);
if (status != 0) {
err_str = libnetapi_errstr(status);
err_str = libnetapi_get_error_string(state->ctx, status);
g_print("callback_do_join: failed to unjoin (%s)\n",
err_str);
@ -463,7 +464,7 @@ static void callback_do_join(GtkWidget *widget,
state->password,
join_flags);
if (status != 0) {
err_str = libnetapi_errstr(status);
err_str = libnetapi_get_error_string(state->ctx, status);
g_print("callback_do_join: failed to join (%s)\n", err_str);
dialog = gtk_message_dialog_new(GTK_WINDOW(state->window_parent),
@ -1263,37 +1264,56 @@ static int initialize_join_state(struct join_state *state,
{
char my_hostname[HOST_NAME_MAX];
const char *p = NULL;
if (gethostname(my_hostname, sizeof(my_hostname)) == -1) {
return -1;
}
struct hostent *hp = NULL;
state->my_fqdn = strdup(my_hostname);
if (!state->my_fqdn) {
if (gethostname(my_hostname, sizeof(my_hostname)) == -1) {
return -1;
}
p = strchr(my_hostname, '.');
if (p) {
my_hostname[strlen(my_hostname) - strlen(p)] = '\0';
state->my_hostname = strdup(my_hostname);
if (!state->my_hostname) {
return -1;
}
my_hostname[strlen(my_hostname)-strlen(p)] = '\0';
}
state->my_hostname = strdup(my_hostname);
if (!state->my_hostname) {
return -1;
}
debug("state->my_hostname: %s\n", state->my_hostname);
hp = gethostbyname(my_hostname);
if (!hp || !hp->h_name || !*hp->h_name) {
return -1;
}
state->my_fqdn = strdup(hp->h_name);
if (!state->my_fqdn) {
return -1;
}
debug("state->my_fqdn: %s\n", state->my_fqdn);
p = strchr(state->my_fqdn, '.');
if (p) {
p++;
state->my_dnsdomain = strdup(p);
if (!state->my_dnsdomain) {
return -1;
}
} else {
state->my_dnsdomain = strdup("");
}
if (!state->my_dnsdomain) {
return -1;
}
debug("state->my_dnsdomain: %s\n", state->my_dnsdomain);
}
{
const char *buffer = NULL;
uint16_t type = 0;
status = NetGetJoinInformation(NULL, &buffer, &type);
if (status) {
if (status != 0) {
printf("NetGetJoinInformation failed with: %s\n",
libnetapi_get_error_string(state->ctx, status));
return status;
}
debug("NetGetJoinInformation gave: %s and %d\n", buffer, type);
state->name_buffer_initial = strdup(buffer);
if (!state->name_buffer_initial) {
return -1;
@ -1307,7 +1327,9 @@ static int initialize_join_state(struct join_state *state,
uint8_t *buffer = NULL;
status = NetServerGetInfo(NULL, 1005, &buffer);
if (status) {
if (status != 0) {
printf("NetServerGetInfo failed with: %s\n",
libnetapi_get_error_string(state->ctx, status));
return status;
}

View File

@ -22,21 +22,8 @@
#include "lib/netapi/netapi.h"
#include "libnet/libnet.h"
#if 0
#include "librpc/gen_ndr/cli_netlogon.h"
#endif
NTSTATUS rpccli_netr_GetDcName(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
const char *logon_server,
const char *domainname,
const char **dcname);
NTSTATUS rpccli_netr_GetAnyDCName(struct rpc_pipe_client *cli,
TALLOC_CTX *mem_ctx,
const char *logon_server,
const char *domainname,
const char **dcname,
WERROR *werror);
/********************************************************************
********************************************************************/
static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx,
const char *server_name,
@ -46,6 +33,9 @@ static WERROR NetGetDCNameLocal(struct libnetapi_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -76,17 +66,11 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx,
goto done;
};
#if 0
werr = rpccli_netr_GetDcName(pipe_cli, ctx,
server_name,
domain_name,
(const char **)&buffer);
#else
werr = rpccli_netlogon_getdcname(pipe_cli, ctx,
server_name,
domain_name,
(char **)buffer);
#endif
status = rpccli_netr_GetDcName(pipe_cli, ctx,
server_name,
domain_name,
(const char **)buffer,
&werr);
done:
if (cli) {
cli_shutdown(cli);
@ -95,6 +79,9 @@ static WERROR NetGetDCNameRemote(struct libnetapi_ctx *ctx,
return werr;
}
/********************************************************************
********************************************************************/
static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -113,6 +100,10 @@ static WERROR libnetapi_NetGetDCName(struct libnetapi_ctx *ctx,
buffer);
}
/****************************************************************
NetGetDCName
****************************************************************/
NET_API_STATUS NetGetDCName(const char *server_name,
const char *domain_name,
uint8_t **buffer)
@ -134,9 +125,12 @@ NET_API_STATUS NetGetDCName(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}
/********************************************************************
********************************************************************/
static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -145,6 +139,9 @@ static WERROR NetGetAnyDCNameLocal(struct libnetapi_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
/********************************************************************
********************************************************************/
static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -175,22 +172,14 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx,
goto done;
};
#if 0
status = rpccli_netr_GetAnyDCName(pipe_cli, ctx,
server_name,
domain_name,
(const char **)&buffer,
(const char **)buffer,
&werr);
if (!NT_STATUS_IS_OK(status)) {
werr = ntstatus_to_werror(status);
goto done;
}
#else
werr = rpccli_netlogon_getanydcname(pipe_cli, ctx,
server_name,
domain_name,
(char **)buffer);
#endif
done:
if (cli) {
cli_shutdown(cli);
@ -200,6 +189,9 @@ static WERROR NetGetAnyDCNameRemote(struct libnetapi_ctx *ctx,
}
/********************************************************************
********************************************************************/
static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -218,6 +210,10 @@ static WERROR libnetapi_NetGetAnyDCName(struct libnetapi_ctx *ctx,
buffer);
}
/****************************************************************
NetGetAnyDCName
****************************************************************/
NET_API_STATUS NetGetAnyDCName(const char *server_name,
const char *domain_name,
uint8_t **buffer)
@ -239,5 +235,5 @@ NET_API_STATUS NetGetAnyDCName(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}

View File

@ -22,6 +22,9 @@
#include "lib/netapi/netapi.h"
#include "libnet/libnet.h"
/****************************************************************
****************************************************************/
static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
const char *server_name,
const char *domain_name,
@ -45,17 +48,19 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
if (join_flags & WKSSVC_JOIN_FLAGS_JOIN_TYPE) {
NTSTATUS status;
struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
struct netr_DsRGetDCNameInfo *info = NULL;
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_WRITABLE_REQUIRED |
DS_RETURN_DNS_NAME;
status = dsgetdcname(mem_ctx, NULL, domain_name,
status = dsgetdcname(mem_ctx, domain_name,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(mem_ctx,
"%s", get_friendly_nt_error_msg(status));
return ntstatus_to_werror(status);
}
r->in.dc_name = talloc_strdup(mem_ctx,
info->domain_controller_name);
info->dc_unc);
W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
}
@ -79,13 +84,16 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx,
werr = libnet_Join(mem_ctx, r);
if (!W_ERROR_IS_OK(werr) && r->out.error_string) {
libnetapi_set_error_string(mem_ctx, r->out.error_string);
libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string);
}
TALLOC_FREE(r);
return werr;
}
/****************************************************************
****************************************************************/
static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -149,6 +157,9 @@ static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx,
return werr;
}
/****************************************************************
****************************************************************/
static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain_name,
@ -181,6 +192,10 @@ static WERROR libnetapi_NetJoinDomain(struct libnetapi_ctx *ctx,
join_flags);
}
/****************************************************************
NetJoinDomain
****************************************************************/
NET_API_STATUS NetJoinDomain(const char *server_name,
const char *domain_name,
const char *account_ou,
@ -208,9 +223,12 @@ NET_API_STATUS NetJoinDomain(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}
/****************************************************************
****************************************************************/
static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx,
const char *server_name,
const char *account,
@ -232,10 +250,9 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx,
r->in.dc_name = talloc_strdup(mem_ctx, server_name);
W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
} else {
NTSTATUS status;
const char *domain = NULL;
struct DS_DOMAIN_CONTROLLER_INFO *info = NULL;
struct netr_DsRGetDCNameInfo *info = NULL;
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_WRITABLE_REQUIRED |
DS_RETURN_DNS_NAME;
@ -244,13 +261,15 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx,
} else {
domain = lp_workgroup();
}
status = dsgetdcname(mem_ctx, NULL, domain,
status = dsgetdcname(mem_ctx, domain,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(mem_ctx,
"%s", get_friendly_nt_error_msg(status));
return ntstatus_to_werror(status);
}
r->in.dc_name = talloc_strdup(mem_ctx,
info->domain_controller_name);
info->dc_unc);
W_ERROR_HAVE_NO_MEMORY(r->in.dc_name);
}
@ -266,13 +285,22 @@ static WERROR NetUnjoinDomainLocal(struct libnetapi_ctx *mem_ctx,
r->in.unjoin_flags = unjoin_flags;
r->in.modify_config = true;
r->in.debug = true;
r->in.domain_sid = &domain_sid;
return libnet_Unjoin(mem_ctx, r);
werr = libnet_Unjoin(mem_ctx, r);
if (!W_ERROR_IS_OK(werr) && r->out.error_string) {
libnetapi_set_error_string(mem_ctx, "%s", r->out.error_string);
}
TALLOC_FREE(r);
return werr;
}
/****************************************************************
****************************************************************/
static WERROR NetUnjoinDomainRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char *account,
@ -335,6 +363,9 @@ static WERROR NetUnjoinDomainRemote(struct libnetapi_ctx *ctx,
return werr;
}
/****************************************************************
****************************************************************/
static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx,
const char *server_name,
const char *account,
@ -357,6 +388,10 @@ static WERROR libnetapi_NetUnjoinDomain(struct libnetapi_ctx *ctx,
unjoin_flags);
}
/****************************************************************
NetUnjoinDomain
****************************************************************/
NET_API_STATUS NetUnjoinDomain(const char *server_name,
const char *account,
const char *password,
@ -380,9 +415,12 @@ NET_API_STATUS NetUnjoinDomain(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}
/****************************************************************
****************************************************************/
static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char **name_buffer,
@ -431,6 +469,9 @@ static WERROR NetGetJoinInformationRemote(struct libnetapi_ctx *ctx,
return werr;
}
/****************************************************************
****************************************************************/
static WERROR NetGetJoinInformationLocal(struct libnetapi_ctx *ctx,
const char *server_name,
const char **name_buffer,
@ -478,6 +519,10 @@ static WERROR libnetapi_NetGetJoinInformation(struct libnetapi_ctx *ctx,
name_type);
}
/****************************************************************
NetGetJoinInformation
****************************************************************/
NET_API_STATUS NetGetJoinInformation(const char *server_name,
const char **name_buffer,
uint16_t *name_type)
@ -499,5 +544,201 @@ NET_API_STATUS NetGetJoinInformation(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}
/****************************************************************
****************************************************************/
static WERROR NetGetJoinableOUsLocal(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain,
const char *account,
const char *password,
uint32_t *ou_count,
const char ***ous)
{
#ifdef WITH_ADS
NTSTATUS status;
ADS_STATUS ads_status;
ADS_STRUCT *ads = NULL;
struct netr_DsRGetDCNameInfo *info = NULL;
uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED |
DS_RETURN_DNS_NAME;
status = dsgetdcname(ctx, domain,
NULL, NULL, flags, &info);
if (!NT_STATUS_IS_OK(status)) {
libnetapi_set_error_string(ctx, "%s",
get_friendly_nt_error_msg(status));
return ntstatus_to_werror(status);
}
ads = ads_init(domain, domain, info->dc_unc);
if (!ads) {
return WERR_GENERAL_FAILURE;
}
SAFE_FREE(ads->auth.user_name);
if (account) {
ads->auth.user_name = SMB_STRDUP(account);
} else if (ctx->username) {
ads->auth.user_name = SMB_STRDUP(ctx->username);
}
SAFE_FREE(ads->auth.password);
if (password) {
ads->auth.password = SMB_STRDUP(password);
} else if (ctx->password) {
ads->auth.password = SMB_STRDUP(ctx->password);
}
ads_status = ads_connect(ads);
if (!ADS_ERR_OK(ads_status)) {
ads_destroy(&ads);
return WERR_DEFAULT_JOIN_REQUIRED;
}
ads_status = ads_get_joinable_ous(ads, ctx,
(char ***)ous,
(size_t *)ou_count);
if (!ADS_ERR_OK(ads_status)) {
ads_destroy(&ads);
return WERR_DEFAULT_JOIN_REQUIRED;
}
ads_destroy(&ads);
return WERR_OK;
#else
return WERR_NOT_SUPPORTED;
#endif
}
/****************************************************************
****************************************************************/
static WERROR NetGetJoinableOUsRemote(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain,
const char *account,
const char *password,
uint32_t *ou_count,
const char ***ous)
{
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_cli = NULL;
struct wkssvc_PasswordBuffer *encrypted_password = NULL;
NTSTATUS status;
WERROR werr;
status = cli_full_connection(&cli, NULL, server_name,
NULL, 0,
"IPC$", "IPC",
ctx->username,
ctx->workgroup,
ctx->password,
0, Undefined, NULL);
if (!NT_STATUS_IS_OK(status)) {
werr = ntstatus_to_werror(status);
goto done;
}
pipe_cli = cli_rpc_pipe_open_noauth(cli, PI_WKSSVC,
&status);
if (!pipe_cli) {
werr = ntstatus_to_werror(status);
goto done;
}
if (password) {
encode_wkssvc_join_password_buffer(ctx,
password,
&cli->user_session_key,
&encrypted_password);
}
status = rpccli_wkssvc_NetrGetJoinableOus2(pipe_cli, ctx,
server_name,
domain,
account,
encrypted_password,
ou_count,
ous,
&werr);
if (!NT_STATUS_IS_OK(status)) {
werr = ntstatus_to_werror(status);
goto done;
}
done:
if (cli) {
cli_shutdown(cli);
}
return werr;
}
/****************************************************************
****************************************************************/
static WERROR libnetapi_NetGetJoinableOUs(struct libnetapi_ctx *ctx,
const char *server_name,
const char *domain,
const char *account,
const char *password,
uint32_t *ou_count,
const char ***ous)
{
if (!server_name || is_myname_or_ipaddr(server_name)) {
return NetGetJoinableOUsLocal(ctx,
server_name,
domain,
account,
password,
ou_count,
ous);
}
return NetGetJoinableOUsRemote(ctx,
server_name,
domain,
account,
password,
ou_count,
ous);
}
/****************************************************************
NetGetJoinableOUs
****************************************************************/
NET_API_STATUS NetGetJoinableOUs(const char *server_name,
const char *domain,
const char *account,
const char *password,
uint32_t *ou_count,
const char ***ous)
{
struct libnetapi_ctx *ctx = NULL;
NET_API_STATUS status;
WERROR werr;
status = libnetapi_getctx(&ctx);
if (status != 0) {
return status;
}
werr = libnetapi_NetGetJoinableOUs(ctx,
server_name,
domain,
account,
password,
ou_count,
ous);
if (!W_ERROR_IS_OK(werr)) {
return W_ERROR_V(werr);
}
return NET_API_STATUS_SUCCESS;
}

View File

@ -50,7 +50,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context)
return W_ERROR_V(WERR_NOMEM);
}
DEBUGLEVEL = 0;
if (!DEBUGLEVEL) {
DEBUGLEVEL = 0;
}
setup_logging("libnetapi", true);
dbf = x_stderr;
@ -119,7 +121,6 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
gencache_shutdown();
secrets_shutdown();
regdb_close();
TALLOC_FREE(ctx);
TALLOC_FREE(frame);
@ -205,15 +206,20 @@ const char *libnetapi_errstr(NET_API_STATUS status)
****************************************************************/
NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
const char *error_string)
const char *format, ...)
{
va_list args;
TALLOC_FREE(ctx->error_string);
ctx->error_string = talloc_strdup(ctx, error_string);
va_start(args, format);
ctx->error_string = talloc_vasprintf(ctx, format, args);
va_end(args);
if (!ctx->error_string) {
return W_ERROR_V(WERR_NOMEM);
}
return NET_API_STATUS_SUCCESS;
}
/****************************************************************

View File

@ -36,6 +36,11 @@
/****************************************************************
****************************************************************/
#define LIBNETAPI_LOCAL_SERVER(x) (!x || is_myname_or_ipaddr(x))
/****************************************************************
****************************************************************/
struct libnetapi_ctx {
char *debuglevel;
char *error_string;
@ -57,46 +62,84 @@ NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *use
NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password);
NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup);
const char *libnetapi_errstr(NET_API_STATUS status);
NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string);
NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *format, ...);
const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx, NET_API_STATUS status);
/****************************************************************
NetApiBufferFree
****************************************************************/
NET_API_STATUS NetApiBufferFree(void *buffer);
/****************************************************************
NetJoinDomain
****************************************************************/
/* wkssvc */
NET_API_STATUS NetJoinDomain(const char *server,
const char *domain,
const char *account_ou,
const char *account,
const char *password,
uint32_t join_options);
/****************************************************************
NetUnjoinDomain
****************************************************************/
NET_API_STATUS NetUnjoinDomain(const char *server_name,
const char *account,
const char *password,
uint32_t unjoin_flags);
/****************************************************************
NetGetJoinInformation
****************************************************************/
NET_API_STATUS NetGetJoinInformation(const char *server_name,
const char **name_buffer,
uint16_t *name_type);
/* srvsvc */
/****************************************************************
NetGetJoinableOUs
****************************************************************/
NET_API_STATUS NetGetJoinableOUs(const char *server_name,
const char *domain,
const char *account,
const char *password,
uint32_t *ou_count,
const char ***ous);
/****************************************************************
NetServerGetInfo
****************************************************************/
NET_API_STATUS NetServerGetInfo(const char *server_name,
uint32_t level,
uint8_t **buffer);
/****************************************************************
NetServerSetInfo
****************************************************************/
NET_API_STATUS NetServerSetInfo(const char *server_name,
uint32_t level,
uint8_t *buffer,
uint32_t *parm_error);
/* netlogon */
/****************************************************************
NetGetDCName
****************************************************************/
NET_API_STATUS NetGetDCName(const char *server_name,
const char *domain_name,
uint8_t **buffer);
/****************************************************************
NetGetAnyDCName
****************************************************************/
NET_API_STATUS NetGetAnyDCName(const char *server_name,
const char *domain_name,
uint8_t **buffer);

View File

@ -22,6 +22,9 @@
#include "lib/netapi/netapi.h"
#include "libnet/libnet.h"
/****************************************************************
****************************************************************/
static WERROR NetServerGetInfoLocal_1005(struct libnetapi_ctx *ctx,
uint8_t **buffer)
{
@ -36,6 +39,9 @@ static WERROR NetServerGetInfoLocal_1005(struct libnetapi_ctx *ctx,
return WERR_OK;
}
/****************************************************************
****************************************************************/
static WERROR NetServerGetInfoLocal(struct libnetapi_ctx *ctx,
const char *server_name,
uint32_t level,
@ -51,6 +57,9 @@ static WERROR NetServerGetInfoLocal(struct libnetapi_ctx *ctx,
return WERR_UNKNOWN_LEVEL;
}
/****************************************************************
****************************************************************/
static WERROR NetServerGetInfoRemote(struct libnetapi_ctx *ctx,
const char *server_name,
uint32_t level,
@ -102,6 +111,9 @@ static WERROR NetServerGetInfoRemote(struct libnetapi_ctx *ctx,
return werr;
}
/****************************************************************
****************************************************************/
static WERROR libnetapi_NetServerGetInfo(struct libnetapi_ctx *ctx,
const char *server_name,
uint32_t level,
@ -121,6 +133,10 @@ static WERROR libnetapi_NetServerGetInfo(struct libnetapi_ctx *ctx,
}
/****************************************************************
NetServerGetInfo
****************************************************************/
NET_API_STATUS NetServerGetInfo(const char *server_name,
uint32_t level,
uint8_t **buffer)
@ -142,17 +158,18 @@ NET_API_STATUS NetServerGetInfo(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}
/****************************************************************
****************************************************************/
static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx,
uint8_t *buffer,
uint32_t *parm_error)
{
WERROR werr;
struct libnet_conf_ctx *conf_ctx;
TALLOC_CTX *mem_ctx;
struct srvsvc_NetSrvInfo1005 *info1005;
if (!buffer) {
@ -167,12 +184,11 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx,
return WERR_INVALID_PARAM;
}
if (!lp_include_registry_globals()) {
if (!lp_config_backend_is_registry()) {
return WERR_NOT_SUPPORTED;
}
mem_ctx = talloc_stackframe();
werr = libnet_conf_open(mem_ctx, &conf_ctx);
werr = libnet_conf_open(ctx, &conf_ctx);
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@ -181,12 +197,14 @@ static WERROR NetServerSetInfoLocal_1005(struct libnetapi_ctx *ctx,
"server string",
info1005->comment);
done:
done:
libnet_conf_close(conf_ctx);
TALLOC_FREE(mem_ctx);
return werr;
}
/****************************************************************
****************************************************************/
static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx,
const char *server_name,
uint32_t level,
@ -203,6 +221,9 @@ static WERROR NetServerSetInfoLocal(struct libnetapi_ctx *ctx,
return WERR_UNKNOWN_LEVEL;
}
/****************************************************************
****************************************************************/
static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx,
const char *server_name,
uint32_t level,
@ -263,6 +284,9 @@ static WERROR NetServerSetInfoRemote(struct libnetapi_ctx *ctx,
return werr;
}
/****************************************************************
****************************************************************/
static WERROR libnetapi_NetServerSetInfo(struct libnetapi_ctx *ctx,
const char *server_name,
uint32_t level,
@ -284,6 +308,9 @@ static WERROR libnetapi_NetServerSetInfo(struct libnetapi_ctx *ctx,
parm_error);
}
/****************************************************************
NetServerSetInfo
****************************************************************/
NET_API_STATUS NetServerSetInfo(const char *server_name,
uint32_t level,
@ -308,5 +335,5 @@ NET_API_STATUS NetServerSetInfo(const char *server_name,
return W_ERROR_V(werr);
}
return 0;
return NET_API_STATUS_SUCCESS;
}

View File

@ -71,10 +71,19 @@ static void popt_common_callback(poptContext con,
}
if (reason == POPT_CALLBACK_REASON_POST) {
if (!PrintSambaVersionString) return;
printf( "Version %s\n", SAMBA_VERSION_STRING);
exit(0);
if (PrintSambaVersionString) {
printf( "Version %s\n", SAMBA_VERSION_STRING);
exit(0);
}
if (is_default_dyn_CONFIGFILE()) {
if(getenv("SMB_CONF_PATH")) {
set_dyn_CONFIGFILE(getenv("SMB_CONF_PATH"));
}
}
/* Further 'every Samba program must do this' hooks here. */
return;
}

View File

@ -317,6 +317,10 @@ const char* get_privilege_dispname( const char *name )
{
int i;
if (!name) {
return NULL;
}
for ( i=0; !se_priv_equal(&privs[i].se_priv, &se_priv_end); i++ ) {
if ( strequal( privs[i].name, name ) ) {
@ -469,7 +473,7 @@ bool se_priv_to_privilege_set( PRIVILEGE_SET *set, SE_PRIV *mask )
/*******************************************************************
*******************************************************************/
static bool luid_to_se_priv( LUID *luid, SE_PRIV *mask )
static bool luid_to_se_priv( struct lsa_LUID *luid, SE_PRIV *mask )
{
int i;
uint32 num_privs = count_all_privileges();
@ -487,7 +491,7 @@ static bool luid_to_se_priv( LUID *luid, SE_PRIV *mask )
/*******************************************************************
*******************************************************************/
bool privilege_set_to_se_priv( SE_PRIV *mask, PRIVILEGE_SET *privset )
bool privilege_set_to_se_priv( SE_PRIV *mask, struct lsa_PrivilegeSet *privset )
{
int i;

View File

@ -1,217 +0,0 @@
/*
Unix SMB/CIFS implementation.
Copyright (C) Andrew Tridgell 2005
Updated for Samba3 64-bit cleanliness (C) Jeremy Allison 2006
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
a replacement for opendir/readdir/telldir/seekdir/closedir for BSD systems
This is needed because the existing directory handling in FreeBSD
and OpenBSD (and possibly NetBSD) doesn't correctly handle unlink()
on files in a directory where telldir() has been used. On a block
boundary it will occasionally miss a file when seekdir() is used to
return to a position previously recorded with telldir().
This also fixes a severe performance and memory usage problem with
telldir() on BSD systems. Each call to telldir() in BSD adds an
entry to a linked list, and those entries are cleaned up on
closedir(). This means with a large directory closedir() can take an
arbitrary amount of time, causing network timeouts as millions of
telldir() entries are freed
Note! This replacement code is not portable. It relies on getdents()
always leaving the file descriptor at a seek offset that is a
multiple of DIR_BUF_SIZE. If the code detects that this doesn't
happen then it will abort(). It also does not handle directories
with offsets larger than can be stored in a long,
This code is available under other free software licenses as
well. Contact the author.
*/
#include <include/includes.h>
void replace_readdir_dummy(void);
void replace_readdir_dummy(void) {}
#if defined(REPLACE_READDIR)
#if defined(PARANOID_MALLOC_CHECKER)
#ifdef malloc
#undef malloc
#endif
#endif
#define DIR_BUF_BITS 9
#define DIR_BUF_SIZE (1<<DIR_BUF_BITS)
struct dir_buf {
int fd;
int nbytes, ofs;
SMB_OFF_T seekpos;
char buf[DIR_BUF_SIZE];
};
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OPENDIR64)
SMB_STRUCT_DIR *opendir64(const char *dname)
#else
SMB_STRUCT_DIR *opendir(const char *dname)
#endif
{
struct dir_buf *d;
d = malloc(sizeof(*d));
if (d == NULL) {
errno = ENOMEM;
return NULL;
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_OPEN64)
d->fd = open64(dname, O_RDONLY);
#else
d->fd = open(dname, O_RDONLY);
#endif
if (d->fd == -1) {
free(d);
return NULL;
}
d->ofs = 0;
d->seekpos = 0;
d->nbytes = 0;
return (SMB_STRUCT_DIR *)d;
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64)
SMB_STRUCT_DIRENT *readdir64(SMB_STRUCT_DIR *dir)
#else
SMB_STRUCT_DIRENT *readdir(SMB_STRUCT_DIR *dir)
#endif
{
struct dir_buf *d = (struct dir_buf *)dir;
SMB_STRUCT_DIRENT *de;
if (d->ofs >= d->nbytes) {
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_LSEEK64)
d->seekpos = lseek64(d->fd, 0, SEEK_CUR);
#else
d->seekpos = lseek(d->fd, 0, SEEK_CUR);
#endif
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_GETDENTS64)
d->nbytes = getdents64(d->fd, d->buf, DIR_BUF_SIZE);
#else
d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE);
#endif
d->ofs = 0;
}
if (d->ofs >= d->nbytes) {
return NULL;
}
de = (SMB_STRUCT_DIRENT *)&d->buf[d->ofs];
d->ofs += de->d_reclen;
return de;
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_TELLDIR64)
long telldir64(SMB_STRUCT_DIR *dir)
#else
long telldir(SMB_STRUCT_DIR *dir)
#endif
{
struct dir_buf *d = (struct dir_buf *)dir;
if (d->ofs >= d->nbytes) {
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_LSEEK64)
d->seekpos = lseek64(d->fd, 0, SEEK_CUR);
#else
d->seekpos = lseek(d->fd, 0, SEEK_CUR);
#endif
d->ofs = 0;
d->nbytes = 0;
}
/* this relies on seekpos always being a multiple of
DIR_BUF_SIZE. Is that always true on BSD systems? */
if (d->seekpos & (DIR_BUF_SIZE-1)) {
abort();
}
return d->seekpos + d->ofs;
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_SEEKDIR64)
void seekdir64(SMB_STRUCT_DIR *dir, long ofs)
#else
void seekdir(SMB_STRUCT_DIR *dir, long ofs)
#endif
{
struct dir_buf *d = (struct dir_buf *)dir;
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_LSEEK64)
d->seekpos = lseek64(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET);
#else
d->seekpos = lseek(d->fd, ofs & ~(DIR_BUF_SIZE-1), SEEK_SET);
#endif
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_GETDENTS64)
d->nbytes = getdents64(d->fd, d->buf, DIR_BUF_SIZE);
#else
d->nbytes = getdents(d->fd, d->buf, DIR_BUF_SIZE);
#endif
d->ofs = 0;
while (d->ofs < (ofs & (DIR_BUF_SIZE-1))) {
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_READDIR64)
if (readdir64(dir) == NULL) break;
#else
if (readdir(dir) == NULL) break;
#endif
}
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_REWINDDIR64)
void rewinddir64(SMB_STRUCT_DIR *dir)
#else
void rewinddir(SMB_STRUCT_DIR *dir)
#endif
{
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_SEEKDIR64)
seekdir64(dir, 0);
#else
seekdir(dir, 0);
#endif
}
#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_CLOSEDIR64)
int closedir64(SMB_STRUCT_DIR *dir)
#else
int closedir(SMB_STRUCT_DIR *dir)
#endif
{
struct dir_buf *d = (struct dir_buf *)dir;
int r = close(d->fd);
if (r != 0) {
return r;
}
free(d);
return 0;
}
#ifndef dirfd
/* darn, this is a macro on some systems. */
int dirfd(SMB_STRUCT_DIR *dir)
{
struct dir_buf *d = (struct dir_buf *)dir;
return d->fd;
}
#endif
#endif /* REPLACE_READDIR */

Some files were not shown because too many files have changed in this diff Show More